summaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorMichael Orlitzky <michael@orlitzky.com>2018-07-15 13:32:03 -0400
committerMichael Orlitzky <michael@orlitzky.com>2018-07-15 13:35:35 -0400
commit0b146208eb3a6f3ceb04d59e9e89c1cc914854ea (patch)
tree526281611745f0144d5c7a3b023de54d89b3e79d /files
parent115024d14a0b1a5a4b96175712f257b408883f38 (diff)
downloadfail2ban-0b146208eb3a6f3ceb04d59e9e89c1cc914854ea.tar.gz
files/fail2ban-openrc.init: move pre-flight checks into start_pre().
Our OpenRC service script performs two tasks before starting the service: 1. It removes any stake sockets (from e.g. a system crash). 2. It ensures that the PID file directory exists. These have both been moved into the "start_pre" phase, which is designed to do such things (and will allow us to simplify the "start" phase in the future). The existing "mkdir -p" has also been converted into a "checkpath -d" command which is built-in to OpenRC.
Diffstat (limited to 'files')
-rwxr-xr-xfiles/fail2ban-openrc.init12
1 files changed, 8 insertions, 4 deletions
diff --git a/files/fail2ban-openrc.init b/files/fail2ban-openrc.init
index 9969a3e0..e1cf5273 100755
--- a/files/fail2ban-openrc.init
+++ b/files/fail2ban-openrc.init
@@ -32,12 +32,16 @@ depend() {
after iptables
}
+start_pre() {
+ checkpath -d "${pidfile%/*}" || return 1
+
+ # Remove stale socket after system crash, Gentoo bug 347477
+ rm -f /var/run/fail2ban/fail2ban.sock || return 1
+}
+
start() {
ebegin "Starting fail2ban"
- mkdir -p /var/run/fail2ban || return 1
- # remove stalled sock file after system crash
- # bug 347477
- rm -f /var/run/fail2ban/fail2ban.sock || return 1
+
start-stop-daemon --start --pidfile "${pidfile}" \
-- ${command} ${command_args} start
eend $? "Failed to start fail2ban"