Double password entering in editproj as well
[girocco/mytab.git] / cgi / regproj.cgi
blob5a300fbff10e12d4a991c2b324b712d77ec520c2
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib qw(/home/repo/repomgr/cgi);
9 use Git::RepoCGI;
11 my $repo = Git::RepoCGI->new('Project Registration');
12 my $cgi = $repo->cgi;
14 my $name = $cgi->param('name');
15 $name ||= '';
17 if ($cgi->param('mode')) {
18 # submitted, let's see
19 # FIXME: racy, do a lock
20 my $name = $repo->wparam('name');
21 valid_proj_name($name)
22 and Git::RepoCGI::Project::does_exist($name)
23 and $repo->err("Project with the name '$name' already exists.");
24 $name =~ /\.git$/
25 and $repo->err("Project name should not end with <tt>.git</tt> - I'll add that automagically.");
27 my $mirror = $cgi->param('mode') eq 'mirror';
28 my $proj = Git::RepoCGI::Project->ghost($name, $mirror);
29 if ($proj->cgi_fill($repo)) {
30 if ($mirror) {
31 $proj->premirror;
32 print "<p>Initiated mirroring. You will be notified about the result by mail.</p>\n";
33 } else {
34 $proj->conjure;
35 print <<EOT;
36 <p>
37 Project <a href="/w/$name.git">$name</a> successfuly set up.</p>
38 <p>The push URL for the project is <tt>git+ssh://repo.or.cz/srv/git/$name.git</tt>.</p>
39 <p>You can <a href="p/editproj.cgi">assign users</a> now (use project name (without <tt>.git</tt>) as username, admin password as password)
40 - don't forget to assign yourself as a user as well if you want to push!
41 Everyone who wants to push must <a href="reguser.cgi">register himself as a user</a> first.
42 (One user can have push access to multiple projects and multiple users can have push access to one project.)
43 </p>
44 <p>Note that you cannot clone an empty repository since it contains no branches; you need to make the first push from an existing repository.</p>
45 <p>You may experience permission problems if you try to push right now.
46 If so, that should get fixed automagically in few minutes, please be patient.</p>
47 <p>Enjoy yourself!</p>
48 EOT
50 exit;
54 print <<EOT;
55 <p>Here you can register a project.
56 It can be hosted in two modes: mirror mode and push mode.
57 In the <b>mirror mode</b>, our dedicated git monkeys will check another repository at a given URL every hour and mirror any new updates.
58 In the <b>push mode</b>, registered users with appropriate permissions will be able to push to the repository.
59 You currently cannot switch freely between those two modes;
60 if you want to switch from mirroring to push mode, just delete and recreate
61 the project. If you want to switch the other way, please contact the administrator.</p>
62 <p>You will need the admin password to adjust the project settings later
63 (mirroring URL, list of users allowed to push, project description, ...).
64 Use the project name (without <tt>.git</tt>) as the username when asked by the browser.</p>
65 EOT
66 unless ($name =~ m#/#) {
67 print <<EOT;
68 <p>Note that if your project is a <strong>fork of an existing project</strong>
69 (this does not mean anything socially bad), please instead go to the project's
70 gitweb page and click the 'fork' link in the top bar. This way, all of us
71 will save bandwidth and more importantly, your project will be properly categorized.
72 If your project is a fork but the existing project is not registered here yet, please
73 consider registering it first; you do not have to be involved in the project
74 in order to register it here as a mirror.</p>
75 EOT
76 } else {
77 my $xname = $name; $xname =~ s#/$#.git#;
78 print <<EOT;
79 <p>Great, your project will be created as a subproject of the '$xname' project.
80 This means that it will be properly categorized and you will need to push only
81 the data <em>you</em> created, not the whole project. (That will be done automagically,
82 you do not need to specify any extra arguments during the push.)</p>
83 EOT
85 print <<EOT;
86 <p>By submitting this form, you are confirming that the repository contains only free software
87 and redistributing it does not violate any law of Czech Republic. Read <a href="/about.html">more details</a>
88 about the hosting and terms and conditions.</p>
89 <p>Have fun!</p>
90 <form method="post">
91 <p>Project name (w/o the .git suffix): <input type="text" name="name" value="$name" /></p>
92 <p>Admin password: <input type="password" name="pwd" /></p>
93 <p>Admin password (retype): <input type="password" name="pwd2" /></p>
94 <p>E-mail contact: <input type="text" name="email" /></p>
95 <p>Hosting mode:</p><ul>
96 <li><input type="radio" name="mode" value="mirror" />Mirror mode. Repository URL: <input type="text" name="url" /></li>
97 <li><input type="radio" name="mode" value="push" />Push mode.</li></ul>
98 <p>Description: <input type="text" name="desc" /></p>
99 <p>Homepage URL: <input type="text" name="hp" /></p>
100 <p>README (HTML, lt 8kb): <textarea name="README" rows="5" cols="80"></textarea></p>
101 <p><input type="submit" name="y0" value="Register" /></p>
102 </form>