source: package_branches/invirt-web/cherrypy/files/etc/init.d/apache2.invirt @ 2652

Last change on this file since 2652 was 1855, checked in by price, 16 years ago

invirt-web: make initscript stop command not leave apache2 processes lying around

This makes restart/force-reload work correctly.

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/pagsh -e
2### BEGIN INIT INFO
3# Provides:          apache2
4# Required-Start:    $local_fs $remote_fs $network $syslog openafs-client
5# Required-Stop:     $local_fs $remote_fs $network $syslog openafs-client
6# Default-Start:     2 3 4 5
7# Default-Stop:      0 1 6
8# Short-Description: Start/stop apache2 web server
9### END INIT INFO
10#
11# Apache kstart wrapper by anders.
12#
13
14SCRIPT=/etc/init.d/apache2.invirt-orig
15KSTART_PIDFILE=/var/run/k5start-apache2.pid
16KSTART_KEYTAB=/etc/invirt/keytab
17
18export AFSCELL=sipb.mit.edu
19
20kstart_start () {
21    TMP_PIDFILE=$(mktemp /tmp/k5start-apache2.pid-XXXXXX)
22    chown www-data "$TMP_PIDFILE"
23    export KRB5CCNAME=$(mktemp /tmp/krb5cc_33.kstart-XXXXXX)
24    chown www-data $KRB5CCNAME
25    /sbin/start-stop-daemon --start --pidfile "$TMP_PIDFILE" -c www-data \
26        --exec /usr/bin/k5start -- -b -p "$TMP_PIDFILE" \
27        -f "$KSTART_KEYTAB" -K10 -S afs -I "$AFSCELL" -t \
28        "daemon/$(hostname -f)"
29    cat "$TMP_PIDFILE" >|"$KSTART_PIDFILE"
30    rm -f "$TMP_PIDFILE"
31}
32kstart_stop () {
33    if [ -e $KSTART_PIDFILE ]; then
34        /sbin/start-stop-daemon --stop --pidfile $KSTART_PIDFILE
35        pgrep apache2 >/dev/null && sleep 1 \
36         && pgrep apache2 >/dev/null && sleep 1 \
37         && pgrep apache2 >/dev/null && sleep 1 \
38         && pgrep apache2 >/dev/null && sleep 1 \
39         && pkill -9 apache2
40        rm -f $KSTART_PIDFILE
41    else
42        echo -n " ... no kstart pidfile"
43    fi
44}
45
46case "$1" in
47  start)
48    echo -n "Starting kstart for Apache2: k5start"
49    kstart_start
50    echo "."
51    exec "$SCRIPT" start
52    ;;
53  stop)
54    "$SCRIPT" stop
55    echo -n "Stopping kstart for Apache2: k5start"
56    kstart_stop
57    echo "."
58    ;;
59  restart|force-reload)
60    "$0" stop
61    sleep 1
62    "$0" start
63    ;;
64  *)
65    exec "$SCRIPT" "$@"
66    ;;
67esac
Note: See TracBrowser for help on using the repository browser.