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
/getent
]; then
46 echo "ERROR: src/getent is not built! Did you _REALLY_ read INSTALL?" >&2
47 echo "ERROR: perhaps you forgot to run make?" >&2
52 echo "*** Checking for ezcert..."
53 if [ ! -f ezcert.git
/CACreateCert
]; then
54 echo "ERROR: ezcert.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
59 echo "*** Checking for git..."
60 if [ ! -x "$cfg_git_bin" ]; then
61 echo "ERROR: $cfg_git_bin does not exist or is not executable" >&2
64 if ! git_version
="$("$cfg_git_bin" --version)"; then
65 echo "ERROR: $cfg_git_bin --version failed" >&2
68 case "$git_version" in
71 echo "ERROR: '$cfg_git_bin --version' output does not start with 'git version '" >&2
76 echo "*** Setting up basedir..."
77 "$MAKE" --quiet apache.conf
78 "$MAKE" --quiet -C src
80 mkdir
-p "$cfg_basedir"
81 cp -pR Girocco jobd taskd gitweb html
jobs toolbox hooks apache.conf shlib.sh bin screen
"$cfg_basedir"
82 cp -p src
/can_user_push ezcert.git
/CACreateCert
"$cfg_basedir/bin"
83 [ -n "$cfg_httpspushurl" ] ||
rm -f "$cfg_basedir"/html
/rootcert.html
"$cfg_basedir"/html
/httpspush.html
84 [ -n "$cfg_mob" ] ||
rm -f "$cfg_basedir"/html
/mob.html
86 # Put the correct Config in place
87 [ "$GIROCCO_CONF" = "Girocco::Config" ] ||
cp "$(echo "$GIROCCO_CONF" | sed 's#::#/#g; s/$/.pm/')" "$cfg_basedir/Girocco/Config.pm"
90 echo "*** Preprocessing scripts..."
91 perl
-I.
-M$GIROCCO_CONF -i -p \
92 -e 's/(?<!")\@basedir\@/"$Girocco::Config::basedir"/g;' -e 's/(?<=")\@basedir\@/$Girocco::Config::basedir/g;' \
93 -e 's/\@reporoot\@/"$Girocco::Config::reporoot"/g;' -e 's/\@jailreporoot\@/"$Girocco::Config::jailreporoot"/g;' \
94 -e 's/\@webadmurl\@/"$Girocco::Config::webadmurl"/g;' -e 's/\@screen_acl_file\@/"$Girocco::Config::screen_acl_file"/g;' \
95 -e 's/\@mob\@/"$Girocco::Config::mob"/g;' "$cfg_basedir"/jobs
/*.sh
"$cfg_basedir"/jobd
/*.sh \
96 "$cfg_basedir"/taskd
/*.sh
"$cfg_basedir"/gitweb
/*.sh
"$cfg_basedir"/shlib.sh
"$cfg_basedir"/hooks
/* \
97 "$cfg_basedir"/toolbox
/* "$cfg_basedir"/bin
/git-
* "$cfg_basedir"/bin
/create-
* "$cfg_basedir"/bin
/update-
* \
98 "$cfg_basedir"/screen
/*
100 # Dump all the cfg_ and defined_ variables to shlib_vars.sh
101 get_girocco_config_var_list
> "$cfg_basedir"/shlib_vars.sh
103 if [ -n "$cfg_mirror" ]; then
104 echo "--- Remember to start $cfg_basedir/taskd/taskd.pl"
106 echo "--- Also remember to either start $cfg_basedir/jobd/jobd.sh, or add this"
107 echo "--- to the crontab of $cfg_mirror_user (adjust frequency on number of repos):"
108 echo "*/30 * * * * /usr/bin/nice -n 18 $cfg_basedir/jobd/jobd.sh -q --all-once"
111 echo "*** Setting up repository root..."
112 mkdir
-p "$cfg_reporoot" "$cfg_reporoot-recyclebin"
113 if [ "$cfg_owning_group" ]; then
114 chgrp
"$cfg_owning_group" "$cfg_reporoot" ||
echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot"
115 chgrp
"$cfg_owning_group" "$cfg_reporoot-recyclebin" ||
echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot-recyclebin"
117 chmod 02775 "$cfg_reporoot" ||
echo "WARNING: Cannot chmod $cfg_reporoot properly"
118 chmod 02775 "$cfg_reporoot-recyclebin" ||
echo "WARNING: Cannot chmod $cfg_reporoot-recyclebin properly"
121 if [ -n "$cfg_chrooted" ]; then
122 echo "*** Setting up chroot jail for pushing..."
123 if [ "$(id -u)" -eq 0 ]; then
126 echo "WARNING: Skipping jail setup, not root"
131 echo "*** Setting up jail configuration (project database)..."
132 [ "$(id -u)" -eq 0 ] || .
/jailsetup.sh dbonly
133 mkdir
-p "$cfg_chroot" "$cfg_chroot/etc"
134 touch "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group"
135 chown
"$cfg_mirror_user""$owngroup" "$cfg_chroot/etc" ||
136 echo "WARNING: Cannot chown $cfg_mirror_user$owngroup $cfg_chroot/etc"
137 chown
"$cfg_cgi_user""$owngroup" "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" ||
138 echo "WARNING: Cannot chown $cfg_cgi_user$owngroup the files"
139 chmod g
+w
"$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" ||
140 echo "WARNING: Cannot chmod g+w the etc/passwd and/or etc/group files"
141 chmod 02775 "$cfg_chroot/etc" ||
echo "WARNING: Cannot chmod 02775 $cfg_chroot/etc"
144 echo "*** Setting up gitweb from git.git..."
145 if [ ! -f git.git
/Makefile
]; then
146 echo "ERROR: git.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
149 mkdir
-p "$cfg_webroot" "$cfg_cgiroot"
150 (cd git.git
&& "$MAKE" --quiet gitweb
&& cp gitweb
/gitweb.cgi
"$cfg_cgiroot" \
151 && cp gitweb
/static
/*.png gitweb
/static
/*.css gitweb
/static
/*.js
"$cfg_webroot")
154 echo "*** Setting up git-browser from git-browser.git..."
155 if [ ! -f git-browser.git
/git-browser.cgi
]; then
156 echo "ERROR: git-browser.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
159 mkdir
-p "$cfg_webroot"/git-browser
"$cfg_cgiroot"
160 (cd git-browser.git
&& cp git-browser.cgi
"$cfg_cgiroot" \
161 && cp -r *.html
*.js
*.css js.lib JSON
"$cfg_webroot"/git-browser
)
162 ln -sf "$cfg_webroot/git-browser/JSON" "$cfg_cgiroot"
163 cat >"$cfg_cgiroot"/git-browser.conf
<<EOT
165 warehouse: $cfg_reporoot
167 cat >"$cfg_webroot"/git-browser
/GitConfig.js
<<EOT
168 cfg_gitweb_url="$cfg_gitweburl/"
169 cfg_browsercgi_url="$cfg_webadmurl/git-browser.cgi"
173 echo "*** Setting up darcs-fast-export from bzr-fastimport.git..."
174 if [ ! -d bzr-fastimport.git
/exporters
/darcs
/ ]; then
175 echo "ERROR: bzr-fastimport.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
178 mkdir
-p "$cfg_basedir"/bin
179 cp bzr-fastimport.git
/exporters
/darcs
/darcs-fast-export
"$cfg_basedir"/bin
182 echo "*** Setting up hg-fast-export from fast-export.git..."
183 if [ ! -f fast-export.git
/hg-fast-export.py
-o ! -f fast-export.git
/hg2git.py
]; then
184 echo "ERROR: fast-export.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
187 mkdir
-p "$cfg_basedir"/bin
188 cp fast-export.git
/hg-fast-export.py fast-export.git
/hg2git.py
"$cfg_basedir"/bin
191 echo "*** Setting up our part of the website..."
192 mkdir
-p "$cfg_webroot" "$cfg_cgiroot"
193 cp cgi
/*.cgi gitweb
/gitweb_config.perl
"$cfg_cgiroot"
194 [ -n "$cfg_httpspushurl" ] ||
rm -f "$cfg_cgiroot/usercert.cgi"
195 ln -fs "$cfg_basedir"/Girocco
"$cfg_cgiroot"
196 [ -z "$cfg_webreporoot" ] ||
{ rm -f "$cfg_webreporoot" && ln -s "$cfg_reporoot" "$cfg_webreporoot"; }
197 if [ -z "$cfg_httpspushurl" ]; then
198 grep -v 'rootcert[.]html' gitweb
/indextext.html
> "$cfg_webroot/indextext.html"
200 cp gitweb
/indextext.html
"$cfg_webroot"
202 mv "$cfg_basedir"/html
/*.css
"$cfg_basedir"/html
/*.js
"$cfg_webroot"
203 cp mootools.js
"$cfg_webroot"
204 cp htaccess
"$cfg_webroot/.htaccess"
205 cp git-favicon.ico
"$cfg_webroot/favicon.ico"
206 cp robots.txt
"$cfg_webroot"
207 cat gitweb
/gitweb.css
>>"$cfg_webroot"/gitweb.css
210 if [ -n "$cfg_httpspushurl" ]; then
211 echo "*** Setting up SSL certificates..."
213 if [ "$cfg_rsakeylength" -gt "$bits" ] 2>/dev
/null
; then
214 bits
="$cfg_rsakeylength"
216 mkdir
-p "$cfg_certsdir"
217 [ -d "$cfg_certsdir" ]
219 if [ -e "$cfg_certsdir/girocco_www_crt.pem" ]; then
221 openssl x509 -in "$cfg_certsdir/girocco_www_crt.pem
" -noout -subject | \
226 [ -e "$cfg_certsdir/girocco_client_crt.pem" -a \
227 -e "$cfg_certsdir/girocco_client_key.pem" -a \
228 -e "$cfg_certsdir/girocco_www_key.pem" -a \
229 -e "$cfg_certsdir/girocco_www_crt.pem" -a "$wwwcertcn" = "/CN=$cfg_httpsdnsname" -a \
230 -e "$cfg_certsdir/girocco_root_crt.pem" ] || needroot
=1
231 if [ -n "$needroot" -a ! -e "$cfg_certsdir/girocco_root_key.pem" ]; then
232 rm -f "$cfg_certsdir/girocco_root_crt.pem" "$cfg_certsdir/girocco_root_key.pem"
233 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_root_key.pem" $bits
234 chmod 0600 "$cfg_certsdir/girocco_root_key.pem"
235 rm -f "$cfg_certsdir/girocco_root_crt.pem"
236 echo "Created new root key"
238 if [ ! -e "$cfg_certsdir/girocco_root_crt.pem" ]; then
239 ezcert.git
/CACreateCert
--root --key "$cfg_certsdir/girocco_root_key.pem" \
240 --out "$cfg_certsdir/girocco_root_crt.pem" "girocco $cfg_nickname root certificate"
241 rm -f "$cfg_certsdir/girocco_www_crt.pem" "$cfg_certsdir/girocco_www_chain.pem"
242 rm -f "$cfg_certsdir/girocco_client_crt.pem" "$cfg_certsdir/girocco_client_suffix.pem"
243 rm -f "$cfg_certsdir/girocco_mob_user_crt.pem"
244 rm -f "$cfg_chroot/etc/sshcerts"/*.pem
245 echo "Created new root certificate"
247 if [ ! -e "$cfg_certsdir/girocco_www_key.pem" ]; then
248 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_www_key.pem" $bits
249 chmod 0600 "$cfg_certsdir/girocco_www_key.pem"
250 rm -f "$cfg_certsdir/girocco_www_crt.pem"
251 echo "Created new www key"
253 if [ ! -e "$cfg_certsdir/girocco_www_crt.pem" -o "$wwwcertcn" != "/CN=$cfg_httpsdnsname" ]; then
254 openssl rsa
-in "$cfg_certsdir/girocco_www_key.pem" -pubout |
255 ezcert.git
/CACreateCert
--server --key "$cfg_certsdir/girocco_root_key.pem" \
256 --cert "$cfg_certsdir/girocco_root_crt.pem" \
257 --out "$cfg_certsdir/girocco_www_crt.pem" "$cfg_httpsdnsname"
258 echo "Created www certificate"
260 if [ ! -e "$cfg_certsdir/girocco_www_chain.pem" ]; then
261 cat "$cfg_certsdir/girocco_root_crt.pem" > "$cfg_certsdir/girocco_www_chain.pem"
262 echo "Created www certificate chain file"
264 if [ ! -e "$cfg_certsdir/girocco_client_key.pem" ]; then
265 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_client_key.pem" $bits
266 chmod 0640 "$cfg_certsdir/girocco_client_key.pem"
267 rm -f "$cfg_certsdir/girocco_client_crt.pem"
268 echo "Created new client key"
270 if [ ! -e "$cfg_certsdir/girocco_client_crt.pem" ]; then
271 openssl rsa
-in "$cfg_certsdir/girocco_client_key.pem" -pubout |
272 ezcert.git
/CACreateCert
--subca --key "$cfg_certsdir/girocco_root_key.pem" \
273 --cert "$cfg_certsdir/girocco_root_crt.pem" \
274 --out "$cfg_certsdir/girocco_client_crt.pem" "girocco $cfg_nickname client authority"
275 rm -f "$cfg_certsdir/girocco_client_suffix.pem"
276 rm -f "$cfg_certsdir/girocco_mob_user_crt.pem"
277 rm -f "$cfg_chroot/etc/sshcerts"/*.pem
278 echo "Created client certificate"
280 if [ ! -e "$cfg_certsdir/girocco_client_suffix.pem" ]; then
281 cat "$cfg_certsdir/girocco_client_crt.pem" > "$cfg_certsdir/girocco_client_suffix.pem"
282 echo "Created client certificate suffix file"
284 cat "$cfg_rootcert" > "$cfg_webroot/${cfg_nickname}_root_cert.pem"
285 if [ -n "$cfg_mob" ]; then
286 if [ ! -e "$cfg_certsdir/girocco_mob_user_key.pem" ]; then
287 openssl genrsa
-f4 -out "$cfg_certsdir/girocco_mob_user_key.pem" $bits
288 chmod 0640 "$cfg_certsdir/girocco_client_key.pem"
289 rm -f "$cfg_certsdir/girocco_mob_user_crt.pem"
290 echo "Created new mob user key"
292 if [ ! -e "$cfg_certsdir/girocco_mob_user_crt.pem" ]; then
293 openssl rsa
-in "$cfg_mobuserkey" -pubout |
294 ezcert.git
/CACreateCert
--client --key "$cfg_clientkey" \
295 --cert "$cfg_clientcert" \
296 --out "$cfg_certsdir/girocco_mob_user_crt.pem" 'mob'
297 echo "Created mob user client certificate"
299 cat "$cfg_mobuserkey" > "$cfg_webroot/${cfg_nickname}_mob_key.pem"
300 cat "$cfg_mobusercert" "$cfg_clientcertsuffix" > "$cfg_webroot/${cfg_nickname}_mob_user.pem"
302 rm -f "$cfg_webroot/${cfg_nickname}_mob_key.pem" "$cfg_webroot/${cfg_nickname}_mob_user.pem"
305 rm -f "$cfg_webroot/${cfg_nickname}_root_cert.pem"
306 rm -f "$cfg_webroot/${cfg_nickname}_mob_key.pem" "$cfg_webroot/${cfg_nickname}_mob_user.pem"
310 echo "*** Finalizing permissions..."
311 chown
-R -h "$cfg_mirror_user""$owngroup" "$cfg_basedir" "$cfg_webroot" "$cfg_cgiroot"
312 [ -z "$cfg_httpspushurl" ] || chown
-R -h "$cfg_mirror_user""$owngroup" "$cfg_certsdir"