]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirt-guests: enhance status
authorEric Blake <eblake@redhat.com>
Tue, 27 Jul 2010 19:50:35 +0000 (13:50 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 28 Jul 2010 13:22:25 +0000 (07:22 -0600)
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.

daemon/libvirt-guests.init.in

index 3a5b205364b4285196d9bf5121ddd0412753b09c..9b3bcd7aeac2135b556bc3c16f5a3b5e05375d46 100644 (file)
@@ -282,10 +282,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}
 }
 
@@ -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