Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #715 - installation and development start scripts #716

Merged
merged 1 commit into from
Jan 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions alignak/bin/alignak_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# along with Alignak. If not, see <http://www.gnu.org/licenses/>.

"""
set_alignak_env command line interface::
alignak-environment command line interface::

Usage:
set_alignak_env [-h]
set_alignak_env [-v] <cfg_file>
alignak-environment [-h]
alignak-environment [-v] <cfg_file>

Options:
-h, --help Show this usage screen.
Expand Down Expand Up @@ -81,12 +81,12 @@

Use cases:
Displays this usage screen
set_alignak_env (-h | --help)
alignak-environment (-h | --help)

Parse Alignak configuration files and define environment variables
Parse Alignak configuration file and define environment variables
cfg_file ../etc/alignak.ini

Parse Alignak configuration files and define environment variables and print information
Parse Alignak configuration file and define environment variables and print information
cfg_file -v ../etc/alignak.ini

Exit code:
Expand Down
24 changes: 23 additions & 1 deletion dev/_launch_daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,30 @@ case $i in
esac
done

# 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"
cfg_var="${DAEMON_NAME}_CFG"
dbg_var="${DAEMON_NAME}_DEBUGFILE"

Expand All @@ -109,7 +131,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)"

if [ ${ALIGNAKCFG} ]; then
echo "Alignak main configuration file is defined in the environment"
Expand Down
23 changes: 22 additions & 1 deletion dev/_stop_daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 "---"
Expand Down
7 changes: 6 additions & 1 deletion dev/launch_arbiter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

7 changes: 6 additions & 1 deletion dev/launch_broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

7 changes: 6 additions & 1 deletion dev/launch_poller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

7 changes: 6 additions & 1 deletion dev/launch_reactionner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

7 changes: 6 additions & 1 deletion dev/launch_receiver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

7 changes: 6 additions & 1 deletion dev/launch_scheduler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

8 changes: 6 additions & 2 deletions dev/stop_arbiter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

8 changes: 6 additions & 2 deletions dev/stop_broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

8 changes: 6 additions & 2 deletions dev/stop_poller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

8 changes: 6 additions & 2 deletions dev/stop_reactionner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

8 changes: 6 additions & 2 deletions dev/stop_receiver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

8 changes: 6 additions & 2 deletions dev/stop_scheduler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

13 changes: 7 additions & 6 deletions etc/alignak.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ ETC=../etc
VAR=/tmp
RUN=/tmp
LOG=/tmp

USER=alignak
GROUP=alignak

# We define the name of the 2 main Alignak configuration files.
# There may be 2 configuration files because tools like Centreon generate those...
Expand All @@ -72,36 +73,36 @@ 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


[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

Expand Down
14 changes: 10 additions & 4 deletions etc/arbiter/resource.d/paths.cfg
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# Nagios legacy macros
$USER1$=$NAGIOSPLUGINSDIR$
$NAGIOSPLUGINSDIR$=/usr/lib/nagios/plugins
# For a freeBSD, set this value:
# For a FreeBSD, set this value:
# $NAGIOSPLUGINSDIR$=/usr/local/libexec/nagios

#-- Alignak main directories
#-- Those variables are automatically updated during the Alignak installation
#-- Those macros are automatically updated during the Alignak installation
#-- process (eg. python setup.py install)
$BIN$=/usr/local/bin
$ETC$=/usr/local/alignak/etc
$VAR$=/usr/local/var
$RUN$=$VAR$/run
$LOG$=$VAR$/log
$LIBEXEC$=$VAR$/libexec
$PLUGINSDIR$=$LIBEXEC$/alignak

$USER$=alignak
$GROUP$=alignak

#-- Those macros are declared to be used in some templates or commands definition
$LIBEXEC$=$VAR$
$PLUGINSDIR$=$VAR$
Loading