# # # patch "Makefile" # from [d3cb2a0616784e004734d1d6d752de658b84e8b1] # to [5bacfbec95253efd5cb7fc5dfda52cf15a6efde6] # # patch "README" # from [6e0effd2fb2288a12a55acf8a413b9997add514b] # to [ae9a3c17baebaaa0b13ba1cf3e6f6581fc78fbf9] # # patch "hostconfig.dist" # from [1cdd0ee060395726477325a2a0bd32e0ec97725b] # to [be6b29f695f2970cac77f6bf76fb59219c699261] # # patch "install" # from [d9830ebcbb0a200ca8ce9e09d77913d7a9889ffb] # to [fee7005a1b9713e3912bea180c0d16a045492500] # ============================================================ --- Makefile d3cb2a0616784e004734d1d6d752de658b84e8b1 +++ Makefile 5bacfbec95253efd5cb7fc5dfda52cf15a6efde6 @@ -7,3 +7,5 @@ install: ./install +forced-install: + ./install --force-conffiles ============================================================ --- README 6e0effd2fb2288a12a55acf8a413b9997add514b +++ README ae9a3c17baebaaa0b13ba1cf3e6f6581fc78fbf9 @@ -5,15 +5,9 @@ make usher.webhost -./install +make install -createdb -psql -f schema.sql - setup database, if not done as the webserver user, that user will need - permission to read/insert/update/delete. - If you want the reset script to work, you need permission to delete. - About ----- ============================================================ --- hostconfig.dist 1cdd0ee060395726477325a2a0bd32e0ec97725b +++ hostconfig.dist be6b29f695f2970cac77f6bf76fb59219c699261 @@ -1,5 +1,5 @@ userpass "username" "password" -dbstring "dbname=webhost-db" +dbstring "dbname=DBNAME" admin "127.0.0.5:12345" hostkey "address@hidden" ============================================================ --- install d9830ebcbb0a200ca8ce9e09d77913d7a9889ffb +++ install fee7005a1b9713e3912bea180c0d16a045492500 @@ -5,6 +5,7 @@ USHERUSER=www-data USHERGROUP=www-data NAME=webhost +DBNAME=webhost-db CONFDIR=/etc/$NAME PROJDIR=/var/lib/$NAME/projects GRAPHDIR=/var/cache/$NAME/graphs @@ -14,6 +15,57 @@ HOSTNAME=$(hostname) +prompt_about_file_update() { + FILE="$1" + + while /bin/true; do + echo "$FILE is updated" + echo "Right now, the update is in $FILE.new" + echo "What do you want to do?" + echo " I or Y - Install the new version" + echo " N - Leave the old version alone" + echo " D - See the difference" + echo " Z - Escape to $SHELL" + read ANSWER + ANSWER=`echo $ANSWER | tr a-z A-Z` + case $ANSWER in + I*|Y*) + /bin/true + return + ;; + N*) + /bin/false + return + ;; + D*) + diff -u $FILE $FILE.new + ;; + Z*) + echo "Get back here by simply exiting the shell" + $SHELL + ;; + esac + done +} +install_file() { + FILE="$1" + CHECK="$2" + + if $CHECK && [ -f $FILE ] && cmp $FILE $FILE.new; then + if prompt_about_file_update "$FILE"; then + mv $FILE $FILE.old + mv $FILE.new $FILE + echo "Replaced the old $FILE" + echo "The old file is backed up as $FILE.old" + else + echo "There is an update for $FILE in $FILE.new" + fi + else + mv $FILE.new $FILE + echo "Installed $FILE" + fi +} + do_install() { umask 002 mkdir -p $PROJDIR/ @@ -21,11 +73,20 @@ mkdir -p $WWWDIR/ # sort -r is a trick to hopefully get the longest paths first - find $WWWDIR -type d | grep -v "$WWWDIR/projects" | sort -r | \ - while read D; do rm -f $D/*; rmdir $D 2>/dev/null; done - (cd www; tar -cf - .) | (cd $WWWDIR; tar -xvf -) + find $WWWDIR -type d | grep -v "^$WWWDIR/projects" | sort -r | \ + while read D; do + rm -f $D/* $D/.* 2>/dev/null + rmdir $D 2>/dev/null + echo "Removed $D and its contents" + done + # The main directory migh just have gotten destroyed, let's recreate it + mkdir -p $WWWDIR/ + (cd www; tar -cf - .) | (cd $WWWDIR; tar -xf -) + echo "Copied www/... to $WWWDIR/..." + rm -f $WWWDIR/MochiKit ln -s viewmtn/MochiKit/ $WWWDIR/MochiKit + rm -f $WWWDIR/viewmtn/graph ln -s $GRAPHDIR/ $WWWDIR/viewmtn/graph # the webserver needs to be able to link to certain files chown $WEBUSER $WWWDIR/project.php @@ -44,47 +105,60 @@ else mkdir $CONFDIR/ dd if=/dev/random of=$CONFDIR/secfile bs=1 count=64 - chgrp $WEBGROUP $CONFDIR/secfile + chown $WEBUSER $CONFDIR/secfile chmod 0400 $CONFDIR/secfile fi - if [ -f $CONFDIR/hostconfig ]; then - mv -v $CONFDIR/hostconfig $CONFDIR/hostconfig.old - echo "Your previous hostconfig file has been moved to hostconfig.old" - fi sed -e "s!DBROTATE!$BINDIR/update-viewmtn-db.sh!" \ - < skel/monotonerc > $CONFDIR/monotonerc + < skel/monotonerc > $CONFDIR/monotonerc.new + install_file $CONFDIR/monotonerc /bin/false sed -e "s!HOSTNAME!$HOSTNAME!" \ + -e "s!DBNAME!$DBNAME!" \ -e "s!MONOTONE!$MONOTONE!" \ -e "s!BASE_URL!http://$HOSTNAME/$NAME/!" \ -e "s!PROJECT_DIR!$PROJDIR!" \ -e "s!GRAPH_DIR!$GRAPHDIR!" \ -e "s!WWW_DIR!$WWWDIR!" \ - < hostconfig.dist > $CONFDIR/hostconfig - + < hostconfig.dist > $CONFDIR/hostconfig.new + install_file $CONFDIR/hostconfig /bin/true + sed -e "s!BINDIR!$BINDIR!" \ -e "s!CONFDIR!$CONFDIR!" \ -e "s!USHERUSER!$USHERUSER!" \ - < webhost.initscript > /etc/init.d/$NAME + < webhost.initscript > /etc/init.d/$NAME.new + install_file /etc/init.d/$NAME /bin/false sed -e "s!GRAPH_DIR!$GRAPHDIR!" \ - -e "s!CONFDIR!$CONFDIR'!" \ - < webhost.cronjob > /etc/cron.daily/$NAME + -e "s!CONFDIR!$CONFDIR!" \ + < webhost.cronjob > /etc/cron.daily/$NAME.new + install_file /etc/cron.daily/$NAME /bin/false + sed -e "s!NAME!$NAME!" \ + -e "s!WWW_DIR!$WWWDIR!" \ + < webhost.conf > /etc/apache2/conf.d/$NAME.new + install_file /etc/apache2/conf.d/$NAME /bin/true + cp -r skel/keys $CONFDIR/ fi sed -e "s!'CONFDIR'!'$CONFDIR'!" \ < $WWWDIR/common.php > $WWWDIR/common.php.new - mv $WWWDIR/common.php.new + install_file $WWWDIR/common.php /bin/false if [ -f $WWWDIR/viewmtn/config.py.example ]; then sed -e "s!'CONFDIR'!'$CONFDIR'!" \ < $WWWDIR/viewmtn/config.py.example \ - > $WWWDIR/viewmtn/config.py - rm $WWWDIR/viewmtn/config.py.example + > $WWWDIR/viewmtn/config.py.new + install_file $WWWDIR/viewmtn/config.py /bin/false fi + + if psql -c "\d" $DBNAME 2>/dev/null >/dev/null; then + : + else + createdb -O $WEBUSER $DBNAME + psql -f schema.sql $DBNAME + fi } do_install "$1"