X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sliver-initscripts%2Fvinit;h=38ff6af50a5b62498b12d814dbd46786a8b73b7b;hb=e57432c1dfdfeaa52cc32799e2abbc34b7704ce9;hp=4a3e9c7080bcb113c19fb802d428085e701c9a63;hpb=cecd6091b3b6516d7d6b90f303dce5619d14236e;p=nodemanager.git diff --git a/sliver-initscripts/vinit b/sliver-initscripts/vinit index 4a3e9c7..38ff6af 100755 --- a/sliver-initscripts/vinit +++ b/sliver-initscripts/vinit @@ -1,8 +1,5 @@ #!/bin/bash # -# $Id$ -# $URL$ -# # vinit - trigger the slice-local initscript as installed in /etc/rc.d/vinit.slice # # this is unconditionnally installed and activated in the sliver @@ -12,14 +9,14 @@ # as the slice has not yet started at that point # # historical note -# historically planetlab initscripts have not been required to handle the 'stop' method -# so installing such a script directly as /etc/rc.d/vinit would result in the -# script .. being run a second time at vserver-stop time - +# historically planetlab initscripts were not required to handle the 'stop' and 'restart' method +# as of March 2011 this becomes a requirement though # Source function library. . /etc/init.d/functions +# chkconfig: - 99 1 + slicescript=/etc/rc.d/init.d/vinit.slice basename=$(basename $slicescript) slicename=$(cat /etc/slicename) @@ -29,24 +26,31 @@ lockfile=/var/lock/subsys/vinit RETVAL=0 +# bash's &>> feature is broken in f8 function start() { - if [ ! -x $slicescript ] ; then - echo "vinit@$slicename: no executable $slicescript - ignored" - return 0 - fi + [ -x $slicescript ] || return 0 echo $"Starting $prog" - $slicescript start $slicename >& /var/log/vinit & + $slicescript start $slicename >> /var/log/vinit 2>&1 & touch ${lockfile} return 0 } -# the initial model came without a stop function; legacy ... function stop() { + [ -x $slicescript ] && $slicescript stop $slicename >> /var/log/vinit 2>&1 & + # safe side + sleep 5 echo $"Stopping $prog " killproc $basename rm -f ${lockfile} } +function restart () { + [ -x $slicescript ] || return 0 + echo $"Restarting $prog" + $slicescript restart $slicename >> /var/log/vinit 2>&1 & + return 0 +} + function status () { if [ -f ${lockfile} ] ; then echo "$prog seems to have run" @@ -66,12 +70,16 @@ case "$1" in stop RETVAL=$? ;; + restart) + restart + RETVAL=$? + ;; status) status RETVAL=$? ;; *) - echo $"Usage: $0 {start|stop|status}" + echo $"Usage: $0 {start|stop|restart|status}" exit 1 ;; esac