forgot to add
authorS.Çağlar Onur <caglar@cs.princeton.edu>
Thu, 20 Jan 2011 19:11:30 +0000 (14:11 -0500)
committerS.Çağlar Onur <caglar@cs.princeton.edu>
Thu, 20 Jan 2011 19:11:30 +0000 (14:11 -0500)
sliver-initscripts/vinit [new file with mode: 0644]

diff --git a/sliver-initscripts/vinit b/sliver-initscripts/vinit
new file mode 100644 (file)
index 0000000..9e0c9b7
--- /dev/null
@@ -0,0 +1,81 @@
+#!/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
+# 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 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
+
+
+# Source function library.
+. /etc/init.d/functions
+
+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
+
+# xxx todo - redirect all stdout, stderr to /var/log/vinit for user access
+
+function start() {
+    if [ ! -x $slicescript ] ; then
+       echo "vinit@$slicename: no executable $slicescript - ignored"
+       return 0
+    fi
+    echo $"Starting $prog" 
+    $slicescript start $slicename >& /var/log/vinit &
+    touch ${lockfile}
+    return 0
+}
+
+# the initial model came without a stop function; legacy ...
+function stop() {
+    echo $"Stopping $prog "
+    killproc $basename
+    rm -f ${lockfile}
+}
+
+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=$?
+       ;;
+    status)
+       status 
+       RETVAL=$?
+       ;;
+    *)
+       echo $"Usage: $0 {start|stop|status}"
+       exit 1
+       ;;
+esac
+
+exit $RETVAL