Author: waldi Date: Sat Apr 14 12:44:41 2012 New Revision: 976 Log: debian/xen-utils-common.xen.init: Do some cleanups. Modified: trunk/xen/debian/xen-utils-common.xen.init Modified: trunk/xen/debian/xen-utils-common.xen.init =============================================================================--- trunk/xen/debian/xen-utils-common.xen.init Sat Apr 14 12:28:46 2012 (r975) +++ trunk/xen/debian/xen-utils-common.xen.init Sat Apr 14 12:44:41 2012 (r976) @@ -65,6 +65,44 @@ fi log_progress_msg "xend" + xend_start_real + return $? +} + +xend_stop() +{ + if [ -z "$XEND" ] || [ "$(basename "$TOOLSTACK")" != xm ]; then + return 0 + fi + + log_progress_msg "xend" + xend_stop_real + return $? +} + +xend_restart() +{ + if [ -z "$XEND" ] || [ "$(basename "$TOOLSTACK")" != xm ]; then + return 0 + fi + + log_progress_msg "xend" + xend_stop_real + case "$?" in + 0|1) + xend_start_real + case "$?" in + 0) ;; + *) return 2 ;; + esac + ;; + *) return 2 ;; + esac + return 0 +} + +xend_start_real() +{ $XEND status && return 1 $XEND start || return 2 @@ -77,9 +115,8 @@ return 2 } -xend_stop() +xend_stop_real() { - [ -z "$XEND" ] && return 0 log_progress_msg "xend" $XEND status || return 0 $XEND stop || return 1 @@ -88,6 +125,36 @@ xenconsoled_start() { log_progress_msg "xenconsoled" + xenconsoled_start_real + return $? +} + +xenconsoled_stop() +{ + log_progress_msg "xenconsoled" + xenconsoled_stop_real + return $? +} + +xenconsoled_restart() +{ + log_progress_msg "xenconsoled" + xenconsoled_stop_real + case "$?" in + 0|1) + xenconsoled_start_real + case "$?" in + 0) ;; + *) return 2 ;; + esac + ;; + *) return 2 ;; + esac + return 0 +} + +xenconsoled_start_real() +{ start-stop-daemon --start --quiet --pidfile "$XENCONSOLED_PIDFILE" --exec "$XENCONSOLED" --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile "$XENCONSOLED_PIDFILE" --exec "$XENCONSOLED" -- \ @@ -95,7 +162,7 @@ || return 2 } -xenconsoled_stop() +xenconsoled_stop_real() { log_progress_msg "xenconsoled" start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile "$XENCONSOLED_PIDFILE" --name xenconsoled @@ -157,17 +224,18 @@ *) exit ;; esac log_daemon_msg "Stopping $DESC" + ret=0 xend_stop case "$?" in 0|1) ;; - *) log_end_msg 1 ;; + *) ret=1 ;; esac xenconsoled_stop case "$?" in 0|1) ;; - *) log_end_msg 1 ;; + *) ret=1 ;; esac - log_end_msg 0 + log_end_msg $ret ;; restart|force-reload) capability_check @@ -176,29 +244,18 @@ *) exit ;; esac log_daemon_msg "Restarting $DESC" - xend_stop + ret=0 + xend_restart case "$?" in - 0|1) - xend_start - case "$?" in - 0) ;; - *) log_end_msg 1 ;; - esac - ;; - *) log_end_msg 1 ;; + 0|1) ;; + *) ret=1 ;; esac - xenconsoled_stop + xenconsoled_restart case "$?" in - 0|1) - xenconsoled_start - case "$?" in - 0) ;; - *) log_end_msg 1 ;; - esac - ;; - *) log_end_msg 1 ;; + 0|1) ;; + *) ret=1 ;; esac - log_end_msg 0 + log_end_msg $ret ;; *) echo "Usage: $0 {start|stop|restart|force-reload}" >&2