forgot to add
[nodemanager.git] / sliver-initscripts / vinit
1 #!/bin/bash
2 #
3 # $Id$
4 # $URL$
5 #
6 # vinit - trigger the slice-local initscript as installed in /etc/rc.d/vinit.slice
7 #
8 # this is unconditionnally installed and activated in the sliver
9 # but of course nothing is run if the script is not present 
10 #
11 # note - for practical reasons this is *not* activated through chkconfig
12 # as the slice has not yet started at that point
13 #
14 # historical note
15 # historically planetlab initscripts have not been required to handle the 'stop' method
16 # so installing such a script directly as /etc/rc.d/vinit would result in the
17 # script .. being run a second time at vserver-stop time
18
19
20 # Source function library.
21 . /etc/init.d/functions
22
23 slicescript=/etc/rc.d/init.d/vinit.slice
24 basename=$(basename $slicescript)
25 slicename=$(cat /etc/slicename)
26
27 prog="Slice initscript ${basename}@${slicename}"
28 lockfile=/var/lock/subsys/vinit
29
30 RETVAL=0
31
32 # xxx todo - redirect all stdout, stderr to /var/log/vinit for user access
33
34 function start() {
35     if [ ! -x $slicescript ] ; then
36         echo "vinit@$slicename: no executable $slicescript - ignored"
37         return 0
38     fi
39     echo $"Starting $prog" 
40     $slicescript start $slicename >& /var/log/vinit &
41     touch ${lockfile}
42     return 0
43 }
44
45 # the initial model came without a stop function; legacy ...
46 function stop() {
47     echo $"Stopping $prog "
48     killproc $basename
49     rm -f ${lockfile}
50 }
51
52 function status () {
53     if [ -f ${lockfile} ] ; then
54         echo "$prog seems to have run"
55         return 0
56     else
57         echo "$prog apparently hasn't run"
58         return 1
59     fi
60
61
62 case "$1" in
63     start)
64         start
65         RETVAL=$?
66         ;;
67     stop)
68         stop
69         RETVAL=$?
70         ;;
71     status)
72         status 
73         RETVAL=$?
74         ;;
75     *)
76         echo $"Usage: $0 {start|stop|status}"
77         exit 1
78         ;;
79 esac
80
81 exit $RETVAL