Don't over-escape Javascript in the web templates.
[invirt/packages/invirt-web.git] / files / etc / init.d / apache2.invirt
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
14 SCRIPT=/etc/init.d/apache2.invirt-orig
15 KSTART_PIDFILE=/var/run/k5start-apache2.pid
16 KSTART_KEYTAB=/etc/invirt/keytab
17
18 export AFSCELL=sipb.mit.edu
19
20 kstart_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 }
32 kstart_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
46 case "$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     ;;
67 esac