Xend initscript

From brainsik
Jump to navigation Jump to search

diff

--- /etc/init.d/xend    2005-10-31 18:26:56.000000000 -0800
+++ /usr/local/src/xen/xen-2.0/dist/install/etc/init.d/xend     2005-10-17 17:51:27.000000000 -0700
@@ -6,7 +6,6 @@
 #
 # chkconfig: 2345 98 01
 # description: Starts and stops the Xen control daemon.
-PATH="${PATH}:/usr/local/sbin"
 
 if ! [ -e /proc/xen/privcmd ]; then
        exit 0
@@ -24,29 +23,22 @@
            i=$(($i + 1))
            xend status
        done
-       echo .
 }
 
 case "$1" in
   start)
-       echo -n "Starting Xen control daemon: xend"
        xend start
        await_daemons_up
-       echo .
        ;;
   stop)
-       echo -n "Stopping Xen control daemon: xend"
        xend stop
-       echo .
        ;;
   status)
        xend status
        ;;
   restart|reload|force-reload)
-       echo -n "Restarting Xen control daemon: xend"
        xend restart
        await_daemons_up
-       echo .
        ;;
   *)
        # do not advertise unreasonable commands that there is no reason

file

/etc/init.d/xend:

#!/bin/bash
#
# xend          Script to start and stop the Xen control daemon.
#
# Author:       Keir Fraser <keir.fraser@cl.cam.ac.uk>
#
# chkconfig: 2345 98 01
# description: Starts and stops the Xen control daemon.
PATH="${PATH}:/usr/local/sbin"

if ! [ -e /proc/xen/privcmd ]; then
        exit 0
fi

# Wait for Xend / Xfrd to be up
function await_daemons_up
{
        i=1
        rets=10
        xend status
        while [ $? -ne 0 -a $i -lt $rets ]; do
            sleep 1
            echo -n .
            i=$(($i + 1))
            xend status
        done
        echo .
}

case "$1" in
  start)
        echo -n "Starting Xen control daemon: xend"
        xend start
        await_daemons_up
        echo .
        ;;
  stop)
        echo -n "Stopping Xen control daemon: xend"
        xend stop
        echo .
        ;;
  status)
        xend status
        ;;
  restart|reload|force-reload)
        echo -n "Restarting Xen control daemon: xend"
        xend restart
        await_daemons_up
        echo .
        ;;
  *)
        # do not advertise unreasonable commands that there is no reason
        # to use with this device
        echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
        exit 1
esac

exit $?