Also use pkill/pgrep in the FTL service script

Signed-off-by: DL6ER <dl6er@dl6er.de>
pull/3599/head
DL6ER 4 years ago
parent 6ee6eea1fb
commit 17aabf26f7
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD

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

Loading…
Cancel
Save