install.sh: Make sure etc/passwd, etc/group exist
[girocco/mytab.git] / install.sh
bloba6a46e8ddde5e04ff76d12c604c5022d63d3164e
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 . shlib.sh
17 echo "*** Setting up basedir..."
18 rm -fr "$cfg_basedir"
19 mkdir -p "$cfg_basedir"
20 cp -a Girocco gitweb html jobs mirroring toolbox apache.conf shlib.sh 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 echo "*** Preprocessing scripts..."
27 perl -I. -M$GIROCCO_CONF -i -pe 's/\@basedir\@/"$Girocco::Config::basedir"/g' "$cfg_basedir"/jobs/*.sh "$cfg_basedir"/mirroring/*.sh "$cfg_basedir"/shlib.sh "$cfg_basedir"/update-hook
30 if [ -n "$cfg_mirror" ]; then
31 if [ ! -x "$($cfg_git_bin --exec-path)/git-mirror" ]; then
32 echo "ERROR: Your $cfg_git_bin does not know about git-mirror; git.git submodule has it but you need to install it manually"
34 echo "--- Recommended crontab for $cfg_mirror_user:"
35 echo "*/10 * * * * /usr/bin/nice -n 18 $cfg_basedir/jobs/updatecheck.sh # adjust frequency based on number of repos"
36 echo "--- Remember to start $cfg_basedir/mirroring/cloned.pl"
38 if [ -n "$cfg_push" -a "$cfg_permission_control" = "Group" ]; then
39 echo "--- Recommended crontab for root:"
40 echo "*/2 * * * * /usr/bin/nice -n 18 /root/fixupcheck.sh # adjust frequency based on number of repos"
44 echo "*** Setting up repository root..."
45 mkdir -p "$cfg_reporoot"
46 chown ."$cfg_owning_group" "$cfg_reporoot" || echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot"
47 chmod a+rwx,g+s,o+t "$cfg_reporoot" || echo "WARNING: Cannot chmod $cfg_reporoot properly"
50 if [ -n "$cfg_chrooted" ]; then
51 echo "*** Setting up chroot jail for pushing..."
52 echo "ERROR: I don't know how to set up a chroot yet!" >&2
56 echo "*** Setting up jail configuration (project database)..."
57 mkdir -p "$cfg_chroot" "$cfg_chroot/etc"
58 touch "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group"
59 chown "$cgi_user"."$cfg_owning_group" "$cfg_chroot/etc" ||
60 echo "WARNING: Cannot chown $cgi_user.$cfg_owning_group the files"
61 chmod 02775 "$cfg_chroot/etc" || echo "WARNING: Cannot chmod 02775 $cfg_chroot/etc"
64 echo "*** Setting up gitweb from git.git..."
65 if [ ! -f git.git/Makefile ]; then
66 echo "ERROR: git.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
67 exit 1;
69 mkdir -p "$cfg_webroot" "$cfg_cgiroot"
70 (cd git.git && make --quiet gitweb/gitweb.cgi && cp gitweb/gitweb.cgi "$cfg_cgiroot" \
71 && cp gitweb/*.png gitweb/*.css gitweb/*.js "$cfg_webroot")
74 echo "*** Setting up git-browser from git-browser.git..."
75 if [ ! -f git-browser.git/git-browser.cgi ]; then
76 echo "ERROR: git-browser.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
77 exit 1;
79 mkdir -p "$cfg_webroot"/git-browser "$cfg_cgiroot"
80 (cd git-browser.git && cp git-browser.cgi "$cfg_cgiroot" \
81 && cp -r *.html *.js *.css js.lib/ JSON/ "$cfg_webroot"/git-browser)
82 ln -sf "$cfg_webroot/git-browser/JSON" "$cfg_cgiroot"
83 cat >"$cfg_cgiroot"/git-browser.conf <<EOT
84 gitbin: $cfg_git_bin
85 warehouse: $cfg_reporoot
86 EOT
87 cat >"$cfg_webroot"/git-browser/GitConfig.js <<EOT
88 cfg_gitweb_url="$cfg_gitweburl/"
89 cfg_browsercgi_url="$cfg_webadmurl/git-browser.cgi"
90 EOT
93 echo "*** Setting up our part of the website..."
94 mkdir -p "$cfg_webroot" "$cfg_cgiroot"
95 cp cgi/*.cgi gitweb/gitweb_config.perl "$cfg_cgiroot"
96 ln -fs "$cfg_basedir"/Girocco "$cfg_cgiroot"
97 [ -z "$cfg_webreporoot" ] || { rm -f "$cfg_webreporoot" && ln -s "$cfg_reporoot" "$cfg_webreporoot"; }
98 cp gitweb/indextext.html "$cfg_webroot"
99 mv "$cfg_basedir"/html/*.css "$cfg_basedir"/html/*.js "$cfg_webroot"
100 cp mootools.js "$cfg_webroot"
101 cat gitweb/gitweb.css >>"$cfg_webroot"/gitweb.css