diff --git a/alignak/bin/alignak_environment.py b/alignak/bin/alignak_environment.py
index 64f864baa..cca37df3a 100755
--- a/alignak/bin/alignak_environment.py
+++ b/alignak/bin/alignak_environment.py
@@ -19,11 +19,11 @@
# along with Alignak. If not, see .
"""
-set_alignak_env command line interface::
+alignak-environment command line interface::
Usage:
- set_alignak_env [-h]
- set_alignak_env [-v]
+ alignak-environment [-h]
+ alignak-environment [-v]
Options:
-h, --help Show this usage screen.
@@ -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:
diff --git a/dev/_launch_daemon.sh b/dev/_launch_daemon.sh
index 6d42c9890..3446b6c8e 100755
--- a/dev/_launch_daemon.sh
+++ b/dev/_launch_daemon.sh
@@ -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"
@@ -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"
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 e26db5431..5409ad131 100755
--- a/etc/alignak.ini
+++ b/etc/alignak.ini
@@ -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...
@@ -72,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
@@ -80,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
diff --git a/etc/arbiter/resource.d/paths.cfg b/etc/arbiter/resource.d/paths.cfg
index 547ca1028..3544e6d76 100644
--- a/etc/arbiter/resource.d/paths.cfg
+++ b/etc/arbiter/resource.d/paths.cfg
@@ -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$
diff --git a/install_hooks.py b/install_hooks.py
index b7b33b994..9dff141d4 100755
--- a/install_hooks.py
+++ b/install_hooks.py
@@ -48,36 +48,38 @@ def get_init_scripts(config):
:param config: current setup configuration
:return:
"""
- data_files = config['files']['data_files']
if 'win' in sys.platform:
raise Exception("Not yet Windows ready, sorry. For more information, "
"see: https://github.com/Alignak-monitoring/alignak/issues/522")
elif 'linux' in sys.platform or 'sunos5' in sys.platform:
- # Perhaps we may completely remove this @Seb-Solon? init.d scripts moved to packaging repo
- print("Linux: %s" % sys.platform)
- # data_files = data_files + "\nalignak/bin/etc/init.d = systemV/init.d/*"
- # data_files = data_files + "\nalignak/bin/etc/default = systemV/default/alignak.in"
- # data_files = data_files + "\nalignak/etc = systemV/alignak.ini"
+ print("Installing Alignak on Linux: %s" % sys.platform)
elif 'bsd' in sys.platform or 'dragonfly' in sys.platform:
- # Perhaps we may completely remove this @Seb-Solon? rc.d scripts moved to packaging repo
- print("Unix: %s" % sys.platform)
- # data_files = data_files + "\nalignak/bin/etc/rc.d = for_freebsd/rc.d/*"
- # # data_files = data_files + "\nalignak/bin/etc/default = for_freebsd/default/alignak.in"
- # data_files = data_files + "\nalignak/etc = for_freebsd/alignak.ini"
+ print("Installing Alignak on Unix: %s" % sys.platform)
else:
- raise Exception("Unsupported platform, sorry")
-
- config['files']['data_files'] = data_files
+ raise Exception("Unsupported platform: %s, sorry" % sys.platform)
+ print("\n"
+ "===================================================="
+ "====================================================")
+ print("Alignak installable directories/files: ")
for line in config['files']['data_files'].split('\n'):
+ if not line:
+ continue
line = line.strip().split('=')
- print("Installable directories/files: %s" % line)
+ if not line[1]:
+ print("will create directory: %s" % (line[0]))
+ else:
+ print("will copy: %s to %s" % (line[1], line[0]))
+ print("===================================================="
+ "====================================================\n")
def fix_alignak_cfg(config):
"""
Fix paths, user and group in alignak.cfg and daemons/*.ini
- Called one all files are copied.
+ Called once all files are copied.
+
+ The config.install_dir contains the python sys.prefix directory (most often: /usr/local)
:param config:
:return:
@@ -100,12 +102,18 @@ def fix_alignak_cfg(config):
changing_path = re.compile("^(%s) *= *" % pattern)
# Read main Alignak configuration file (eg. /etc/default/alignak)
- cfg_file_name = os.path.join(config.install_dir, "alignak", "bin", "etc", "default", "alignak.in")
- if os.path.exists(cfg_file_name):
- print("Alignak shell configuration file is: %s" % cfg_file_name)
+ # This file may exist on older installation... or for init.d start systems
+ cfg_file_name = ''
+ etc_default_alignak = os.path.join("etc", "default", "alignak")
+ use_local_etc_default_alignak = os.path.join(config.install_dir, "etc", "default", "alignak")
+ if os.path.exists(etc_default_alignak):
+ cfg_file_name = etc_default_alignak
+ if os.path.exists(use_local_etc_default_alignak):
+ cfg_file_name = use_local_etc_default_alignak
+ if cfg_file_name:
+ print("Found Alignak shell configuration file: %s" % cfg_file_name)
for line in open(cfg_file_name):
line = line.strip()
- print("Line: %s" % line)
got_path = changing_path.match(line)
if got_path:
found = got_path.group(1)
@@ -113,7 +121,7 @@ def fix_alignak_cfg(config):
config.install_dir, alignak_cfg[found].strip("/")
)
else:
- print("Alignak shell configuration file not found: %s" % cfg_file_name)
+ print("No Alignak shell configuration file found.")
for path in alignak_cfg:
if path not in ['USER', 'GROUP']:
alignak_cfg[path] = os.path.join(
@@ -127,8 +135,7 @@ def fix_alignak_cfg(config):
print("===================================================="
"====================================================\n")
- print("\n"
- "===================================================="
+ print("===================================================="
"====================================================")
print("Alignak main configuration directories: ")
for path in alignak_cfg:
@@ -137,24 +144,60 @@ def fix_alignak_cfg(config):
print("===================================================="
"====================================================\n")
+ print("===================================================="
+ "====================================================")
+ print("Alignak main configuration parameters: ")
+ for path in alignak_cfg:
+ if path in ['USER', 'GROUP']:
+ print(" %s = %s" % (path, alignak_cfg[path]))
+ print("===================================================="
+ "====================================================\n")
+
"""
- Update resource files
- - get all .cfg files in the arbiter/resource.d folder
+ Update monitoring objects configuration files
+ - get all .cfg files in the etc/alignak folder
- update the $LOG$=, $ETC$=,... macros with the real installation paths
"""
pattern = "|".join(alignak_cfg.keys())
- # Search from start of line something like ETC=qsdqsdqsd
- changing_path = re.compile("^(%s) *= *" % pattern)
+ # Search from start of line something like $ETC$=qsdqsdqsd
+ changing_path = re.compile(r"^\$(%s)\$ *= *" % pattern)
- resource_folder = os.path.join(alignak_cfg["ETC"], "arbiter", "resource.d")
- for _, _, files in os.walk(resource_folder):
+ folder = os.path.join(alignak_cfg["ETC"])
+ for root, dirs, files in os.walk(folder):
for r_file in files:
if not re.search(r"\.cfg$", r_file):
continue
# Handle resource paths file
- resource_file = os.path.join(resource_folder, r_file)
- for line in fileinput.input(resource_file, inplace=True):
+ updated_file = os.path.join(root, r_file)
+ print("Updating file: %s..." % updated_file)
+ for line in fileinput.input(updated_file, inplace=True):
+ line = line.strip()
+ got_path = changing_path.match(line)
+ if got_path:
+ print("$%s$=%s" % (got_path.group(1), alignak_cfg[got_path.group(1)]))
+ else:
+ print(line)
+
+ """
+ Update alignak configuration file
+ - get alignak.ini
+ - update the LOG=, ETC=,... variables with the real installation paths
+ """
+ pattern = "|".join(alignak_cfg.keys())
+ # Search from start of line something like ETC=qsdqsdqsd
+ changing_path = re.compile(r"^(%s) *= *" % pattern)
+
+ folder = os.path.join(alignak_cfg["ETC"])
+ for root, dirs, files in os.walk(folder):
+ for r_file in files:
+ if not re.search(r"\.ini$", r_file):
+ continue
+
+ # Handle resource paths file
+ updated_file = os.path.join(root, r_file)
+ print("Updating file: %s..." % updated_file)
+ for line in fileinput.input(updated_file, inplace=True):
line = line.strip()
got_path = changing_path.match(line)
if got_path:
@@ -165,50 +208,34 @@ def fix_alignak_cfg(config):
"""
Update daemons configuration files
- get all .ini files in the arbiter/daemons folder
+ - update the LOG=, ETC=,... variables with the real installation paths
- update the workdir, logdir and etcdir variables with the real installation paths
"""
- default_paths = {
- 'workdir': 'RUN',
- 'logdir': 'LOG',
- 'etcdir': 'ETC'
- }
- pattern = "|".join(default_paths.keys())
+ alignak_cfg.update({
+ 'workdir': alignak_cfg['RUN'],
+ 'logdir': alignak_cfg['LOG'],
+ 'etcdir': alignak_cfg['ETC']
+ })
+ pattern = "|".join(alignak_cfg.keys())
changing_path = re.compile("^(%s) *= *" % pattern)
- daemons_folder = os.path.join(alignak_cfg["ETC"], "daemons")
- for _, _, files in os.walk(daemons_folder):
- for d_file in files:
- if not re.search(r"\.ini", d_file):
+ folder = os.path.join(alignak_cfg["ETC"])
+ for root, dirs, files in os.walk(folder):
+ for r_file in files:
+ if not re.search(r"\.ini$", r_file):
continue
- # Handle daemon configuration file
- daemon_file = os.path.join(daemons_folder, d_file)
- if not os.path.exists(daemon_file):
- # Ignone not distributed ini files
- continue
- for line in fileinput.input(daemon_file, inplace=True):
+ # Handle resource paths file
+ updated_file = os.path.join(root, r_file)
+ print("Updating file: %s..." % updated_file)
+ for line in fileinput.input(updated_file, inplace=True):
line = line.strip()
got_path = changing_path.match(line)
if got_path:
- print("%s=%s" % (got_path.group(1), alignak_cfg[default_paths[got_path.group(1)]]))
+ print("%s=%s" % (got_path.group(1), alignak_cfg[got_path.group(1)]))
else:
print(line)
- """
- Get default run scripts and configuration location
- """
- # # Alignak run script
- # alignak_run = ''
- # if 'win' in sys.platform:
- # raise Exception("Not yet Windows ready, sorry. For more information, "
- # "see: https://github.com/Alignak-monitoring/alignak/issues/522")
- # elif 'linux' in sys.platform or 'sunos5' in sys.platform:
- # alignak_run = os.path.join(config.install_dir,
- # "alignak", "bin", "etc", "init.d", "alignak start")
- # elif 'bsd' in sys.platform or 'dragonfly' in sys.platform:
- # alignak_run = os.path.join(config.install_dir,
- # "alignak", "bin", "etc", "rc.d", "alignak start")
-
# Alignak configuration root directory
alignak_etc = alignak_cfg["ETC"]
@@ -226,7 +253,6 @@ def fix_alignak_cfg(config):
"""export ALIGNAK_DEFAULT_FILE=%s/etc/default/alignak\n"""
% os.environ.get("VIRTUAL_ENV"))
alignak_etc = "%s/etc/alignak" % os.environ.get("VIRTUAL_ENV")
- alignak_run = "%s/etc/init.d alignak start" % os.environ.get("VIRTUAL_ENV")
if afd.read().find(env_config) == -1:
afd.write(env_config)
@@ -242,40 +268,41 @@ def fix_alignak_cfg(config):
print("\n"
"================================================================================\n"
- "== ==\n"
- "== The installation succeded. ==\n"
- "== ==\n"
+ "==\n"
+ "== The installation succeded.\n"
+ "==\n"
"== -------------------------------------------------------------------------- ==\n"
- "== ==\n"
- "== You can run Alignak with the scripts located in the dev folder. ==\n"
- "== ==\n"
- "== The default installed configuration is located here: ==\n"
+ "==\n"
+ "== You can run Alignak with the scripts located in the dev folder.\n"
+ "==\n"
+ "== The default installed configuration is located here:\n"
"== %s\n"
- "== ==\n"
- "== You will find more information about Alignak configuration here: ==\n"
- "== http://alignak-doc.readthedocs.io/en/latest/04_configuration/index.html ==\n"
- "== ==\n"
+ "==\n"
+ "== You will find more information about Alignak configuration here:\n"
+ "== http://alignak-doc.readthedocs.io/en/latest/04_configuration/index.html\n"
+ "==\n"
"== -------------------------------------------------------------------------- ==\n"
- "== ==\n"
- "== You should grant the write permissions on the configuration directory to ==\n"
- "== the user alignak: ==\n"
+ "==\n"
+ "== You should grant the write permissions on the configuration directory to \n"
+ "== the user alignak:\n"
"== find %s -type f -exec chmod 664 {} +\n"
"== find %s -type d -exec chmod 775 {} +\n"
- "== -------------------------------------------------------------------------- ==\n"
- "== ==\n"
- "== You should also grant ownership on those directories to the user alignak: ==\n"
+ "==\n"
+ "== You should also grant ownership on those directories to the user alignak:\n"
+ "== chown -R alignak:alignak %s\n"
"== chown -R alignak:alignak %s\n"
"== chown -R alignak:alignak %s\n"
- "== ==\n"
+ "==\n"
"== -------------------------------------------------------------------------- ==\n"
- "== ==\n"
- "== Please note that installing Alignak with the setup.py script is not the ==\n"
- "== recommended way. You'd rather use the packaging built for your OS ==\n"
- "== distribution that you can find here: ==\n"
- "== http://alignak-monitoring.github.io/download/ ==\n"
- "== ==\n"
+ "==\n"
+ "== Please note that installing Alignak with the setup.py script is not the \n"
+ "== recommended way for a production installation. You'd rather use the "
+ "== packaging built for your OS distribution that you can find here:\n"
+ "== http://alignak-monitoring.github.io/download/\n"
+ "==\n"
"================================================================================\n"
- % (alignak_etc, alignak_etc, alignak_etc, alignak_cfg["LOG"], alignak_cfg["VAR"])
+ % (alignak_etc, alignak_etc, alignak_etc,
+ alignak_cfg["RUN"], alignak_cfg["LOG"], alignak_cfg["VAR"])
)
# Check Alignak recommended user existence
diff --git a/setup.cfg b/setup.cfg
index 05872a618..f0162dde5 100755
--- a/setup.cfg
+++ b/setup.cfg
@@ -28,6 +28,7 @@ post-hook.fix_alignak_cfg = install_hooks.fix_alignak_cfg
[entry_points]
console_scripts =
+ alignak-environment = alignak.bin.alignak_environment:main
alignak-arbiter = alignak.bin.alignak_arbiter:main
alignak-broker = alignak.bin.alignak_broker:main
alignak-receiver = alignak.bin.alignak_receiver:main