Blob Blame History Raw
*** xen-unstable/tools/examples/init.d/xend.orig	2006-06-12 17:10:53.000000000 +0200
--- xen-unstable/tools/examples/init.d/xend	2006-06-12 17:11:22.000000000 +0200
***************
*** 7,43 ****
  # chkconfig: 2345 98 01
  # description: Starts and stops the Xen control daemon.
  
  if ! grep -q "control_d" /proc/xen/capabilities ; then
  	exit 0
  fi
  
  # Wait for Xend 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
  }
  
  case "$1" in
    start)
! 	xend start
  	await_daemons_up
  	;;
    stop)
! 	xend stop
  	;;
    status)
! 	xend status
  	;;
    restart|reload|force-reload)
! 	xend restart
  	await_daemons_up
  	;;
    *)
--- 7,64 ----
  # chkconfig: 2345 98 01
  # description: Starts and stops the Xen control daemon.
  
+ # Source function library.
+ . /etc/rc.d/init.d/functions
+ 
+ RETVAL=0
  if ! grep -q "control_d" /proc/xen/capabilities ; then
+         RETVAL=-1
  	exit 0
  fi
+ prog=xend
  
  # Wait for Xend to be up
  function await_daemons_up
  {
  	i=1
  	rets=10
! 	/usr/sbin/xend status
  	while [ $? -ne 0 -a $i -lt $rets ]; do
  	    sleep 1
  	    echo -n .
  	    i=$(($i + 1))
! 	    /usr/sbin/xend status
  	done
+         if [ $i -ge $rets ]; then
+             RETVAL=-1
+             return 1
+         fi
+         return 0
  }
  
  case "$1" in
    start)
! 	echo -n $"Starting $prog: "
! 	/usr/sbin/xend start
  	await_daemons_up
  	;;
    stop)
! 	echo -n $"Stopping $prog: "
! 	/usr/sbin/xend stop
!         RETVAL=$?
  	;;
    status)
! 	/usr/sbin/xend status
! 	if [ $? = 0 ] ; then
! 	    echo xend is running
! 	else
! 	    echo xend is stopped
! 	fi
!         exit 0
  	;;
    restart|reload|force-reload)
!         echo -n $"$1 $prog: "
! 	/usr/sbin/xend restart
  	await_daemons_up
  	;;
    *)
*************** case "$1" in
*** 47,51 ****
  	exit 1
  esac
  
! exit $?
  
--- 68,79 ----
  	exit 1
  esac
  
! if [ $RETVAL = 0 ] ; then
!     echo_success
!     echo
! else
!     echo_failure
!     echo
! fi
! exit $RETVAL