From a9cd4309e8d84f4ee76e6898b9b365b26d8cab45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20MOHIER?= Date: Sun, 29 Jan 2017 15:56:31 +0100 Subject: [PATCH] Fixes #715: update start/stop dev scripts --- dev/_launch_daemon.sh | 3 ++- dev/_stop_daemon.sh | 23 ++++++++++++++++++++++- dev/launch_arbiter.sh | 7 ++++++- dev/launch_broker.sh | 7 ++++++- dev/launch_poller.sh | 7 ++++++- dev/launch_reactionner.sh | 7 ++++++- dev/launch_receiver.sh | 7 ++++++- dev/launch_scheduler.sh | 7 ++++++- dev/stop_arbiter.sh | 8 ++++++-- dev/stop_broker.sh | 8 ++++++-- dev/stop_poller.sh | 8 ++++++-- dev/stop_reactionner.sh | 8 ++++++-- dev/stop_receiver.sh | 8 ++++++-- dev/stop_scheduler.sh | 8 ++++++-- etc/alignak.ini | 10 +++++----- 15 files changed, 101 insertions(+), 25 deletions(-) diff --git a/dev/_launch_daemon.sh b/dev/_launch_daemon.sh index c269807a1..3446b6c8e 100755 --- a/dev/_launch_daemon.sh +++ b/dev/_launch_daemon.sh @@ -122,6 +122,7 @@ echo "---" # Get the daemon's variables names (only the name, not the value) scr_var="${DAEMON_NAME}_DAEMON" +proc_var="${DAEMON_NAME}_PROCESS" cfg_var="${DAEMON_NAME}_CFG" dbg_var="${DAEMON_NAME}_DEBUGFILE" @@ -130,7 +131,7 @@ while IFS=';' read -ra VAR; do for v in "${VAR[@]}"; do eval "$v" done -done <<< "$($DIR/../alignak/bin/alignak_environment.py $DIR/../etc/alignak.ini)" +done <<< "$(alignak-environment $ALIGNAK_CONFIGURATION_INI)" if [ ${ALIGNAKCFG} ]; then echo "Alignak main configuration file is defined in the environment" diff --git a/dev/_stop_daemon.sh b/dev/_stop_daemon.sh index bd582ecb9..3bfca6c6c 100755 --- a/dev/_stop_daemon.sh +++ b/dev/_stop_daemon.sh @@ -35,6 +35,27 @@ fi DAEMON_NAME="$1" +# Alignak.ini file name +echo "---" +if [ ${ALIGNAKINI} ]; then + echo "Alignak ini configuration file is defined in the environment" + ALIGNAK_CONFIGURATION_INI="$ALIGNAKINI" +else + if [ -f "/usr/local/etc/alignak/alignak.ini" ]; then + echo "Alignak ini configuration file found in /usr/local/etc/alignak folder" + ALIGNAK_CONFIGURATION_INI="/usr/local/etc/alignak/alignak.ini" + else + if [ -f "/etc/alignak/alignak.ini" ]; then + echo "Alignak ini configuration file found in /etc/alignak folder" + ALIGNAK_CONFIGURATION_INI="/etc/alignak/alignak.ini" + else + ALIGNAK_CONFIGURATION_INI="$DIR/../etc/alignak.ini" + fi + fi +fi +echo "Alignak ini configuration file: $ALIGNAK_CONFIGURATION_INI" +echo "---" + # Get the daemon's variables names (only the name, not the value) scr_var="${DAEMON_NAME}_DAEMON" proc_var="${DAEMON_NAME}_PROCESS" @@ -46,7 +67,7 @@ while IFS=';' read -ra VAR; do for v in "${VAR[@]}"; do eval "$v" done -done <<< "$($DIR/../alignak/bin/alignak_environment.py ../etc/alignak.ini)" +done <<< "$(alignak-environment $ALIGNAK_CONFIGURATION_INI)" echo "---" diff --git a/dev/launch_arbiter.sh b/dev/launch_arbiter.sh index 0a261a124..ada7a8451 100755 --- a/dev/launch_arbiter.sh +++ b/dev/launch_arbiter.sh @@ -21,7 +21,12 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="ARBITER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_launch_daemon.sh" $@ -a "$DAEMON_NAME" diff --git a/dev/launch_broker.sh b/dev/launch_broker.sh index a23bdd09f..bf6a9e069 100755 --- a/dev/launch_broker.sh +++ b/dev/launch_broker.sh @@ -21,7 +21,12 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="BROKER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_launch_daemon.sh" $@ "$DAEMON_NAME" diff --git a/dev/launch_poller.sh b/dev/launch_poller.sh index 58975b847..a3e284a1c 100755 --- a/dev/launch_poller.sh +++ b/dev/launch_poller.sh @@ -21,7 +21,12 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="POLLER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_launch_daemon.sh" $@ "$DAEMON_NAME" diff --git a/dev/launch_reactionner.sh b/dev/launch_reactionner.sh index f546c7fcf..be8642f1c 100755 --- a/dev/launch_reactionner.sh +++ b/dev/launch_reactionner.sh @@ -21,7 +21,12 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="REACTIONNER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_launch_daemon.sh" $@ "$DAEMON_NAME" diff --git a/dev/launch_receiver.sh b/dev/launch_receiver.sh index ee96bcdf9..b1c362214 100755 --- a/dev/launch_receiver.sh +++ b/dev/launch_receiver.sh @@ -21,7 +21,12 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="RECEIVER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_launch_daemon.sh" $@ "$DAEMON_NAME" diff --git a/dev/launch_scheduler.sh b/dev/launch_scheduler.sh index c4a7a76f7..d2c7897d9 100755 --- a/dev/launch_scheduler.sh +++ b/dev/launch_scheduler.sh @@ -21,7 +21,12 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="SCHEDULER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_launch_daemon.sh" $@ "$DAEMON_NAME" diff --git a/dev/stop_arbiter.sh b/dev/stop_arbiter.sh index 065cbc24a..76f8d4faa 100755 --- a/dev/stop_arbiter.sh +++ b/dev/stop_arbiter.sh @@ -21,7 +21,11 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="ARBITER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_stop_daemon.sh" $@ "$DAEMON_NAME" - diff --git a/dev/stop_broker.sh b/dev/stop_broker.sh index e3ba67d3b..34ae63225 100755 --- a/dev/stop_broker.sh +++ b/dev/stop_broker.sh @@ -21,7 +21,11 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="BROKER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_stop_daemon.sh" $@ "$DAEMON_NAME" - diff --git a/dev/stop_poller.sh b/dev/stop_poller.sh index a3f54f6d1..04615a56f 100755 --- a/dev/stop_poller.sh +++ b/dev/stop_poller.sh @@ -21,7 +21,11 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="POLLER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_stop_daemon.sh" $@ "$DAEMON_NAME" - diff --git a/dev/stop_reactionner.sh b/dev/stop_reactionner.sh index ec79fd997..1cb4c957f 100755 --- a/dev/stop_reactionner.sh +++ b/dev/stop_reactionner.sh @@ -21,7 +21,11 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="REACTIONNER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_stop_daemon.sh" $@ "$DAEMON_NAME" - diff --git a/dev/stop_receiver.sh b/dev/stop_receiver.sh index 2c80c1a42..842ee6063 100755 --- a/dev/stop_receiver.sh +++ b/dev/stop_receiver.sh @@ -21,7 +21,11 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="RECEIVER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_stop_daemon.sh" $@ "$DAEMON_NAME" - diff --git a/dev/stop_scheduler.sh b/dev/stop_scheduler.sh index 0527428ff..382c7fb9f 100755 --- a/dev/stop_scheduler.sh +++ b/dev/stop_scheduler.sh @@ -21,7 +21,11 @@ DIR="$(cd $(dirname "$0"); pwd)" DAEMON_TYPE="SCHEDULER" -DAEMON_NAME="${DAEMON_TYPE}_MASTER" +if [ $# -eq 0 ]; then + DAEMON_NAME="${DAEMON_TYPE}_MASTER" +else + # Make parameter as uppercase for daemon name + DAEMON_NAME="${DAEMON_TYPE}_${1^^}" +fi "$DIR/_stop_daemon.sh" $@ "$DAEMON_NAME" - diff --git a/etc/alignak.ini b/etc/alignak.ini index 44076598a..5409ad131 100755 --- a/etc/alignak.ini +++ b/etc/alignak.ini @@ -73,7 +73,7 @@ SPECIFICCFG= [arbiter-master] ### ARBITER PART ### PROCESS=alignak-arbiter -DAEMON=%(BIN)s/alignak_arbiter.py +DAEMON=alignak-arbiter CFG=%(ETC)s/daemons/arbiterd.ini DEBUGFILE=%(LOG)s/arbiter-debug.log @@ -81,28 +81,28 @@ DEBUGFILE=%(LOG)s/arbiter-debug.log [scheduler-master] ### SCHEDULER PART ### PROCESS=alignak-scheduler -DAEMON=%(BIN)s/alignak_scheduler.py +DAEMON=alignak-scheduler CFG=%(ETC)s/daemons/schedulerd.ini DEBUGFILE=%(LOG)s/scheduler-debug.log [poller-master] ### POLLER PART ### PROCESS=alignak-poller -DAEMON=%(BIN)s/alignak_poller.py +DAEMON=alignak-poller CFG=%(ETC)s/daemons/pollerd.ini DEBUGFILE=%(LOG)s/poller-debug.log [reactionner-master] ### REACTIONNER PART ### PROCESS=alignak-reactionner -DAEMON=%(BIN)s/alignak_reactionner.py +DAEMON=alignak-reactionner CFG=%(ETC)s/daemons/reactionnerd.ini DEBUGFILE=%(LOG)s/reactionner-debug.log [broker-master] ### BROKER PART ### PROCESS=alignak-broker -DAEMON=%(BIN)s/alignak_broker.py +DAEMON=alignak-broker CFG=%(ETC)s/daemons/brokerd.ini DEBUGFILE=%(LOG)s/broker-debug.log