#!/bin/bash # # vinit - trigger the slice-local initscript as installed in /etc/rc.d/vinit.slice # # this is unconditionnally installed and activated in the sliver # but of course nothing is run if the script is not present # # note - for practical reasons this is *not* activated through chkconfig # as the slice has not yet started at that point # # historical note # 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) prog="Slice initscript ${basename}@${slicename}" lockfile=/var/lock/subsys/vinit RETVAL=0 # bash's &>> feature is broken in f8 function start() { [ -x $slicescript ] || return 0 echo $"Starting $prog" $slicescript start $slicename >> /var/log/vinit 2>&1 & touch ${lockfile} return 0 } 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" return 0 else echo "$prog apparently hasn't run" return 1 fi } case "$1" in start) start RETVAL=$? ;; stop) stop RETVAL=$? ;; restart) restart RETVAL=$? ;; status) status RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit $RETVAL