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.
pull/2182/head
Michael Orlitzky 2018-07-15 13:32:03 -04:00
parent 115024d14a
commit 0b146208eb
1 changed files with 8 additions and 4 deletions

View File

@ -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"