-check_config() {
- for fname in \
- "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \
- "@LOCALSTATEDIR@/lib/ganeti/server.pem"
- do
- if ! [ -f "$fname" ]; then
- log_end_msg 0
- log_warning_msg "Config $fname not there, will not run."
- exit 0
- fi
+check_exitcode() {
+ RC=$1
+
+ if errmsg=$($DAEMON_UTIL check-exitcode $RC)
+ then
+ log_action_end_msg 0 "$errmsg"
+ else
+ log_action_end_msg 1 "$errmsg"
+ fi
+}
+
+start_action() {
+ # called as start_action daemon-name
+ local daemon="$1"
+ log_action_begin_msg "$daemon"
+ $DAEMON_UTIL start "$@"
+ check_exitcode $?
+}
+
+stop_action() {
+ # called as stop_action daemon-name
+ local daemon="$1"
+ log_action_begin_msg "$daemon"
+ $DAEMON_UTIL stop "$@"
+ check_exitcode $?
+}
+
+maybe_do() {
+ requested="$1"; shift
+ action="$1"; shift
+ target="$1"
+ if [ -z "$requested" -o "$requested" = "$target" ]; then
+ $action "$@"
+ fi
+}
+
+start_all() {
+ if ! $DAEMON_UTIL check-config; then
+ log_warning_msg "Incomplete configuration, will not run."
+ exit 0
+ fi
+
+ for i in $($DAEMON_UTIL list-start-daemons); do
+ maybe_do "$1" start_action $i