Commit d2baa21d authored by Michael Hanselmann's avatar Michael Hanselmann

ganeti.initd: Move code checking config to daemon-util

This allows for more code re-use. daemon-util will also be used to start
all daemons.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 7289c16e
......@@ -36,6 +36,21 @@ _daemon_pidfile() {
echo "@LOCALSTATEDIR@/run/ganeti/$1.pid"
}
# Checks whether the local machine is part of a cluster
check_config() {
local server_pem=@LOCALSTATEDIR@/lib/ganeti/server.pem
local fname
for fname in $server_pem; do
if [[ ! -f $fname ]]; then
echo "Missing configuration file $fname" >&2
return 1
fi
done
return 0
}
# Checks whether daemon is running
check() {
if [[ "$#" -lt 1 ]]; then
......
......@@ -27,18 +27,6 @@ test -f "@PREFIX@/sbin/$NODED" || exit 0
. /lib/lsb/init-functions
check_config() {
for fname in \
"@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
done
}
check_exitcode() {
RC=$1
case $RC in
......@@ -80,7 +68,11 @@ maybe_do() {
}
start_all() {
check_config
if ! $DAEMON_UTIL check-config; then
log_warning_msg "Incomplete configuration, will not run."
exit 0
fi
for i in $NODED $MASTERD $CONFD $RAPI; do \
maybe_do "$1" start_action $i
done
......@@ -111,6 +103,7 @@ case "$1" in
stop_all "$2"
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$2"
stop_all "$2"
start_all "$2"
;;
......
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