diff -Naur orig.xen-4.1.1//tools/hotplug/Linux/init.d/xencommons xen-4.1.1//tools/hotplug/Linux/init.d/xencommons --- orig.xen-4.1.1//tools/hotplug/Linux/init.d/xencommons 2011-07-03 03:08:44.953747064 -0700 +++ xen-4.1.1//tools/hotplug/Linux/init.d/xencommons 2011-07-05 13:47:54.627029164 -0700 @@ -18,6 +18,9 @@ # Description: Starts and stops the daemons neeeded for xl/xend ### END INIT INFO +. /etc/rc.conf +. /etc/rc.d/functions + if [ -d /etc/sysconfig ]; then xencommons_config=/etc/sysconfig else @@ -26,7 +29,7 @@ test -f $xencommons_config/xencommons && . $xencommons_config/xencommons -XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid +XENCONSOLED_PIDFILE=/run/daemons/xenconsoled.pid shopt -s extglob if test "x$1" = xstart && \ @@ -51,8 +54,9 @@ rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T /var/log/xen/xenstored-trace.log" - echo -n Starting xenstored... - xenstored --pid-file=/var/run/xenstored.pid $XENSTORED_ARGS + #echo -n Starting xenstored... + stat_busy "Starting xenstored" + xenstored --pid-file=/run/daemons/xenstored.pid $XENSTORED_ARGS # Wait for xenstored to actually come up, timing out after 30 seconds while [ $time -lt $timeout ] && ! `xenstore-read -s / >/dev/null 2>&1` ; do @@ -60,33 +64,39 @@ time=$(($time+1)) sleep 1 done - echo - # Exit if we timed out if ! [ $time -lt $timeout ] ; then - echo Could not start xenstored + #echo Could not start xenstored + stat_fail exit 1 fi + stat_done - echo Setting domain 0 name... + stat_busy "Setting domain 0 name..." xenstore-write "/local/domain/0/name" "Domain-0" + stat_done fi - echo Starting xenconsoled... + #echo Starting xenconsoled... + stat_busy "Starting xenconsoled" test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE" xenconsoled --pid-file=$XENCONSOLED_PIDFILE $XENCONSOLED_ARGS test -z "$XENBACKENDD_DEBUG" || XENBACKENDD_ARGS="-d" test "`uname`" != "NetBSD" || xenbackendd $XENBACKENDD_ARGS + stat_done + add_daemon xencommons } do_stop () { - echo Stopping xenconsoled + stat_busy "Stopping xenconsoled" if read 2>/dev/null <$XENCONSOLED_PIDFILE pid; then kill $pid while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done rm -f $XENCONSOLED_PIDFILE fi + stat_done - echo WARNING: Not stopping xenstored, as it cannot be restarted. + printhl "WARNING: Not stopping xenstored, as it cannot be restarted." + rm_daemon xencommons } case "$1" in diff -Naur orig.xen-4.1.1//tools/hotplug/Linux/init.d/xend xen-4.1.1//tools/hotplug/Linux/init.d/xend --- orig.xen-4.1.1//tools/hotplug/Linux/init.d/xend 2011-07-03 03:08:44.953747064 -0700 +++ xen-4.1.1//tools/hotplug/Linux/init.d/xend 2011-07-05 01:47:40.981951191 -0700 @@ -18,6 +18,10 @@ # Description: Starts and stops the Xen control daemon. ### END INIT INFO +. /etc/rc.conf +. /etc/rc.d/functions + + shopt -s extglob # Wait for Xend to be up @@ -37,23 +41,30 @@ case "$1" in start) if [ -z "`ps -C xenconsoled -o pid=`" ]; then - echo "xencommons should be started first." + printhl "xencommons should be started first." exit 1 fi # mkdir shouldn't be needed as most distros have this already created. Default to using subsys. # See docs/misc/distro_mapping.txt - mkdir -p /var/lock - if [ -d /var/lock/subsys ] ; then - touch /var/lock/subsys/xend + if [ -d /run/lock/subsys ] ; then + touch /run/lock/subsys/xend else - touch /var/lock/xend + touch /run/lock/xend fi + stat_busy "Starting xend" xend start await_daemons_up + stat_done + add_daemon xend ;; + + stop) + stat_busy "Stopping xend" xend stop - rm -f /var/lock/subsys/xend /var/lock/xend + rm -f /run/lock/xend /var/lock/xend + stat_done + rm_daemon xend ;; status) xend status @@ -62,8 +73,10 @@ xend reload ;; restart|force-reload) + stat_busy "Restarting xend" xend restart await_daemons_up + stat_done ;; *) # do not advertise unreasonable commands that there is no reason diff -Naur orig.xen-4.1.1//tools/hotplug/Linux/init.d/xendomains xen-4.1.1//tools/hotplug/Linux/init.d/xendomains --- orig.xen-4.1.1//tools/hotplug/Linux/init.d/xendomains 2011-07-03 03:08:44.953747064 -0700 +++ xen-4.1.1//tools/hotplug/Linux/init.d/xendomains 2011-07-05 13:46:36.208222760 -0700 @@ -26,6 +26,9 @@ # Description: Start / stop domains automatically when domain 0 # boots / shuts down. ### END INIT INFO +. /etc/rc.conf +. /etc/rc.d/functions + CMD=xm $CMD list &> /dev/null @@ -46,93 +49,52 @@ exit 0 fi -# See docs/misc/distro_mapping.txt -if [ -d /var/lock/subsys ]; then - LOCKFILE=/var/lock/subsys/xendomains -else - LOCKFILE=/var/lock/xendomains -fi - -if [ -d /etc/sysconfig ]; then - XENDOM_CONFIG=/etc/sysconfig/xendomains -else - XENDOM_CONFIG=/etc/default/xendomains -fi +LOCKFILE=/run/lock/xendomains +XENDOM_CONFIG=/etc/default/xendomains -test -r $XENDOM_CONFIG || { echo "$XENDOM_CONFIG not existing"; +test -r $XENDOM_CONFIG || { + printhl "$XENDOM_CONFIG not existing"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; } . $XENDOM_CONFIG -# Use the SUSE rc_ init script functions; -# emulate them on LSB, RH and other systems -if test -e /etc/rc.status; then - # SUSE rc script library - . /etc/rc.status -else - _cmd=$1 - declare -a _SMSG - if test "${_cmd}" = "status"; then +_cmd=$1 +declare -a _SMSG +if test "${_cmd}" = "status"; then _SMSG=(running dead dead unused unknown) _RC_UNUSED=3 - else +else _SMSG=(done failed failed missed failed skipped unused failed failed) _RC_UNUSED=6 - fi - if test -e /etc/init.d/functions; then - # REDHAT - . /etc/init.d/functions - echo_rc() - { - #echo -n " [${_SMSG[${_RC_RV}]}] " - if test ${_RC_RV} = 0; then - success " [${_SMSG[${_RC_RV}]}] " - else - failure " [${_SMSG[${_RC_RV}]}] " - fi - } - elif test -e /lib/lsb/init-functions; then - # LSB - . /lib/lsb/init-functions - if alias log_success_msg >/dev/null 2>/dev/null; then - echo_rc() - { - echo " [${_SMSG[${_RC_RV}]}] " - } - else - echo_rc() - { - if test ${_RC_RV} = 0; then - log_success_msg " [${_SMSG[${_RC_RV}]}] " - else - log_failure_msg " [${_SMSG[${_RC_RV}]}] " - fi - } - fi - else - # emulate it - echo_rc() - { - echo " [${_SMSG[${_RC_RV}]}] " - } - fi - rc_reset() { _RC_RV=0; } - rc_failed() - { +fi + + + +echo_rc() { + echo + printhl "Return Status: ${_SMSG[${_RC_RV}]}" +} + + +rc_reset() { _RC_RV=0; } + + +rc_failed() { if test -z "$1"; then - _RC_RV=1; + _RC_RV=1; elif test "$1" != "0"; then - _RC_RV=$1; - fi + _RC_RV=$1; + fi return ${_RC_RV} - } - rc_check() - { +} + +rc_check() { return rc_failed $? - } - rc_status() - { +} + + +rc_status() { rc_failed $? if test "$1" = "-r"; then _RC_RV=0; shift; fi if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi @@ -140,26 +102,24 @@ if test "$1" = "-v"; then echo_rc; shift; fi if test "$1" = "-r"; then _RC_RV=0; shift; fi return ${_RC_RV} - } - rc_exit() { exit ${_RC_RV}; } - rc_active() - { +} + + +rc_exit() { exit ${_RC_RV}; } + + +rc_active() { if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi return 1 - } -fi +} -if ! which usleep >&/dev/null -then - usleep() - { - if [ -n "$1" ] - then - sleep $(( $1 / 1000000 )) - fi - } -fi +usleep() { + if [ -n "$1" ] + then + sleep $(( $1 / 1000000 )) + fi +} # Reset status of this service rc_reset @@ -235,10 +195,12 @@ start() { if [ -f $LOCKFILE ]; then - echo -e "xendomains already running (lockfile exists)" + stat_busy "xendomains already running (lockfile exists)" + stat_fail return; fi + printhl "Starting Xen Domains" saved_domains=" " if [ "$XENDOMAINS_RESTORE" = "true" ] && contains_something "$XENDOMAINS_SAVE" @@ -299,6 +261,7 @@ fi done fi + add_daemon xendomains } all_zombies() @@ -352,7 +315,7 @@ if test "$XENDOMAINS_AUTO_ONLY" = "true"; then rdnames fi - echo -n "Shutting down Xen domains:" + printhl "Shutting down Xen domains" name=;id= while read LN; do parseln "$LN" || continue @@ -465,6 +428,7 @@ rm -f $LOCKFILE exec 2>&3 + rm_daemon xendomains } check_domain_up() diff -Naur orig.xen-4.1.1//tools/hotplug/Linux/init.d/xen-watchdog xen-4.1.1//tools/hotplug/Linux/init.d/xen-watchdog --- orig.xen-4.1.1//tools/hotplug/Linux/init.d/xen-watchdog 2011-07-03 03:08:44.957080397 -0700 +++ xen-4.1.1//tools/hotplug/Linux/init.d/xen-watchdog 2011-07-05 13:20:22.515289867 -0700 @@ -17,49 +17,32 @@ ### END INIT INFO # +. /etc/rc.conf +. /etc/rc.d/functions + DAEMON=/usr/sbin/xenwatchdogd base=$(basename $DAEMON) +initname="xen-watchdog" -# Source function library. -if [ -e /etc/init.d/functions ] ; then - . /etc/init.d/functions -elif [ -e /lib/lsb/init-functions ] ; then - . /lib/lsb/init-functions - success () { - log_success_msg $* - } - failure () { - log_failure_msg $* - } -else - success () { - echo $* - } - failure () { - echo $* - } -fi start() { local r - echo -n $"Starting domain watchdog daemon: " + stat_busy "Starting domain watchdog daemon" $DAEMON 30 15 r=$? - [ "$r" -eq 0 ] && success $"$base startup" || failure $"$base startup" - echo + [ "$r" -eq 0 ] && stat_done ; add_daemon $initname || stat_fail return $r } stop() { local r - echo -n $"Stopping domain watchdog daemon: " + stat_busy "Stopping domain watchdog daemon" killall -USR1 $base 2>/dev/null r=$? - [ "$r" -eq 0 ] && success $"$base stop" || failure $"$base stop" - echo + [ "$r" -eq 0 ] && stat_done ; rm_daemon $initname || stat_fail return $r }