mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 23:08:07 +00:00
Merge pull request #3599 from pi-hole/fix/gravity_cronjob
Fix for gravity cronjob
This commit is contained in:
commit
61616b8c86
@ -12,19 +12,8 @@
|
|||||||
FTLUSER=pihole
|
FTLUSER=pihole
|
||||||
PIDFILE=/run/pihole-FTL.pid
|
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() {
|
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 the service
|
||||||
stop() {
|
stop() {
|
||||||
if is_running; then
|
if is_running; then
|
||||||
kill "$(get_pid)"
|
pkill -o pihole-FTL
|
||||||
for i in {1..5}; do
|
for i in {1..5}; do
|
||||||
if ! is_running; then
|
if ! is_running; then
|
||||||
break
|
break
|
||||||
@ -76,7 +65,7 @@ stop() {
|
|||||||
|
|
||||||
if is_running; then
|
if is_running; then
|
||||||
echo "Not stopped; may still be shutting down or shutdown may have failed, killing now"
|
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
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Stopped"
|
echo "Stopped"
|
||||||
|
@ -18,19 +18,19 @@
|
|||||||
# early morning. Download any updates from the adlists
|
# early morning. Download any updates from the adlists
|
||||||
# Squash output to log, then splat the log to stdout on error to allow for
|
# Squash output to log, then splat the log to stdout on error to allow for
|
||||||
# standard crontab job error handling.
|
# standard crontab job error handling.
|
||||||
59 1 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log
|
59 1 * * 7 root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log
|
||||||
|
|
||||||
# Pi-hole: Flush the log daily at 00:00
|
# Pi-hole: Flush the log daily at 00:00
|
||||||
# The flush script will use logrotate if available
|
# The flush script will use logrotate if available
|
||||||
# parameter "once": logrotate only once (default is twice)
|
# parameter "once": logrotate only once (default is twice)
|
||||||
# parameter "quiet": don't print messages
|
# parameter "quiet": don't print messages
|
||||||
00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush once quiet
|
00 00 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole flush once quiet
|
||||||
|
|
||||||
@reboot root /usr/sbin/logrotate /etc/pihole/logrotate
|
@reboot root /usr/sbin/logrotate /etc/pihole/logrotate
|
||||||
|
|
||||||
# Pi-hole: Grab local version and branch every 10 minutes
|
# Pi-hole: Grab local version and branch every 10 minutes
|
||||||
*/10 * * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker local
|
*/10 * * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker local
|
||||||
|
|
||||||
# Pi-hole: Grab remote version every 24 hours
|
# Pi-hole: Grab remote version every 24 hours
|
||||||
59 17 * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote
|
59 17 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker remote
|
||||||
@reboot root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote reboot
|
@reboot root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updatechecker remote reboot
|
||||||
|
@ -43,8 +43,6 @@ optimize_database=false
|
|||||||
|
|
||||||
domainsExtension="domains"
|
domainsExtension="domains"
|
||||||
|
|
||||||
resolver="pihole-FTL"
|
|
||||||
|
|
||||||
# Source setupVars from install script
|
# Source setupVars from install script
|
||||||
setupVars="${piholeDir}/setupVars.conf"
|
setupVars="${piholeDir}/setupVars.conf"
|
||||||
if [[ -f "${setupVars}" ]];then
|
if [[ -f "${setupVars}" ]];then
|
||||||
@ -284,7 +282,7 @@ gravity_CheckDNSResolutionAvailable() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine error output message
|
# Determine error output message
|
||||||
if pidof ${resolver} &> /dev/null; then
|
if pgrep pihole-FTL &> /dev/null; then
|
||||||
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} DNS service is not running"
|
echo -e " ${CROSS} DNS service is not running"
|
||||||
@ -746,7 +744,7 @@ gravity_Cleanup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Only restart DNS service if offline
|
# Only restart DNS service if offline
|
||||||
if ! pidof ${resolver} &> /dev/null; then
|
if ! pgrep pihole-FTL &> /dev/null; then
|
||||||
"${PIHOLE_COMMAND}" restartdns
|
"${PIHOLE_COMMAND}" restartdns
|
||||||
dnsWasOffline=true
|
dnsWasOffline=true
|
||||||
fi
|
fi
|
||||||
|
10
pihole
10
pihole
@ -20,8 +20,6 @@ PI_HOLE_BIN_DIR="/usr/local/bin"
|
|||||||
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
|
readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE"
|
||||||
source "${colfile}"
|
source "${colfile}"
|
||||||
|
|
||||||
resolver="pihole-FTL"
|
|
||||||
|
|
||||||
webpageFunc() {
|
webpageFunc() {
|
||||||
source "${PI_HOLE_SCRIPT_DIR}/webpage.sh"
|
source "${PI_HOLE_SCRIPT_DIR}/webpage.sh"
|
||||||
main "$@"
|
main "$@"
|
||||||
@ -107,19 +105,19 @@ restartDNS() {
|
|||||||
# Determine if we should reload or restart
|
# Determine if we should reload or restart
|
||||||
if [[ "${svcOption}" =~ "reload-lists" ]]; then
|
if [[ "${svcOption}" =~ "reload-lists" ]]; then
|
||||||
# Reloading of the lists has been requested
|
# Reloading of the lists has been requested
|
||||||
# Note: This will NOT re-read any *.conf files
|
# Note 1: This will NOT re-read any *.conf files
|
||||||
# Note 2: We cannot use killall here as it does
|
# Note 2: We cannot use killall here as it does
|
||||||
# not know about real-time signals
|
# not know about real-time signals
|
||||||
svc="kill -SIGRTMIN $(pidof ${resolver})"
|
svc="pkill -RTMIN pihole-FTL"
|
||||||
str="Reloading DNS lists"
|
str="Reloading DNS lists"
|
||||||
elif [[ "${svcOption}" =~ "reload" ]]; then
|
elif [[ "${svcOption}" =~ "reload" ]]; then
|
||||||
# Reloading of the DNS cache has been requested
|
# Reloading of the DNS cache has been requested
|
||||||
# Note: This will NOT re-read any *.conf files
|
# Note: This will NOT re-read any *.conf files
|
||||||
svc="killall -s SIGHUP ${resolver}"
|
svc="pkill -HUP pihole-FTL"
|
||||||
str="Flushing DNS cache"
|
str="Flushing DNS cache"
|
||||||
else
|
else
|
||||||
# A full restart has been requested
|
# A full restart has been requested
|
||||||
svc="service ${resolver} restart"
|
svc="service pihole-FTL restart"
|
||||||
str="Restarting DNS server"
|
str="Restarting DNS server"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user