install.sh: Set up chroot/etc less vigorously
[girocco/test-forks.git] / install.sh
blob90d824ea6eefbd6f702e615364ab8e03fdd92eaa
1 #!/bin/sh
2 # The Girocco installation script
3 # We will OVERWRITE basedir!
5 set -e
7 # What Config should we use?
8 [ -n "$GIROCCO_CONF" ] || GIROCCO_CONF=Girocco::Config
9 echo "*** Initializing using $GIROCCO_CONF..."
11 # First run Girocco::Config consistency checks
12 perl -I. -M$GIROCCO_CONF -e ''
14 . jobs/shlib.sh
17 echo "*** Setting up basedir..."
18 rm -r "$cfg_basedir"
19 mkdir -p "$cfg_basedir"
20 cp -a Girocco gitweb html jobs toolbox apache.conf update-hook "$cfg_basedir"
22 # Put the correct Config in place
23 [ "$GIROCCO_CONF" = "Girocco::Config" ] || cp "$(echo "$GIROCCO_CONF" | sed 's#::#/#g; s/$/.pm/')" "$cfg_basedir/Girocco/Config.pm"
26 if [ -n "$cfg_mirror" ]; then
27 echo "*** Setting up mirror queue..."
28 mkdir -p "$cfg_mqueuedir/to-clone" "$cfg_mqueuedir/cloning"
29 chown "$cgi_mirror_user"."$cfg_owning_group" "$cfg_mqueuedir/to-clone" "$cfg_mqueuedir/cloning" ||
30 echo "WARNING: Cannot chown $cgi_mirror_user.$cfg_owning_group the mirroring directories"
31 chmod 02775 "$cfg_mqueuedir/to-clone" "$cfg_mqueuedir/cloning" ||
32 echo "WARNING: Cannot chmod 02775 the mirroring directories"
34 if [ ! -x "$($cfg_git_bin --exec-path)/git-mirror" ]; then
35 echo "ERROR: Your $cfg_git_bin does not know about git-mirror; git.git submodule has it but you need to install it manually"
37 echo "!!! Do not forget to set up the clone and update cronjobs for $cfg_mirror_user"
38 elif [ "$cfg_permission_control" = "Group" ]; then
39 echo "!!! Do not forget to set up the fixup cronjob for root"
43 echo "*** Setting up repository root..."
44 mkdir -p "$cfg_reporoot"
45 chown ."$cfg_owning_group" "$cfg_reporoot" || echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot"
46 chmod a+rwx,g+s,o+t "$cfg_reporoot" || echo "WARNING: Cannot chmod $cfg_reporoot properly"
49 if [ -n "$cfg_chrooted" ]; then
50 echo "*** Setting up chroot jail for pushing..."
51 echo "ERROR: I don't know how to set up a chroot yet!" >&2
55 echo "*** Setting up jail configuration (project database)..."
56 mkdir -p "$cfg_chroot" "$cfg_chroot/etc"
57 chown "$cgi_user"."$cfg_owning_group" "$cfg_chroot/etc" ||
58 echo "WARNING: Cannot chown $cgi_user.$cfg_owning_group the files"
59 chmod 02775 "$cfg_chroot/etc" || echo "WARNING: Cannot chmod 02775 $cfg_chroot/etc"
62 echo "*** Setting up gitweb from git.git..."
63 if [ ! -f git.git/Makefile ]; then
64 echo "ERROR: git.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
65 exit 1;
67 mkdir -p "$cfg_webroot" "$cfg_cgiroot"
68 (cd git.git && make gitweb/gitweb.cgi && cp gitweb/gitweb.cgi "$cfg_cgiroot" \
69 && cp gitweb/*.png gitweb/*.css gitweb/*.js "$cfg_webroot")
72 echo "*** Setting up git-browser from git-browser.git..."
73 if [ ! -f git-browser.git/git-browser.cgi ]; then
74 echo "ERROR: git-browser.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
75 exit 1;
77 mkdir -p "$cfg_webroot"/git-browser "$cfg_cgiroot"
78 (cd git-browser.git && cp git-browser.cgi "$cfg_cgiroot" \
79 && cp -r *.html *.js *.css js.lib/ JSON/ "$cfg_webroot"/git-browser)
80 ln -sf "$cfg_webroot/git-browser/JSON" "$cfg_cgiroot"
81 cat >"$cfg_cgiroot"/git-browser.conf <<EOT
82 gitbin: $cfg_git_bin
83 warehouse: $cfg_reporoot
84 EOT
85 cat >"$cfg_webroot"/git-browser/GitConfig.js <<EOT
86 cfg_gitweb_url="$cfg_gitweburl/"
87 cfg_browsercgi_url="$cfg_webadmurl/git-browser.cgi"
88 EOT
91 echo "*** Setting up our part of the website..."
92 mkdir -p "$cfg_webroot" "$cfg_cgiroot"
93 cp cgi/*.cgi gitweb/gitweb_config.perl "$cfg_cgiroot"
94 ln -fs "$cfg_basedir"/Girocco "$cfg_cgiroot"
95 cp gitweb/indextext.html "$cfg_webroot"