chiark / gitweb /
add apache-restart script
[dsa-metapackages.git] / restart-apache
1 #!/bin/bash
2
3 # needs:
4 # %apachectrl   ALL=(root)      /usr/sbin/restart-apache
5
6 case $1 in 
7         restart)
8                 action="restart"
9         ;;
10         reload)
11                 action="reload"
12         ;;
13         *)
14                 echo "Usage: $0 [restart|reload]"
15         ;;
16 esac
17
18 if [ -x /usr/sbin/apache2ctl ]; then
19
20         /usr/sbin/apache2ctl configtest
21
22         if [ "$?" != "0" ]; then
23                 env -i /etc/init.d/apache2 $action
24         else
25                 echo "configtest returned errors, thus not restarting apache"
26                 exit 1
27         fi
28 else
29         echo "Ehhh, there is no Apache2 on this machine"
30         exit 2
31 fi
32