chiark / gitweb /
add apache-restart script
[dsa-metapackages.git] / restart-apache
diff --git a/restart-apache b/restart-apache
new file mode 100644 (file)
index 0000000..6b7c405
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# needs:
+# %apachectrl  ALL=(root)      /usr/sbin/restart-apache
+
+case $1 in 
+       restart)
+               action="restart"
+       ;;
+       reload)
+               action="reload"
+       ;;
+       *)
+               echo "Usage: $0 [restart|reload]"
+       ;;
+esac
+
+if [ -x /usr/sbin/apache2ctl ]; then
+
+       /usr/sbin/apache2ctl configtest
+
+       if [ "$?" != "0" ]; then
+               env -i /etc/init.d/apache2 $action
+       else
+               echo "configtest returned errors, thus not restarting apache"
+               exit 1
+       fi
+else
+       echo "Ehhh, there is no Apache2 on this machine"
+       exit 2
+fi
+