mirror of https://github.com/fail2ban/fail2ban
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.pull/2182/head
parent
e6a9f109c5
commit
dd0f348757
2
MANIFEST
2
MANIFEST
|
@ -376,7 +376,7 @@ files/fail2ban-tmpfiles.conf
|
|||
files/fail2ban.upstart
|
||||
files/gen_badbots
|
||||
files/fail2ban-openrc.conf
|
||||
files/fail2ban-openrc.init
|
||||
files/fail2ban-openrc.init.in
|
||||
files/ipmasq-ZZZzzz_fail2ban.rul
|
||||
files/logwatch/fail2ban
|
||||
files/logwatch/fail2ban-0.8.log
|
||||
|
|
|
@ -26,12 +26,9 @@ extra_started_commands="reload"
|
|||
FAIL2BAN_RUNDIR="/run/${RC_SVCNAME}"
|
||||
FAIL2BAN_SOCKET="${FAIL2BAN_RUNDIR}/${RC_SVCNAME}.sock"
|
||||
|
||||
# This should be replaced by the build system, eventually.
|
||||
FAIL2BAN_BINDIR="/usr/bin"
|
||||
|
||||
# The fail2ban-client program is also capable of starting and stopping
|
||||
# the server, but things are simpler if we let start-stop-daemon do it.
|
||||
command="${FAIL2BAN_BINDIR}/fail2ban-server"
|
||||
command="@BINDIR@/fail2ban-server"
|
||||
pidfile="${FAIL2BAN_RUNDIR}/${RC_SVCNAME}.pid"
|
||||
|
||||
# We force the pidfile/socket location in this service script because
|
||||
|
@ -55,6 +52,6 @@ reload() {
|
|||
# the server to reload(), so we have to use it here rather
|
||||
# than e.g. sending a signal to the server daemon.
|
||||
ebegin "Reloading ${RC_SVCNAME}"
|
||||
"${FAIL2BAN_BINDIR}/fail2ban-client" ${command_args} reload
|
||||
"@BINDIR@/fail2ban-client" ${command_args} reload
|
||||
eend $? "Failed to reload ${RC_SVCNAME}"
|
||||
}
|
39
setup.py
39
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:
|
||||
|
|
Loading…
Reference in New Issue