]> matita.cs.unibo.it Git - helm.git/blob - helm/scripts/init.d/uwobo_forever.sh
a7985c464b27500ea54d0fd6a581663d2e83d509
[helm.git] / helm / scripts / init.d / uwobo_forever.sh
1 #!/bin/sh
2
3 # THIS SCRIPT IS DEPRECATED, USE daemon_respawner.sh INSTEAD
4 exit 0
5
6 #
7 # respawner for UWOBO (http://helm.cs.unibo.it/software/uwobo)
8 #
9 # by --Zack <zack@cs.unibo.it>
10 #
11 # Created: Mon,  7 Apr 2003 18:59:56 +0200 zacchiro
12 # Last-Modified: Tue,  8 Apr 2003 10:06:41 +0200 zacchiro
13 #
14
15 # Warning: $PIDFILE value is shared by UWOBO /etc/init.d script, change at your
16 # own risk
17 PIDFILE="/var/run/uwobo.opt_mowgli.pid"
18
19 MAILTO="root@mowgli.cs.unibo.it"
20 INTERVAL="60"
21
22 # Usage: alert <subject> <body>
23 alert ()
24 {
25   echo "$2" | mail -s "$1" $MAILTO
26 }
27
28 # check if uwobo is still alive
29 uwobo_is_alive ()
30 {
31    if [ -r "$PIDFILE" ]; then
32      ps `cat $PIDFILE` &> /dev/null
33    else # no pid file found, uwobo has been shutdown nicely
34      exit 0
35    fi
36 }
37
38 # start uwobo
39 start_uwobo ()
40 {
41    /etc/init.d/helm-uwobo_mowgli start &
42 }
43
44 # first check
45 if ! uwobo_is_alive; then
46    alert "UWOBO failed to start :-((" "UWOBO died during initialization :-((, enjoy debugging! :-P. Cheers."
47    exit 0
48 fi
49
50 # continuous checks
51 while true; do
52    sleep $INTERVAL
53    if ! uwobo_is_alive; then
54       alert "UWOBO died :-(, restarting it ..." "UWOBO died miserably :-(. I'm going to try restarting it, you will receive an additional mail in case of failure. Cheers."
55       start_uwobo # performed in background
56       exit 0
57    fi
58 done
59