Util.pm: fix undefined problems with scrypt
[girocco.git] / install.sh
blob7036c4f0bcf6ed6c88d24137909a3913e4bc62bc
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
16 owngroup=""
17 [ -z "$cfg_owning_group" ] || owngroup=":$cfg_owning_group"
20 echo "*** Setting up basedir..."
21 rm -fr "$cfg_basedir"
22 mkdir -p "$cfg_basedir"
23 cp -pR Girocco jobd taskd fixupd gitweb html jobs toolbox hooks apache.conf shlib.sh screen "$cfg_basedir"
25 # Put the correct Config in place
26 [ "$GIROCCO_CONF" = "Girocco::Config" ] || cp "$(echo "$GIROCCO_CONF" | sed 's#::#/#g; s/$/.pm/')" "$cfg_basedir/Girocco/Config.pm"
29 echo "*** Preprocessing scripts..."
30 perl -I. -M$GIROCCO_CONF -i -p \
31 -e 's/(?<!")\@basedir\@/"$Girocco::Config::basedir"/g;' -e 's/(?<=")\@basedir\@/$Girocco::Config::basedir/g;' \
32 -e 's/\@reporoot\@/"$Girocco::Config::reporoot"/g;' \
33 -e 's/\@webadmurl\@/"$Girocco::Config::webadmurl"/g;' -e 's/\@screen_acl_file\@/"$Girocco::Config::screen_acl_file"/g;' \
34 "$cfg_basedir"/jobs/*.sh "$cfg_basedir"/jobd/*.sh \
35 "$cfg_basedir"/taskd/*.sh "$cfg_basedir"/gitweb/*.sh "$cfg_basedir"/shlib.sh "$cfg_basedir"/hooks/* \
36 "$cfg_basedir"/toolbox/* "$cfg_basedir"/screen/*
39 if [ -n "$cfg_mirror" ]; then
40 echo "--- Remember to start $cfg_basedir/taskd/taskd.pl"
42 if [ -n "$cfg_push" -a "$cfg_permission_control" = "Group" ]; then
43 echo "Creating FIFO for fixupd: $cfg_fixup_queue"
44 [ -p "$cfg_fixup_queue" ] || mkfifo "$cfg_fixup_queue"
45 chown "$cfg_cgi_user""$owngroup" "$cfg_fixup_queue" ||
46 echo "WARNING: Cannot chown $cfg_cgi_user$owngroup $cfg_fixup_queue"
47 chmod ug+rw "$cfg_fixup_queue" ||
48 echo "WARNING: Cannot chmod $cfg_fixup_queue"
49 echo "--- Remember to copy $cfg_basedir/fixupd/ to /root and start fixupd.sh as root"
51 echo "--- Also remember to either start $cfg_basedir/jobd/jobd.sh, or add this"
52 echo "--- to the crontab of $cfg_mirror_user (adjust frequency on number of repos):"
53 echo "*/30 * * * * /usr/bin/nice -n 18 $cfg_basedir/jobd/jobd.sh -q --all-once"
56 echo "*** Setting up repository root..."
57 mkdir -p "$cfg_reporoot" "$cfg_reporoot-recyclebin"
58 if [ "$cfg_owning_group" ]; then
59 chown :"$cfg_owning_group" "$cfg_reporoot" || echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot"
60 chown :"$cfg_owning_group" "$cfg_reporoot-recyclebin" || echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot-recyclebin"
62 chmod 02775 "$cfg_reporoot" || echo "WARNING: Cannot chmod $cfg_reporoot properly"
63 chmod 02775 "$cfg_reporoot-recyclebin" || echo "WARNING: Cannot chmod $cfg_reporoot-recyclebin properly"
66 if [ -n "$cfg_chrooted" ]; then
67 echo "*** Setting up chroot jail for pushing..."
68 if [ "$(id -u)" -eq 0 ]; then
69 ./jailsetup.sh
70 else
71 echo "WARNING: Skipping jail setup, not root"
76 echo "*** Setting up jail configuration (project database)..."
77 mkdir -p "$cfg_chroot" "$cfg_chroot/etc"
78 touch "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group"
79 chown "$cfg_mirror_user""$owngroup" "$cfg_chroot/etc" ||
80 echo "WARNING: Cannot chown $cfg_mirror_user$owngroup $cfg_chroot/etc"
81 chown "$cfg_cgi_user""$owngroup" "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" ||
82 echo "WARNING: Cannot chown $cfg_cgi_user$owngroup the files"
83 chmod g+w "$cfg_chroot/etc/passwd" "$cfg_chroot/etc/group" ||
84 echo "WARNING: Cannot chmod g+w the files"
85 chmod 02775 "$cfg_chroot/etc" || echo "WARNING: Cannot chmod 02775 $cfg_chroot/etc"
88 echo "*** Setting up gitweb from git.git..."
89 if [ ! -f git.git/Makefile ]; then
90 echo "ERROR: git.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
91 exit 1;
93 mkdir -p "$cfg_webroot" "$cfg_cgiroot"
94 (cd git.git && make --quiet gitweb/gitweb.cgi && cp gitweb/gitweb.cgi "$cfg_cgiroot" \
95 && cp gitweb/*.png gitweb/*.css gitweb/*.js "$cfg_webroot")
98 echo "*** Setting up git-browser from git-browser.git..."
99 if [ ! -f git-browser.git/git-browser.cgi ]; then
100 echo "ERROR: git-browser.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
101 exit 1;
103 mkdir -p "$cfg_webroot"/git-browser "$cfg_cgiroot"
104 (cd git-browser.git && cp git-browser.cgi "$cfg_cgiroot" \
105 && cp -r *.html *.js *.css js.lib/ JSON/ "$cfg_webroot"/git-browser)
106 ln -sf "$cfg_webroot/git-browser/JSON" "$cfg_cgiroot"
107 cat >"$cfg_cgiroot"/git-browser.conf <<EOT
108 gitbin: $cfg_git_bin
109 warehouse: $cfg_reporoot
111 cat >"$cfg_webroot"/git-browser/GitConfig.js <<EOT
112 cfg_gitweb_url="$cfg_gitweburl/"
113 cfg_browsercgi_url="$cfg_webadmurl/git-browser.cgi"
117 echo "*** Setting up darcs-fast-export from bzr-fastimport.git..."
118 if [ ! -d bzr-fastimport.git/exporters/darcs/ ]; then
119 echo "ERROR: bzr-fastimport.git is not checked out! Did you _REALLY_ read INSTALL?" >&2
120 exit 1;
122 mkdir -p "$cfg_basedir"/bin
123 cp bzr-fastimport.git/exporters/darcs/darcs-fast-export "$cfg_basedir"/bin
126 echo "*** Setting up our part of the website..."
127 mkdir -p "$cfg_webroot" "$cfg_cgiroot"
128 cp cgi/*.cgi gitweb/gitweb_config.perl "$cfg_cgiroot"
129 ln -fs "$cfg_basedir"/Girocco "$cfg_cgiroot"
130 [ -z "$cfg_webreporoot" ] || { rm -f "$cfg_webreporoot" && ln -s "$cfg_reporoot" "$cfg_webreporoot"; }
131 cp gitweb/indextext.html "$cfg_webroot"
132 mv "$cfg_basedir"/html/*.css "$cfg_basedir"/html/*.js "$cfg_webroot"
133 cp mootools.js "$cfg_webroot"
134 cp htaccess "$cfg_webroot/.htaccess"
135 cp git-favicon.ico "$cfg_webroot/favicon.ico"
136 cp robots.txt "$cfg_webroot"
137 cat gitweb/gitweb.css >>"$cfg_webroot"/gitweb.css
139 echo "*** Finalizing permissions..."
140 chown -R -h "$cfg_mirror_user""$owngroup" "$cfg_basedir" "$cfg_webroot" "$cfg_cgiroot"