chiark / gitweb /
dgit now uses just curl, not wget
[dsa-metapackages.git] / apache2-vhost-update
index a61369edeecf9c9b2622dabc94b3435efdd0c526..2c283a39f7ae7c021c27c62ee7369a9dd45fe88b 100755 (executable)
 # All config changes are tracked in RCS.
 #
 # needs something like this in sudoers:
-# %apachectrl  ALL=(root)      /usr/sbin/restart-apache
+# %apachectrl  ALL=(root)      /usr/sbin/apache2-vhost-update
 
 
-# Copyright (c) 2009 Peter Palfrader <peter@palfrader.org>
+# Copyright (c) 2009,2010 Peter Palfrader <peter@palfrader.org>
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
@@ -42,7 +42,7 @@
 
 
 
-STATINGDIR="/etc/apache2/sites-staging"
+STAGINGDIR="/etc/apache2/sites-staging"
 DESTINATION="/etc/apache2/sites-available"
 
 usage() {
@@ -91,8 +91,12 @@ if echo "$site" | grep /; then
        exit 1
 fi
 
-if ! [ -f "$STATINGDIR/$site" ]; then
-       echo "$STATINGDIR/$site does not exist or is not a file" >&2
+if [ -f "$STAGINGDIR/$site.conf" -a ! -f "$STAGINGDIR/$site" ] ; then
+       site="$site.conf"
+fi
+
+if ! [ -f "$STAGINGDIR/$site" ]; then
+       echo "$STAGINGDIR/$site does not exist or is not a file" >&2
        exit 1
 fi
 
@@ -102,7 +106,7 @@ if [ "$?" != "0" ]; then
        exit 1
 fi
 
-if diff "$STATINGDIR/$site" "$DESTINATION/$site" > /dev/null; then
+if diff "$STAGINGDIR/$site" "$DESTINATION/$site" > /dev/null; then
        echo "No differences, not doing anything." >&2
        exit 1
 fi
@@ -113,7 +117,7 @@ if [ "$?" != "0" ]; then
        exit 1
 fi
 
-cp -f "$STATINGDIR/$site" "$DESTINATION/$site"
+cp -f "$STAGINGDIR/$site" "$DESTINATION/$site"
 
 if grep -i include "$DESTINATION/$site" > /dev/null; then
        echo "New site may have include statements - rejecting." >&2
@@ -122,6 +126,20 @@ if grep -i include "$DESTINATION/$site" > /dev/null; then
        exit 1
 fi
 
+if grep -i LoadModule "$DESTINATION/$site" > /dev/null; then
+       echo "New site may have LoadModule statements - rejecting." >&2
+       rm -f "$DESTINATION/$site"
+       co "$DESTINATION/$site"
+       exit 1
+fi
+
+if grep -i LoadFile "$DESTINATION/$site" > /dev/null; then
+       echo "New site may have LoadFile statements - rejecting." >&2
+       rm -f "$DESTINATION/$site"
+       co "$DESTINATION/$site"
+       exit 1
+fi
+
 /usr/sbin/apache2ctl configtest
 if [ "$?" != "0" ]; then
        echo "configtest returned errors; reverting." >&2
@@ -130,6 +148,9 @@ if [ "$?" != "0" ]; then
        exit 1
 fi
 
+echo "Differences:"
+rcsdiff -u "$DESTINATION/$site"
+
 echo "update run by $USER($SUDO_USER) at `date -R -u` on `hostname -f`" | \
        ci -u "$DESTINATION/$site"
 if [ "$?" != "0" ]; then