#!/bin/sh # # xend Script to start and stop the Xen control daemon. # # chkconfig: 2345 98 01 # description: Starts and stops the Xen control daemon. # ### BEGIN INIT INFO # Provides: xend # Required-Start: $syslog $remote_fs xenstored xenconsoled # Should-Start: # Required-Stop: $syslog $remote_fs xenstored xenconsoled # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop xend # Description: Starts and stops the Xen control daemon. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions waitfordaemon() { i=1 rets=10 /usr/sbin/xend status while [ $? -ne 0 -a $i -lt $rets ]; do sleep 1 i=$(($i + 1)) /usr/sbin/xend status done return $? } start() { if [ -f /var/lock/subsys/xend ]; then msg_already_running "Xen control daemon" return fi if [ ! -f /var/lock/subsys/xenconsoled -o ! -f /var/lock/subsys/xenstored ]; then echo "xenconsoled and xenstored must be started first" return fi show "Starting Xen control daemon" busy /usr/sbin/xend start waitfordaemon RETVAL=$? if [ $RETVAL -eq 0 ]; then touch /var/lock/subsys/xend ok else fail fi } stop() { if [ ! -f /var/lock/subsys/xend ]; then msg_not_running "Xen control daemon" return fi show "Stopping Xen control daemon" busy /usr/sbin/xend stop ok rm -f /var/lock/subsys/xend } reload() { if [ ! -f /var/lock/subsys/xend ]; then msg_not_running "Xen control daemon" return fi show "Reloading Xen control daemon" busy /usr/sbin/xend reload ok } restart() { if [ ! -f /var/lock/subsys/xend ]; then msg_not_running "Xen control daemon" return fi show "Restarting Xen control daemon" busy /usr/sbin/xend restart waitfordaemon RETVAL=$? if [ $RETVAL -eq 0 ]; then ok else fail fi } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; status) /usr/sbin/xend status ;; reload) reload ;; restart|force-reload) restart ;; *) msg_usage "$0 {start|stop|status|restart|reload|force-reload}" exit 3 esac exit $RETVAL