1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 14:58:08 +00:00

Also use pkill/pgrep in the FTL service script

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2020-07-21 21:19:19 +02:00
parent 6ee6eea1fb
commit 17aabf26f7
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD

View File

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