#!/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