Add a nickname configuration variable
[girocco.git] / Girocco / Config.pm
blob945d2e47e78834aa3b4ecbbbe923e51a2d342c71
1 package Girocco::Config;
3 use strict;
4 use warnings;
7 ## Basic settings
9 # Name of the service
10 our $name = "GiroccoEx";
12 # Nickname of the service (undef for initial part of $name upto first '.')
13 our $nickname = undef;
15 # Title of the service (as shown in gitweb)
16 our $title = "Example Girocco Hosting";
18 # Path to the Git binary to use (you MUST set this, even if to /usr/bin/git!)
19 our $git_bin = '/usr/bin/git';
21 # E-mail of the site admin
22 our $admin = 'admin@example.org';
24 # Girocco branch to use for html.cgi view source links (undef for HEAD)
25 our $giroccobranch = undef;
28 ## Feature knobs
30 # Enable mirroring mode if true
31 our $mirror = 1;
33 # Enable push mode if true
34 our $push = 1;
36 # Enable user management if true; this means the interface for registering
37 # user accounts and uploading SSH keys. This implies full chroot.
38 our $manage_users = 1;
40 # Enable the special 'mob' user if set to 'mob'
41 our $mob = "mob";
43 # Let users set admin passwords; if false, all password inputs are assumed empty.
44 # This will make new projects use empty passwords and all operations on them
45 # unrestricted, but you will be able to do no operations on previously created
46 # projects you have set a password on.
47 our $project_passwords = 1;
49 # How to determine project owner; 'email' adds a form item asking for their
50 # email contact, 'source' takes realname of owner of source repository if it
51 # is a local path (and empty string otherwise). 'source' is suitable in case
52 # the site operates only as mirror of purely local-filesystem repositories.
53 our $project_owners = 'email';
55 # Which project fields to make editable, out of 'shortdesc', 'homepage',
56 # 'README', 'notifymail', 'notifyjson', 'notifycia'. (This is currently
57 # soft restriction - form fields aren't used, but manually injected values
58 # *are* used. Submit a patch if that's an issue for you.)
59 our @project_fields = qw(homepage shortdesc README notifymail notifyjson notifycia);
61 # Minimal number of seconds to pass between two updates of a project.
62 our $min_mirror_interval = 3600; # 1 hour
64 # Minimal number of seconds to pass between two garbage collections of a project.
65 our $min_gc_interval = 604800; # 1 week
68 ## Paths
70 # Path where the main chunk of Girocco files will be installed
71 # This will get COMPLETELY OVERWRITTEN by each make install!!!
72 our $basedir = '/home/repo/repomgr';
74 # The repository collection
75 # "$reporoot-recyclebin" will also be created for use by toolbox/trash-project.pl
76 our $reporoot = "/srv/git";
78 # The chroot for ssh pushing; location for project database and other run-time
79 # data even in non-chroot setups
80 our $chroot = "/home/repo/j";
82 # The gitweb files web directory (corresponds to $gitwebfiles)
83 our $webroot = "/home/repo/WWW";
85 # The CGI-enabled web directory (corresponds to $gitweburl and $webadmurl)
86 our $cgiroot = "/home/repo/WWW";
88 # A web-accessible symlink to $reporoot (corresponds to $httppullurl, can be undef)
89 our $webreporoot = "/home/repo/WWW/r";
92 ## URL addresses
94 # URL of the gitweb.cgi script (must be in pathinfo mode)
95 our $gitweburl = "http://repo.or.cz/w";
97 # URL of the extra gitweb files (CSS, .js files, images, ...)
98 our $gitwebfiles = "http://repo.or.cz";
100 # URL of the Girocco CGI web admin interface (Girocco cgi/ subdirectory)
101 our $webadmurl = "http://repo.or.cz";
103 # URL of the Girocco CGI html templater (Girocco cgi/html.cgi)
104 our $htmlurl = "http://repo.or.cz/h";
106 # HTTP URL of the repository collection (undef if N/A)
107 our $httppullurl = "http://repo.or.cz/r";
109 # HTTPS push URL of the repository collection (undef if N/A)
110 our $httpspushurl = undef;
112 # Git URL of the repository collection (undef if N/A)
113 # (You need to set up git-daemon on your system, and Girocco will not
114 # do this particular thing for you.)
115 our $gitpullurl = "git://repo.or.cz";
117 # Pushy URL of the repository collection (undef if N/A)
118 our $pushurl = "ssh://repo.or.cz/srv/git";
120 # URL of gitweb of this Girocco instance (set to undef if you're not nice
121 # to the community)
122 our $giroccourl = "$Girocco::Config::gitweburl/girocco.git";
125 ## Some templating settings
127 # Legal warning (on reguser and regproj pages)
128 our $legalese = <<EOT;
129 <p>By submitting this form, you are confirming that you will mirror or push
130 only what we can store and show to anyone else who can visit this site without
131 breaking any law, and that you will be nice to all small furry animals.
132 <sup><a href="$Girocco::Config::htmlurl/about.html">(more details)</a></sup>
133 </p>
136 # Pre-configured mirror sources (set to undef for none)
137 # Arrayref of name - record pairs, the record has these attributes:
138 # label: The label of this source
139 # url: The template URL; %1, %2, ... will be substituted for inputs
140 # desc: Optional VERY short description
141 # link: Optional URL to make the desc point at
142 # inputs: Arrayref of hashref input records:
143 # label: Label of input record
144 # suffix: Optional suffix
145 # If the inputs arrayref is undef, single URL input is shown,
146 # pre-filled with url (probably empty string).
147 our $mirror_sources = [
149 label => 'Anywhere',
150 url => '',
151 desc => 'Any HTTP/Git/rsync pull URL - bring it on!',
152 inputs => undef
155 label => 'GitHub',
156 url => 'git://github.com/%1/%2.git',
157 desc => 'GitHub Social Code Hosting',
158 link => 'http://github.com/',
159 inputs => [ { label => 'User:' }, { label => 'Project:', suffix => '.git' } ]
162 label => 'Gitorious',
163 url => 'git://gitorious.org/%1/%2.git',
164 desc => 'Green and Orange Boxes',
165 link => 'http://gitorious.org/',
166 inputs => [ { label => 'Project:' }, { label => 'Repository:', suffix => '.git' } ]
170 # You can customize the gitweb interface widely by editing
171 # gitweb/gitweb_config.perl
174 ## Permission settings
176 # Note that if you are going to need the fixupd daemon running,
177 # ($chrooted and $permission_control eq 'Group'), you need to update
178 # the settings in fixupd/fixupd.sh as well.
180 # Girocco needs some way to manipulate write permissions to various parts of
181 # all repositories; this concerns three entities:
182 # - www-data: the web interface needs to be able to rewrite few files within
183 # the repository
184 # - repo: a user designated for cronjobs; handles mirroring and repacking;
185 # this one is optional if not $mirror
186 # - others: the designated users that are supposed to be able to push; they
187 # may have account either within chroot, or outside of it
189 # There are several ways how to use Girocco based on a combination of the
190 # following settings.
192 # (Non-chroot) UNIX user the CGI scripts run on; note that if some non-related
193 # untrusted CGI scripts run on this account too, that can be a big security
194 # problem and you'll probably need to set up suexec (poor you).
195 our $cgi_user = 'www-data';
197 # (Non-chroot) UNIX user performing mirroring jobs; this is the user who
198 # should run all the daemons and cronjobs (except the fixupd) and
199 # the user who should be running make install (if not root).
200 our $mirror_user = 'repo';
202 # (Non-chroot) UNIX group owning the repositories by default; it owns whole
203 # mirror repositories and at least web-writable metadata of push repositories.
204 # If you undefine this, all the data will become WORLD-WRITABLE.
205 # Both $cgi_user and $mirror_user should be members of this group!
206 our $owning_group = 'repo';
208 # Whether to use chroot jail for pushing; this must be always the same
209 # as $manage_users.
210 # TODO: Gitosis support for $manage_users and not $chrooted?
211 our $chrooted = $manage_users;
213 # How to control permissions of push-writable data in push repositories:
214 # * 'Group' for the traditional model: The $chroot/etc/group project database
215 # file is used as the UNIX group(5) file; the directories have gid appropriate
216 # for the particular repository and are group-writable. This works only if
217 # $chrooted so that users are put in the proper groups on login. This requires
218 # you also to set up the fixupd/fixupd.sh daemon for root.
219 # * 'ACL' for a model based on POSIX ACL: The directories are coupled with ACLs
220 # listing the users with push permissions. This works for both chroot and
221 # non-chroot setups, however it requires ACL support within the filesystem.
222 # This option is BASICALLY UNTESTED, too. And UNIMPLEMENTED. :-)
223 # * 'Hooks' for a relaxed model: The directories are world-writable and push
224 # permission control is purely hook-driven. This is INSECURE and works only
225 # when you trust all your users; on the other hand, the attack vectors are
226 # mostly just DoS or fully-traceable tinkering.
227 our $permission_control = 'Group';
229 # Path to named pipe for fixing up project permissions
230 # Will be read by fixupd.sh
231 our $fixup_queue = '/var/tmp/fixup.fifo';
233 # Couple of sanity checks
234 $nickname = (split(/[.]/, $Girocco::Config::name))[0] unless $nickname;
235 ($mirror or $push) or die "Girocco::Config: neither \$mirror or \$push is set?!";
236 (not $push or ($pushurl or $gitpullurl or $httppullurl)) or die "Girocco::Config: no pull URL is set";
237 (not $push or $pushurl) or die "Girocco::Config: \$push set but \$pushurl is undef";
238 (not $mirror or $mirror_user) or die "Girocco::Config: \$mirror set but \$mirror_user is undef";
239 ($manage_users == $chrooted) or die "Girocco::Config: \$manage_users and \$chrooted must be set to the same value";
240 (not $chrooted or $permission_control ne 'ACL') or die "Girocco::Config: resolving uids for ACL not supported when using chroot";
241 (grep { $permission_control eq $_ } qw(Group Hooks)) or die "Girocco::Config: \$permission_control must be set to Group or Hooks";
242 ($chrooted or not $mob) or die "Girocco::Config: mob user supported only in the chrooted mode";