[PATCH 2/3] libvirt-guests: enhance status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 (status): Break into new routine,
and provide output.
(usage): Document status.
---
 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 3a5b205..953b18a 100644
--- a/daemon/libvirt-guests.init.in
+++ b/daemon/libvirt-guests.init.in
@@ -282,2 +282,2 @@ 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}
 }

@@ -306,11 +324,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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]