* further integration of invirt.config
[invirt/packages/invirt-web.git] / files / etc / init.d / apache2.invirt
1 #!/usr/bin/pagsh -e
2 #
3 # Apache kstart wrapper by anders.
4 #
5
6 SCRIPT=/etc/init.d/apache2.invirt-orig
7 KSTART_PIDFILE=/var/run/k5start-apache2.pid
8 KSTART_KEYTAB=/etc/apache2/keytab
9
10 export AFSCELL=sipb.mit.edu
11
12 kstart_start () {
13     TMP_PIDFILE=$(mktemp /tmp/k5start-apache2.pid-XXXXXX)
14     chown www-data "$TMP_PIDFILE"
15     export KRB5CCNAME=$(mktemp /tmp/krb5cc_33.kstart-XXXXXX)
16     chown www-data $KRB5CCNAME
17     /sbin/start-stop-daemon --start --pidfile "$TMP_PIDFILE" -c www-data \
18         --exec /usr/bin/k5start -- -b -p "$TMP_PIDFILE" \
19         -U -f "$KSTART_KEYTAB" -K10 -S afs -I "$AFSCELL" -t -b
20     cat "$TMP_PIDFILE" >|"$KSTART_PIDFILE"
21     rm -f "$TMP_PIDFILE"
22 }
23 kstart_stop () {
24     if [ -e $KSTART_PIDFILE ]; then
25         /sbin/start-stop-daemon --stop --pidfile $KSTART_PIDFILE
26         rm -f $KSTART_PIDFILE
27     else
28         echo -n " ... no kstart pidfile"
29     fi
30 }
31
32 case "$1" in
33   start)
34     echo -n "Starting kstart for Apache2: k5start"
35     kstart_start
36     echo "."
37     exec "$SCRIPT" start
38     ;;
39   stop)
40     "$SCRIPT" stop
41     echo -n "Stopping kstart for Apache2: k5start"
42     kstart_stop
43     echo "."
44     ;;
45   restart|force-reload)
46     "$0" stop
47     sleep 1
48     "$0" start
49     ;;
50   *)
51     exec "$SCRIPT" "$@"
52     ;;
53 esac