diff --git a/install_hooks.py b/install_hooks.py index b7b33b994..0346a30fb 100755 --- a/install_hooks.py +++ b/install_hooks.py @@ -151,6 +151,33 @@ def fix_alignak_cfg(config): for r_file in files: if not re.search(r"\.cfg$", r_file): continue + print("Updating file: %s" % r_file) + + # Handle resource paths file + resource_file = os.path.join(resource_folder, r_file) + for line in fileinput.input(resource_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 and alignak.cfg file + - 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) + + resource_folder = os.path.join(alignak_cfg["ETC"]) + for _, _, files in os.walk(resource_folder): + for r_file in files: + if not re.search(r"alignak.cfg$", r_file) and not re.search(r"alignak.ini$", r_file): + continue + print("Updating file: %s" % r_file) # Handle resource paths file resource_file = os.path.join(resource_folder, r_file) @@ -180,6 +207,7 @@ def fix_alignak_cfg(config): for d_file in files: if not re.search(r"\.ini", d_file): continue + print("Updating file: %s" % r_file) # Handle daemon configuration file daemon_file = os.path.join(daemons_folder, d_file)