X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/07c7c94a75c227cfc50bd665e9d29b5873716937..325947e719d0c75711aa9b5086bbd4be9e047343:/daemons/daemon-util.in diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in index 5bf2c3f..44c39a9 100644 --- a/daemons/daemon-util.in +++ b/daemons/daemon-util.in @@ -20,7 +20,9 @@ set -e -defaults_file=@SYSCONFDIR@/default/ganeti +@SHELL_ENV_INIT@ + +readonly 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, @@ -31,14 +33,29 @@ DAEMONS=( ganeti-rapi ) -if [[ "@CUSTOM_ENABLE_CONFD@" == True ]]; then +_confd_enabled() { + [[ "@CUSTOM_ENABLE_CONFD@" == True ]] +} + +if _confd_enabled; then DAEMONS+=( ganeti-confd ) + DAEMONS+=( ganeti-luxid ) +fi + +_mond_enabled() { + [[ "@CUSTOM_ENABLE_MOND@" == True ]] +} + +if _mond_enabled; then + DAEMONS+=( ganeti-mond ) fi NODED_ARGS= MASTERD_ARGS= CONFD_ARGS= +LUXID_ARGS= RAPI_ARGS= +MOND_ARGS= # Read defaults file if it exists if [[ -s $defaults_file ]]; then @@ -52,7 +69,7 @@ _ignore_error() { } _daemon_pidfile() { - echo "@LOCALSTATEDIR@/run/ganeti/$1.pid" + echo "$RUN_DIR/$1.pid" } _daemon_executable() { @@ -67,12 +84,18 @@ _daemon_usergroup() { confd) echo "@GNTCONFDUSER@:@GNTCONFDGROUP@" ;; + luxid) + echo "@GNTLUXIDUSER@:@GNTLUXIDGROUP@" + ;; rapi) echo "@GNTRAPIUSER@:@GNTRAPIGROUP@" ;; noded) echo "@GNTNODEDUSER@:@GNTDAEMONSGROUP@" ;; + mond) + echo "@GNTMONDUSER@:@GNTMONDGROUP@" + ;; *) echo "root:@GNTDAEMONSGROUP@" ;; @@ -81,7 +104,7 @@ _daemon_usergroup() { # Checks whether the local machine is part of a cluster check_config() { - local server_pem=@LOCALSTATEDIR@/lib/ganeti/server.pem + local server_pem=$DATA_DIR/server.pem local fname for fname in $server_pem; do @@ -203,20 +226,19 @@ start() { fi local name="$1"; shift + # Convert daemon name to uppercase after removing "ganeti-" prefix + local plain_name=${name#ganeti-} + local ucname=$(tr a-z A-Z <<<$plain_name) local pidfile=$(_daemon_pidfile $name) local usergroup=$(_daemon_usergroup $plain_name) local daemonexec=$(_daemon_executable $name) - if [[ "$name" == ganeti-confd && - "@CUSTOM_ENABLE_CONFD@" == False ]]; then + if ( [[ "$name" == ganeti-confd ]] || [[ "$name" == ganeti-luxid ]] ) \ + && ! _confd_enabled; then echo 'ganeti-confd disabled at build time' >&2 return 1 fi - # Convert daemon name to uppercase after removing "ganeti-" prefix - local plain_name=${name#ganeti-} - local ucname=$(tr a-z A-Z <<<$plain_name) - # Read $_ARGS and $EXTRA__ARGS eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\"" @@ -236,6 +258,7 @@ start() { --user ${usergroup%:*} \ $daemonexec $args "$@" fi + } # Stops a daemon @@ -301,6 +324,34 @@ stop_all() { done } +# SIGHUP a process to force re-opening its logfiles +rotate_logs() { + if [[ "$#" -lt 1 ]]; then + echo 'Missing daemon name.' >&2 + return 1 + fi + + local name="$1"; shift + local pidfile=$(_daemon_pidfile $name) + local daemonexec=$(_daemon_executable $name) + + if type -p start-stop-daemon >/dev/null; then + start-stop-daemon --stop --signal HUP --quiet \ + --oknodo --pidfile $pidfile + else + _ignore_error killproc \ + -p $pidfile \ + $daemonexec -HUP + fi +} + +# SIGHUP all processes +rotate_all_logs() { + for i in $(list_stop_daemons); do + rotate_logs $i + done +} + # Reloads the SSH keys reload_ssh_keys() { @RPL_SSH_INITD_SCRIPT@ restart