From 17aabf26f7859600bd3f234530f01c85043c3d59 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 21 Jul 2020 21:19:19 +0200 Subject: [PATCH] Also use pkill/pgrep in the FTL service script Signed-off-by: DL6ER --- advanced/Templates/pihole-FTL.service | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/advanced/Templates/pihole-FTL.service b/advanced/Templates/pihole-FTL.service index 6af449f3..f0743b49 100644 --- a/advanced/Templates/pihole-FTL.service +++ b/advanced/Templates/pihole-FTL.service @@ -12,19 +12,8 @@ FTLUSER=pihole PIDFILE=/run/pihole-FTL.pid -get_pid() { - # First, try to obtain PID from PIDFILE - if [ -s "${PIDFILE}" ]; then - cat "${PIDFILE}" - return - fi - - # If the PIDFILE is empty or not available, obtain the PID using pidof - pidof "pihole-FTL" | awk '{print $(NF)}' -} - is_running() { - ps "$(get_pid)" > /dev/null 2>&1 + pgrep -o "pihole-FTL" > /dev/null 2>&1 } @@ -63,7 +52,7 @@ start() { # Stop the service stop() { if is_running; then - kill "$(get_pid)" + pkill -o pihole-FTL for i in {1..5}; do if ! is_running; then break @@ -76,7 +65,7 @@ stop() { if is_running; then echo "Not stopped; may still be shutting down or shutdown may have failed, killing now" - kill -9 "$(get_pid)" + pkill -o -9 pihole-FTL exit 1 else echo "Stopped"