From ae98fde32141154e7384bf38a3893ecf162d94ca Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 31 May 2019 09:18:12 +0200 Subject: [PATCH] Try to obtain PID from PIDFILE. If this fails (file does not exist or is empty), fall back to using pidof + awk Signed-off-by: DL6ER --- advanced/Templates/pihole-FTL.service | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/advanced/Templates/pihole-FTL.service b/advanced/Templates/pihole-FTL.service index 7c7e533e..8a4c7ce6 100644 --- a/advanced/Templates/pihole-FTL.service +++ b/advanced/Templates/pihole-FTL.service @@ -13,6 +13,13 @@ FTLUSER=pihole PIDFILE=/var/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)}' }