From d2baa21dc4a01c528ce563b22cd97f6444b2ce89 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 11 Mar 2010 12:27:11 +0100 Subject: [PATCH] ganeti.initd: Move code checking config to daemon-util MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows for more code re-use. daemon-util will also be used to start all daemons. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- daemons/daemon-util.in | 15 +++++++++++++++ doc/examples/ganeti.initd.in | 19 ++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in index 26c650a7e..5d7e89b03 100755 --- a/daemons/daemon-util.in +++ b/daemons/daemon-util.in @@ -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 diff --git a/doc/examples/ganeti.initd.in b/doc/examples/ganeti.initd.in index 5dc03962f..5ad3a9ba2 100644 --- a/doc/examples/ganeti.initd.in +++ b/doc/examples/ganeti.initd.in @@ -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" ;; -- GitLab