daemon-util: Add function to start and stop all daemons
authorMichael Hanselmann <hansmi@google.com>
Thu, 11 Mar 2010 16:16:28 +0000 (17:16 +0100)
committerMichael Hanselmann <hansmi@google.com>
Fri, 12 Mar 2010 15:44:43 +0000 (16:44 +0100)
This is, to some degree, duplicated code from the init script. However,
the init script has to conform to standards of the underlying Linux
distributions, while these functions will be called by Ganeti itself. By
moving more code into daemon-util, the amount of duplication has been
reduced.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

daemons/daemon-util.in

index ea2bd5f..3cee400 100755 (executable)
@@ -185,6 +185,30 @@ stop_master() {
   stop ganeti-masterd
 }
 
+# Start all daemons
+start_all() {
+  for i in $(list_start_daemons); do
+    local rc=0
+
+    # Try to start daemon
+    start $i || rc=$?
+
+    if ! errmsg=$(check_exitcode $rc); then
+      echo "$errmsg" >&2
+      return 1
+    fi
+  done
+
+  return 0
+}
+
+# Stop all daemons
+stop_all() {
+  for i in $(list_stop_daemons); do
+    stop $i
+  done
+}
+
 # Reloads the SSH keys
 reload_ssh_keys() {
   @RPL_SSH_INITD_SCRIPT@ restart