From 5b88a84fe8f86817653ce1f4b5c0e48b80696878 Mon Sep 17 00:00:00 2001 From: sarneaud Date: Sat, 28 Nov 2015 15:03:09 +1100 Subject: [PATCH] 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.) --- files/gentoo-initd | 12 ++++-------- 1 file 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" }