diff options
author | sarneaud <sarneaud@users.noreply.github.com> | 2015-11-28 15:03:09 +1100 |
---|---|---|
committer | sarneaud <sarneaud@users.noreply.github.com> | 2015-11-28 15:03:09 +1100 |
commit | 5b88a84fe8f86817653ce1f4b5c0e48b80696878 (patch) | |
tree | dab9418f9a0dc188a1eb196ca59efa9c413e2072 /files | |
parent | fe8d585d9161c7a8f90e933bd002a1fa7babb652 (diff) | |
download | fail2ban-5b88a84fe8f86817653ce1f4b5c0e48b80696878.tar.gz |
Small fixes for Gentoo initd script
These fixes are pretty pedantic, but they do simplify the script a
little.
* Checking the existence of a file/directory before creating/deleting
it adds complexity and raciness. There are better options.
* mkdir -p does the job of making sure a directory exists. (It only
fails if there's a filesystem error or something.)
* Likewise, rm -f doesn't fail if the file doesn't exist.
* rm -r isn't neccessary because the socket shouldn't be a directory.
(If it is for some reason, that should be an error.)
Diffstat (limited to 'files')
-rwxr-xr-x | files/gentoo-initd | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/files/gentoo-initd b/files/gentoo-initd index b56d4bdb..98c5edf9 100755 --- a/files/gentoo-initd +++ b/files/gentoo-initd @@ -30,14 +30,10 @@ depend() { start() { ebegin "Starting fail2ban" - if [ ! -d /var/run/fail2ban ]; then - mkdir /var/run/fail2ban || return 1 - fi - if [ -e /var/run/fail2ban/fail2ban.sock ]; then - # remove stalled sock file after system crash - # bug 347477 - rm -rf /var/run/fail2ban/fail2ban.sock || return 1 - fi + 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 ${FAIL2BAN} start &> /dev/null eend $? "Failed to start fail2ban" } |