2 # The Girocco installation script
3 # We will OVERWRITE basedir!
7 if [ -z "$MAKE" ]; then
8 echo "ERROR: MAKE not set" >&2
9 echo "Please run install.sh using 'make install'" >&2
10 echo "or set MAKE to the name of the GNU make executable" >&2
14 # Run perl module checker
15 if [ ! -x toolbox
/check-perl-modules.pl
]; then
16 echo "ERROR: missing toolbox/check-perl-modules.pl!" >&2
19 toolbox
/check-perl-modules.pl
21 # What Config should we use?
22 [ -n "$GIROCCO_CONF" ] || GIROCCO_CONF
=Girocco
::Config
23 echo "*** Initializing using $GIROCCO_CONF..."
25 # First run Girocco::Config consistency checks
26 perl
-I.
-M$GIROCCO_CONF -e ''
31 [ -z "$cfg_owning_group" ] || owngroup
=":$cfg_owning_group"
32 if [ -n "$cfg_httpspushurl" -a -z "$cfg_certsdir" ]; then
33 echo "ERROR: \$httpspushurl is set but \$certsdir is not!" >&2
34 echo "ERROR: perhaps you have an incorrect Config.pm?" >&2
39 echo "*** Checking for compiled utilities..."
40 if [ ! -x src
/can_user_push
]; then
41 echo "ERROR: src/can_user_push is not built! Did you _REALLY_ read INSTALL?" >&2
42 echo "ERROR: perhaps you forgot to run make?" >&2
45 if [ ! -x src
/can_user_push_http
]; then
46 echo "ERROR: src/can_user_push_http is not built! Did you _REALLY_ read INSTALL?" >&2
47 echo "ERROR: perhaps you forgot to run make?" >&2
50 if [ ! -x src
/getent
]; then
51 echo "ERROR: src/getent is not built! Did you _REALLY_ read INSTALL?" >&2
52 echo "ERROR: perhaps you forgot to run make?" >&2
57 echo "*** Checking for ezcert..."
58 if [ ! -f ezcert.git
/CACreateCert
]; then
59 echo "ERROR: ezcert.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
64 echo "*** Checking for git..."
65 if [ ! -x "$cfg_git_bin" ]; then
66 echo "ERROR: $cfg_git_bin does not exist or is not executable" >&2
69 if ! git_version
="$("$cfg_git_bin" --version)"; then
70 echo "ERROR: $cfg_git_bin --version failed" >&2
73 case "$git_version" in
76 echo "ERROR: '$cfg_git_bin --version' output does not start with 'git version '" >&2
81 echo "*** Setting up basedir..."
82 "$MAKE" --quiet apache.conf
83 "$MAKE" --quiet -C src
85 mkdir
-p "$cfg_basedir"
86 cp -pR Girocco jobd taskd gitweb html
jobs toolbox hooks apache.conf shlib.sh bin screen
"$cfg_basedir"
87 cp -p src
/can_user_push src
/can_user_push_http ezcert.git
/CACreateCert
"$cfg_basedir/bin"
88 [ -n "$cfg_httpspushurl" ] ||
rm -f "$cfg_basedir"/html
/rootcert.html
"$cfg_basedir"/html
/httpspush.html
89 [ -n "$cfg_mob" ] ||
rm -f "$cfg_basedir"/html
/mob.html
91 # Put the correct Config in place
92 [ "$GIROCCO_CONF" = "Girocco::Config" ] ||
cp "$(echo "$GIROCCO_CONF" | sed 's#::#/#g; s/$/.pm/')" "$cfg_basedir/Girocco/Config.pm"
95 echo "*** Preprocessing scripts..."
96 perl
-I.
-M$GIROCCO_CONF -i -p \
97 -e 's/(?<!")\@basedir\@/"$Girocco::Config::basedir"/g;' -e 's/(?<=")\@basedir\@/$Girocco::Config::basedir/g;' \
98 -e 's/\@reporoot\@/"$Girocco::Config::reporoot"/g;' -e 's/\@jailreporoot\@/"$Girocco::Config::jailreporoot"/g;' \
99 -e 's/\@webadmurl\@/"$Girocco::Config::webadmurl"/g;' -e 's/\@screen_acl_file\@/"$Girocco::Config::screen_acl_file"/g;' \
100 -e 's/\@mob\@/"$Girocco::Config::mob"/g;' "$cfg_basedir"/jobs
/*.sh
"$cfg_basedir"/jobd
/*.sh \
101 "$cfg_basedir"/taskd
/*.sh
"$cfg_basedir"/gitweb
/*.sh
"$cfg_basedir"/shlib.sh
"$cfg_basedir"/hooks
/* \
102 "$cfg_basedir"/toolbox
/* "$cfg_basedir"/bin
/git-
* "$cfg_basedir"/bin
/create-
* "$cfg_basedir"/bin
/update-
* \
103 "$cfg_basedir"/screen
/*
105 # Dump all the cfg_ and defined_ variables to shlib_vars.sh
106 get_girocco_config_var_list
> "$cfg_basedir"/shlib_vars.sh
108 if [ -n "$cfg_mirror" ]; then
109 echo "--- Remember to start $cfg_basedir/taskd/taskd.pl"
111 echo "--- Also remember to either start $cfg_basedir/jobd/jobd.sh, or add this"
112 echo "--- to the crontab of $cfg_mirror_user (adjust frequency on number of repos):"
113 echo "*/30 * * * * /usr/bin/nice -n 18 $cfg_basedir/jobd/jobd.sh -q --all-once"
116 echo "*** Setting up repository root..."
117 mkdir
-p "$cfg_reporoot" "$cfg_reporoot-recyclebin"
118 if [ "$cfg_owning_group" ]; then
119 chgrp
"$cfg_owning_group" "$cfg_reporoot" ||
echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot"
120 chgrp
"$cfg_owning_group" "$cfg_reporoot-recyclebin" ||
echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot-recyclebin"
122 chmod 02775 "$cfg_reporoot" ||
echo "WARNING: Cannot chmod $cfg_reporoot properly"
123 chmod 02775 "$cfg_reporoot-recyclebin" ||
echo "WARNING: Cannot chmod $cfg_reporoot-recyclebin properly"
126 if [ -n "$cfg_chrooted" ]; then
127 echo "*** Setting up chroot jail for pushing..."
128 if [ "$(id -u)" -eq 0 ]; then
131 echo "WARNING: Skipping jail setup, not root"
136 echo "*** Setting up jail configuration (project database)..."
137 [ "$(id -u)" -eq 0 ] || .
/jailsetup.sh dbonly
138 mkdir
-p "$cfg_chroot" "$cfg_chroot/etc"
139 touch "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group"
140 chown
"$cfg_mirror_user""$owngroup" "$cfg_chroot/etc" ||
141 echo "WARNING: Cannot chown $cfg_mirror_user$owngroup $cfg_chroot/etc"
142 chown
"$cfg_cgi_user""$owngroup" "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" ||
143 echo "WARNING: Cannot chown $cfg_cgi_user$owngroup the files"
144 chmod g
+w
"$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" ||
145 echo "WARNING: Cannot chmod g+w the etc/passwd and/or etc/group files"
146 chmod 02775 "$cfg_chroot/etc" ||
echo "WARNING: Cannot chmod 02775 $cfg_chroot/etc"
149 echo "*** Setting up gitweb from git.git..."
150 if [ ! -f git.git
/Makefile
]; then
151 echo "ERROR: git.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
154 mkdir
-p "$cfg_webroot" "$cfg_cgiroot"
155 (cd git.git
&& "$MAKE" --quiet gitweb
&& cp gitweb
/gitweb.cgi
"$cfg_cgiroot" \
156 && cp gitweb
/static
/*.png gitweb
/static
/*.css gitweb
/static
/*.js
"$cfg_webroot")
159 echo "*** Setting up git-browser from git-browser.git..."
160 if [ ! -f git-browser.git
/git-browser.cgi
]; then
161 echo "ERROR: git-browser.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
164 mkdir
-p "$cfg_webroot"/git-browser
"$cfg_cgiroot"
165 (cd git-browser.git
&& cp git-browser.cgi
"$cfg_cgiroot" \
166 && cp -r *.html
*.js
*.css js.lib JSON
"$cfg_webroot"/git-browser
)
167 ln -sf "$cfg_webroot/git-browser/JSON" "$cfg_cgiroot"
168 cat >"$cfg_cgiroot"/git-browser.conf
<<EOT
170 warehouse: $cfg_reporoot
172 cat >"$cfg_webroot"/git-browser
/GitConfig.js
<<EOT
173 cfg_gitweb_url="$cfg_gitweburl/"
174 cfg_browsercgi_url="$cfg_webadmurl/git-browser.cgi"
178 echo "*** Setting up darcs-fast-export from bzr-fastimport.git..."
179 if [ ! -d bzr-fastimport.git
/exporters
/darcs
/ ]; then
180 echo "ERROR: bzr-fastimport.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
183 mkdir
-p "$cfg_basedir"/bin
184 cp bzr-fastimport.git
/exporters
/darcs
/darcs-fast-export
"$cfg_basedir"/bin
187 echo "*** Setting up hg-fast-export from fast-export.git..."
188 if [ ! -f fast-export.git
/hg-fast-export.py
-o ! -f fast-export.git
/hg2git.py
]; then
189 echo "ERROR: fast-export.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
192 mkdir
-p "$cfg_basedir"/bin
193 cp fast-export.git
/hg-fast-export.py fast-export.git
/hg2git.py
"$cfg_basedir"/bin
196 echo "*** Setting up our part of the website..."
197 mkdir
-p "$cfg_webroot" "$cfg_cgiroot"
198 cp cgi
/*.cgi gitweb
/gitweb_config.perl
"$cfg_cgiroot"
199 [ -n "$cfg_httpspushurl" ] ||
rm -f "$cfg_cgiroot/usercert.cgi"
200 ln -fs "$cfg_basedir"/Girocco
"$cfg_cgiroot"
201 [ -z "$cfg_webreporoot" ] ||
{ rm -f "$cfg_webreporoot" && ln -s "$cfg_reporoot" "$cfg_webreporoot"; }
202 if [ -z "$cfg_httpspushurl" ]; then
203 grep -v 'rootcert[.]html' gitweb
/indextext.html
> "$cfg_webroot/indextext.html"
205 cp gitweb
/indextext.html
"$cfg_webroot"
207 mv "$cfg_basedir"/html
/*.css
"$cfg_basedir"/html
/*.js
"$cfg_webroot"
208 cp mootools.js
"$cfg_webroot"
209 cp htaccess
"$cfg_webroot/.htaccess"
210 cp git-favicon.ico
"$cfg_webroot/favicon.ico"
211 cp robots.txt
"$cfg_webroot"
212 cat gitweb
/gitweb.css
>>"$cfg_webroot"/gitweb.css
215 if [ -n "$cfg_httpspushurl" ]; then
216 echo "*** Setting up SSL certificates..."
218 if [ "$cfg_rsakeylength" -gt "$bits" ] 2>/dev
/null
; then
219 bits
="$cfg_rsakeylength"
221 mkdir
-p "$cfg_certsdir"
222 [ -d "$cfg_certsdir" ]
224 if [ -e "$cfg_certsdir/girocco_www_crt.pem" ]; then
226 openssl x509 -in "$cfg_certsdir/girocco_www_crt.pem
" -noout -subject | \
231 [ -e "$cfg_certsdir/girocco_client_crt.pem" -a \
232 -e "$cfg_certsdir/girocco_client_key.pem" -a \
233 -e "$cfg_certsdir/girocco_www_key.pem" -a \
234 -e "$cfg_certsdir/girocco_www_crt.pem" -a "$wwwcertcn" = "/CN=$cfg_httpsdnsname" -a \
235 -e "$cfg_certsdir/girocco_root_crt.pem" ] || needroot
=1
236 if [ -n "$needroot" -a ! -e "$cfg_certsdir/girocco_root_key.pem" ]; then
237 rm -f "$cfg_certsdir/girocco_root_crt.pem" "$cfg_certsdir/girocco_root_key.pem"
238 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_root_key.pem" $bits
239 chmod 0600 "$cfg_certsdir/girocco_root_key.pem"
240 rm -f "$cfg_certsdir/girocco_root_crt.pem"
241 echo "Created new root key"
243 if [ ! -e "$cfg_certsdir/girocco_root_crt.pem" ]; then
244 ezcert.git
/CACreateCert
--root --key "$cfg_certsdir/girocco_root_key.pem" \
245 --out "$cfg_certsdir/girocco_root_crt.pem" "girocco $cfg_nickname root certificate"
246 rm -f "$cfg_certsdir/girocco_www_crt.pem" "$cfg_certsdir/girocco_www_chain.pem"
247 rm -f "$cfg_certsdir/girocco_client_crt.pem" "$cfg_certsdir/girocco_client_suffix.pem"
248 rm -f "$cfg_certsdir/girocco_mob_user_crt.pem"
249 rm -f "$cfg_chroot/etc/sshcerts"/*.pem
250 echo "Created new root certificate"
252 if [ ! -e "$cfg_certsdir/girocco_www_key.pem" ]; then
253 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_www_key.pem" $bits
254 chmod 0600 "$cfg_certsdir/girocco_www_key.pem"
255 rm -f "$cfg_certsdir/girocco_www_crt.pem"
256 echo "Created new www key"
258 if [ ! -e "$cfg_certsdir/girocco_www_crt.pem" -o "$wwwcertcn" != "/CN=$cfg_httpsdnsname" ]; then
259 openssl rsa
-in "$cfg_certsdir/girocco_www_key.pem" -pubout |
260 ezcert.git
/CACreateCert
--server --key "$cfg_certsdir/girocco_root_key.pem" \
261 --cert "$cfg_certsdir/girocco_root_crt.pem" \
262 --out "$cfg_certsdir/girocco_www_crt.pem" "$cfg_httpsdnsname"
263 echo "Created www certificate"
265 if [ ! -e "$cfg_certsdir/girocco_www_chain.pem" ]; then
266 cat "$cfg_certsdir/girocco_root_crt.pem" > "$cfg_certsdir/girocco_www_chain.pem"
267 echo "Created www certificate chain file"
269 if [ ! -e "$cfg_certsdir/girocco_client_key.pem" ]; then
270 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_client_key.pem" $bits
271 chmod 0640 "$cfg_certsdir/girocco_client_key.pem"
272 rm -f "$cfg_certsdir/girocco_client_crt.pem"
273 echo "Created new client key"
275 if [ ! -e "$cfg_certsdir/girocco_client_crt.pem" ]; then
276 openssl rsa
-in "$cfg_certsdir/girocco_client_key.pem" -pubout |
277 ezcert.git
/CACreateCert
--subca --key "$cfg_certsdir/girocco_root_key.pem" \
278 --cert "$cfg_certsdir/girocco_root_crt.pem" \
279 --out "$cfg_certsdir/girocco_client_crt.pem" "girocco $cfg_nickname client authority"
280 rm -f "$cfg_certsdir/girocco_client_suffix.pem"
281 rm -f "$cfg_certsdir/girocco_mob_user_crt.pem"
282 rm -f "$cfg_chroot/etc/sshcerts"/*.pem
283 echo "Created client certificate"
285 if [ ! -e "$cfg_certsdir/girocco_client_suffix.pem" ]; then
286 cat "$cfg_certsdir/girocco_client_crt.pem" > "$cfg_certsdir/girocco_client_suffix.pem"
287 echo "Created client certificate suffix file"
289 cat "$cfg_rootcert" > "$cfg_webroot/${cfg_nickname}_root_cert.pem"
290 if [ -n "$cfg_mob" ]; then
291 if [ ! -e "$cfg_certsdir/girocco_mob_user_key.pem" ]; then
292 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_mob_user_key.pem" $bits
293 chmod 0640 "$cfg_certsdir/girocco_client_key.pem"
294 rm -f "$cfg_certsdir/girocco_mob_user_crt.pem"
295 echo "Created new mob user key"
297 if [ ! -e "$cfg_certsdir/girocco_mob_user_crt.pem" ]; then
298 openssl rsa
-in "$cfg_mobuserkey" -pubout |
299 ezcert.git
/CACreateCert
--client --key "$cfg_clientkey" \
300 --cert "$cfg_clientcert" \
301 --out "$cfg_certsdir/girocco_mob_user_crt.pem" 'mob'
302 echo "Created mob user client certificate"
304 cat "$cfg_mobuserkey" > "$cfg_webroot/${cfg_nickname}_mob_key.pem"
305 cat "$cfg_mobusercert" "$cfg_clientcertsuffix" > "$cfg_webroot/${cfg_nickname}_mob_user.pem"
307 rm -f "$cfg_webroot/${cfg_nickname}_mob_key.pem" "$cfg_webroot/${cfg_nickname}_mob_user.pem"
310 rm -f "$cfg_webroot/${cfg_nickname}_root_cert.pem"
311 rm -f "$cfg_webroot/${cfg_nickname}_mob_key.pem" "$cfg_webroot/${cfg_nickname}_mob_user.pem"
315 echo "*** Finalizing permissions..."
316 chown
-R -h "$cfg_mirror_user""$owngroup" "$cfg_basedir" "$cfg_webroot" "$cfg_cgiroot"
317 [ -z "$cfg_httpspushurl" ] || chown
-R -h "$cfg_mirror_user""$owngroup" "$cfg_certsdir"