summaryrefslogtreecommitdiff
path: root/web-server/wwwcvs-orig-files/modules/wwwgnu-nongnu/files/update-symlinks.sh
diff options
context:
space:
mode:
Diffstat (limited to 'web-server/wwwcvs-orig-files/modules/wwwgnu-nongnu/files/update-symlinks.sh')
-rwxr-xr-xweb-server/wwwcvs-orig-files/modules/wwwgnu-nongnu/files/update-symlinks.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/web-server/wwwcvs-orig-files/modules/wwwgnu-nongnu/files/update-symlinks.sh b/web-server/wwwcvs-orig-files/modules/wwwgnu-nongnu/files/update-symlinks.sh
new file mode 100755
index 0000000..c733e12
--- /dev/null
+++ b/web-server/wwwcvs-orig-files/modules/wwwgnu-nongnu/files/update-symlinks.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+if [ -e /var/tmp/update-symlinks.pid ]; then
+ # See if the process is still running
+ pid=`cat /var/tmp/update-symlinks.pid`
+ if [ -e /proc/$pid ]; then
+ # send a warning mail and abort
+ mail -s "[wildebeest] update-symlinks warning: pid $pid still active" sysadmin@gnu.org < /dev/null > /dev/null
+ exit -1
+ else
+ # Stale file, overwrite it, onwards and upwards
+ echo $$ > /var/tmp/update-symlinks.pid
+ fi
+else
+ # Output our PID to the pid file
+ echo $$ > /var/tmp/update-symlinks.pid
+fi
+
+exec >> /var/log/wwwcvs/update-symlinks.log 2>&1
+
+echo "Regenerating symlinks..."
+
+WARNING="# GENERATED BY /home/wwwcvs/update-symlinks.sh DO NOT EDIT"
+TMPFILE=`/bin/mktemp /tmp/hourly-website-update.XXXXXX || exit -1`
+/usr/bin/find /var/www -type f -name '.symlinks' >> $TMPFILE
+
+/home/wwwcvs/update-gnu-rewritemaps /var/www /home/wwwcvs/symlinks > /dev/null
+
+printf "${WARNING}\n\n" > /home/wwwcvs/symlinks-nongnu-vhost.conf
+cat $TMPFILE | xargs /home/wwwcvs/update-symlinks-xargs.py nongnu-vhost >> /home/wwwcvs/symlinks-nongnu-vhost.conf
+
+printf "${WARNING}\n\n" > /home/wwwcvs/symlinks-nongnu.conf
+cat $TMPFILE | xargs /home/wwwcvs/update-symlinks-xargs.py nongnu >> /home/wwwcvs/symlinks-nongnu.conf
+
+CHANGED=0
+
+dir1=/etc/apache2/symlinks
+dir2=/home/wwwcvs/symlinks
+
+# these need the -I to ignore comments.
+for file in dir-map.txt html-map.txt nonhtml-map.txt; do
+ diff -I "^#" -q {$dir1,$dir2}/$file
+ if [[ "$?" != "0" ]]; then
+ cp -f {$dir2,$dir1}/$file
+ CHANGED=1
+ fi
+done
+
+# nongnu files lack the comments and are in the top-level dir.
+dir2=/home/wwwcvs
+for file in symlinks-nongnu.conf symlinks-nongnu-vhost.conf; do
+ diff -q {$dir1,$dir2}/$file
+ if [[ "$?" != "0" ]]; then
+ cp -f {$dir2,$dir1}/$file
+ CHANGED=1
+ fi
+done
+
+rm -f $TMPFILE
+echo "Regeneration complete."
+
+if [ "$CHANGED" == "1" ]; then
+ echo "Restarting apache...."
+ sudo /usr/sbin/apache2ctl graceful && echo "Restart successful."
+else
+ echo "No changes, no apache restart necessary"
+fi
+
+# Remove our lock/pid file
+
+rm -f /var/tmp/update-symlinks.pid && echo "update-symlinks finished `date`" && exit 0
+