Skip to content

Commit

Permalink
Fixes #715: update setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Jan 28, 2017
1 parent 9911c96 commit 682cdc0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions install_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 682cdc0

Please sign in to comment.