From f903f5b9e01b45202d7b6277a58ee83b8eb7651b Mon Sep 17 00:00:00 2001 Message-Id: <f903f5b9e01b45202d7b6277a58ee83b8eb7651b.1284409900.git.jdenemar@redhat.com> From: Eric Blake <eblake@redhat.com> Date: Tue, 27 Jul 2010 13:50:35 -0600 Subject: [PATCH] libvirt-guests: enhance status Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=630621 LSB and https://fedoraproject.org/wiki/Packaging/SysVInitScript require status to output something useful, rather than just use the exit code. * daemon/libvirt-guests.init.in (rh_status): Break into new routine, and provide output. (usage): Document status. (cherry picked from commit c629a2883c0427abd03260813118e255a5bb8d65) --- daemon/libvirt-guests.init.in | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/daemon/libvirt-guests.init.in b/daemon/libvirt-guests.init.in index 36b987d..c006b32 100644 --- a/daemon/libvirt-guests.init.in +++ b/daemon/libvirt-guests.init.in @@ -287,10 +287,28 @@ gueststatus() { done } +# rh_status +# Display current status: whether saved state exists, and whether start +# has been executed. We cannot use status() from the functions library, +# since there is no external daemon process matching this init script. +rh_status() { + if [ -f "$LISTFILE" ]; then + echo $"stopped, with saved guests" + RETVAL=3 + else + if [ -f "$VAR_SUBSYS_LIBVIRT_GUESTS" ]; then + echo $"started" + else + echo $"stopped, with no saved guests" + fi + RETVAL=0 + fi +} + # usage [val] # Display usage string, then exit with VAL (defaults to 2). usage() { - echo $"Usage: $0 {start|stop|restart|force-reload|gueststatus|shutdown}" + echo $"Usage: $0 {start|stop|status|restart|force-reload|gueststatus|shutdown}" exit ${1-2} } @@ -311,11 +329,7 @@ case "$1" in force-reload) ;; status) - if [ -f "$LISTFILE" ]; then - RETVAL=3 - else - RETVAL=0 - fi + rh_status ;; shutdown) ON_SHUTDOWN=shutdown -- 1.7.2.2