[Ocfs2-tools-devel] [PATCH 7/7] o2cb.init: Add online-status

Sunil Mushran sunil.mushran at oracle.com
Thu Mar 17 17:31:51 PDT 2011


Add option online-status to the o2cb init service. This option returns
a one-line output (online, offline, error) and an error code (0 online,
1 offline and 2 error). This is useful for script writers.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 vendor/common/o2cb.init.sh |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/vendor/common/o2cb.init.sh b/vendor/common/o2cb.init.sh
index 622c0a6..ba2c376 100755
--- a/vendor/common/o2cb.init.sh
+++ b/vendor/common/o2cb.init.sh
@@ -1832,7 +1832,35 @@ status()
     userdlm_status
 }
 
+#
+# online_status()
+#
+# Return codes to userspace. ** Do not change. **
+# 0 is online, 1 is offline, 2 is error
+#
+online-status()
+{
+    CLUSTER="${1:-${O2CB_BOOTCLUSTER}}"
+    if [ -z "$CLUSTER" ]
+    then
+        return 2
+    fi
 
+    check_online "$CLUSTER"
+    RC=$?
+    if [ "$RC" = "2" ]
+    then
+        echo "online"
+        exit 0
+    elif [ "$RC" = "0" ]
+    then
+        echo "offline"
+        exit 1
+    else
+        echo "error"
+        exit 2
+    fi
+}
 
 case "$1" in
     start)
@@ -1866,6 +1894,10 @@ case "$1" in
         online "$2"
         ;;
 
+    online-status)
+        online-status "$2"
+        ;;
+
     offline)
         offline "$2"
         ;;
@@ -1904,7 +1936,7 @@ case "$1" in
         ;;
 
     *)
-        echo "Usage: $0 {start|stop|restart|force-reload|enable|disable|configure|load|unload|online|offline|force-offline|status}"
+        echo "Usage: $0 {start|stop|restart|force-reload|enable|disable|configure|load|unload|online|offline|force-offline|status|online-status}"
         exit 1
         ;;
 esac
-- 
1.7.1




More information about the Ocfs2-tools-devel mailing list