FTL_pid=$(pidof ${resolver})
FTL_pid2=$(pgrep -f ${resolver})
echo "FTL pid with pidof (/opt/pihole/gravity.sh): ${FTL_pid}"
echo "FTL pid with pgrep (/opt/pihole/gravity.sh): ${FTL_pid2}"
output:
[i] Swapping databases...
e[K [✓] Swapping databases
[i] Number of gravity domains: 2180799 (1573528 unique domains)
[i] Number of exact blacklisted domains: 0
[i] Number of regex blacklist filters: 34
[i] Number of exact whitelisted domains: 44
[i] Number of regex whitelist filters: 2
FTL pid with pidof (/usr/local/bin/pihole): 18055
FTL pid with pgrep (/usr/local/bin/pihole): 18055
path: /usr/bin:/bin:/usr/local/bin/
choice: killall
[i] Cleaning up stray matter...
e[K [✓] Cleaning up stray matter
FTL pid with pidof (/opt/pihole/gravity.sh):
FTL pid with pgrep (/opt/pihole/gravity.sh): 18055
FTL pid with pidof (/usr/local/bin/pihole):
FTL pid with pgrep (/usr/local/bin/pihole): 18055
path: /usr/bin:/bin:/usr/local/bin/
choice: service
[✗] /usr/local/bin/pihole: line 138: service: command not found
[✓] DNS service is running
One step closer to the cause of using service.
This doesn't change the fact the script cannot find service, due to the missing /usr/sbin.
Special thanks to @jpgpi250 and @yubiuser for nailing this down and discovering the real issue (pidof failing) which was initially hidden behind another one (service failed to run even when it should not have been used in the first place).
One quick question: pidof is also used in gravity.sh. Since pidof appears to be unreliable, why isn't this also changed into pgrep? As indicated in the test results, it also fails to provide the correct result in that script.
Thanks to all users and developers, who have contributed to solve this problem...
PIDFILE is only used in the section you are removing (avoid confusion in the near future).
edit
applied all 4 changed files to my system, no problems detected (ran pihole -g, updategravity, using cron, sudo service pihole-FTL - all options tested and pihole restartdns - all options tested)
/edit