summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorMichael Orlitzky <michael@orlitzky.com>2018-07-15 14:32:07 -0400
committerMichael Orlitzky <michael@orlitzky.com>2021-05-14 07:50:34 -0400
commitdd0f3487578e6feb54a54e774fcc40e390d769f8 (patch)
treed684cca6ad8e1fbf494957067c17a79b22a6f687 /setup.py
parente6a9f109c5349041987e64909917256e9c6e4229 (diff)
downloadfail2ban-dd0f3487578e6feb54a54e774fcc40e390d769f8.tar.gz
files/fail2ban-openrc.init: replace @BINDIR@ at build-time.
This commit renames fail2ban-openrc.init to fail2ban-openrc.init.in, and replaces the hard-coded value "/usr/bin" with "@BINDIR@" therein. At build-time, setup.py will replace that string with the correct value, and rename the file (without the ".in" suffix). This mimics the procedure done for "fail2ban-service.in" entirely.
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/setup.py b/setup.py
index 8da29268..e18c99f3 100755
--- a/setup.py
+++ b/setup.py
@@ -95,24 +95,27 @@ class install_scripts_f2b(install_scripts):
if install_dir.startswith(root):
install_dir = install_dir[len(root):]
except: # pragma: no cover
- print('WARNING: Cannot find root-base option, check the bin-path to fail2ban-scripts in "fail2ban.service".')
- print('Creating %s/fail2ban.service (from fail2ban.service.in): @BINDIR@ -> %s' % (buildroot, install_dir))
- with open(os.path.join(source_dir, 'files/fail2ban.service.in'), 'r') as fn:
- lines = fn.readlines()
- fn = None
- if not dry_run:
- fn = open(os.path.join(buildroot, 'fail2ban.service'), 'w')
- try:
- for ln in lines:
- ln = re.sub(r'@BINDIR@', lambda v: install_dir, ln)
- if dry_run:
- sys.stdout.write(' | ' + ln)
- continue
- fn.write(ln)
- finally:
- if fn: fn.close()
- if dry_run:
- print(' `')
+ print('WARNING: Cannot find root-base option, check the bin-path to fail2ban-scripts in "fail2ban.service" and "fail2ban-openrc.init".')
+
+ scripts = ['fail2ban.service', 'fail2ban-openrc.init']
+ for script in scripts:
+ print('Creating %s/%s (from %s.in): @BINDIR@ -> %s' % (buildroot, script, script, install_dir))
+ with open(os.path.join(source_dir, 'files/%s.in' % script), 'r') as fn:
+ lines = fn.readlines()
+ fn = None
+ if not dry_run:
+ fn = open(os.path.join(buildroot, script), 'w')
+ try:
+ for ln in lines:
+ ln = re.sub(r'@BINDIR@', lambda v: install_dir, ln)
+ if dry_run:
+ sys.stdout.write(' | ' + ln)
+ continue
+ fn.write(ln)
+ finally:
+ if fn: fn.close()
+ if dry_run:
+ print(' `')
# Wrapper to specify fail2ban own options: