Commit 5d8acbdd authored by Michael Hanselmann's avatar Michael Hanselmann

ganeti.initd: Move all daemon names from init script to daemon-util

The list of daemon names will be used in daemon-util, too.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 10c5c1c3
......@@ -22,6 +22,16 @@ set -e
defaults_file=@SYSCONFDIR@/default/ganeti
# This is a list of all daemons and the order in which they're started. The
# order is important as there are dependencies between them. On shutdown,
# they're stopped in reverse order.
DAEMONS=(
ganeti-noded
ganeti-masterd
ganeti-rapi
ganeti-confd
)
NODED_ARGS=
MASTERD_ARGS=
CONFD_ARGS=
......@@ -74,6 +84,39 @@ check_exitcode() {
return 0
}
# Prints a list of all daemons in the order in which they should be started
list_start_daemons() {
local name
for name in "${DAEMONS[@]}"; do
echo "$name"
done
}
# Prints a list of all daemons in the order in which they should be stopped
list_stop_daemons() {
list_start_daemons | tac
}
# Checks whether a daemon name is known
is_daemon_name() {
if [[ "$#" -lt 1 ]]; then
echo 'Missing daemon name.' >&2
return 1
fi
local name="$1"; shift
for i in "${DAEMONS[@]}"; do
if [[ "$i" == "$name" ]]; then
return 0
fi
done
echo "Unknown daemon name '$name'" >&2
return 1
}
# Checks whether daemon is running
check() {
if [[ "$#" -lt 1 ]]; then
......
......@@ -14,16 +14,11 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
DESC="Ganeti cluster"
NODED="ganeti-noded"
MASTERD="ganeti-masterd"
CONFD="ganeti-confd"
RAPI="ganeti-rapi"
DAEMON_UTIL=@PKGLIBDIR@/daemon-util
SCRIPTNAME="@SYSCONFDIR@/init.d/ganeti"
test -f "@PREFIX@/sbin/$NODED" || exit 0
test -f "$DAEMON_UTIL" || exit 0
. /lib/lsb/init-functions
......@@ -69,23 +64,19 @@ start_all() {
exit 0
fi
for i in $NODED $MASTERD $CONFD $RAPI; do \
for i in $($DAEMON_UTIL list-start-daemons); do
maybe_do "$1" start_action $i
done
}
stop_all() {
for i in $RAPI $CONFD $MASTERD $NODED; do \
for i in $($DAEMON_UTIL list-stop-daemons); do
maybe_do "$1" stop_action $i
done
}
if [ -n "$2" -a \
"$2" != "$NODED" -a \
"$2" != "$CONFD" -a \
"$2" != "$MASTERD" -a \
"$2" != "$RAPI" ]; then
log_failure_msg "Unknown daemon '$2' requested"
if [ -n "$2" ] && ! errmsg=$($DAEMON_UTIL is-daemon-name "$2" 2>&1); then
log_failure_msg "$errmsg"
exit 1
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment