reguire gnupg1 on f>=31; sense the system to use gpg1 when installed
[nodemanager.git] / sliver-initscripts / vinit
1 #!/bin/bash
2 #
3 # vinit - trigger the slice-local initscript as installed in /etc/rc.d/vinit.slice
4 #
5 # this is unconditionnally installed and activated in the sliver
6 # but of course nothing is run if the script is not present 
7 #
8 # note - for practical reasons this is *not* activated through chkconfig
9 # as the slice has not yet started at that point
10 #
11 # historical note
12 # historically planetlab initscripts were not required to handle the 'stop' and 'restart' method
13 # as of March 2011 this becomes a requirement though
14
15 # Source function library.
16 . /etc/init.d/functions
17
18 # chkconfig: - 99 1
19
20 slicescript=/etc/rc.d/init.d/vinit.slice
21 basename=$(basename $slicescript)
22 slicename=$(cat /etc/slicename)
23
24 prog="Slice initscript ${basename}@${slicename}"
25 lockfile=/var/lock/subsys/vinit
26
27 RETVAL=0
28
29 # bash's &>> feature is broken in f8
30 function start() {
31     [ -x $slicescript ] || return 0
32     echo $"Starting $prog" 
33     $slicescript start $slicename >> /var/log/vinit 2>&1 &
34     touch ${lockfile}
35     return 0
36 }
37
38 function stop() {
39     [ -x $slicescript ] && $slicescript stop $slicename >> /var/log/vinit 2>&1 &
40     # safe side
41     sleep 5
42     echo $"Stopping $prog "
43     killproc $basename
44     rm -f ${lockfile}
45 }
46
47 function restart () {
48     [ -x $slicescript ] || return 0
49     echo $"Restarting $prog"
50     $slicescript restart $slicename >> /var/log/vinit 2>&1 &
51     return 0
52 }
53
54 function status () {
55     if [ -f ${lockfile} ] ; then
56         echo "$prog seems to have run"
57         return 0
58     else
59         echo "$prog apparently hasn't run"
60         return 1
61     fi
62
63
64 case "$1" in
65     start)
66         start
67         RETVAL=$?
68         ;;
69     stop)
70         stop
71         RETVAL=$?
72         ;;
73     restart)
74         restart
75         RETVAL=$?
76         ;;
77     status)
78         status 
79         RETVAL=$?
80         ;;
81     *)
82         echo $"Usage: $0 {start|stop|restart|status}"
83         exit 1
84         ;;
85 esac
86
87 exit $RETVAL