mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Cleanup if startup failed
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
a4e20f79a3
commit
f713b14ba0
@ -23,6 +23,11 @@ is_running() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
# Run post-stop script, which does cleanup among runtime files
|
||||||
|
sh "${PI_HOLE_SCRIPT_DIR}/pihole-FTL-poststop.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Start the service
|
# Start the service
|
||||||
start() {
|
start() {
|
||||||
@ -33,10 +38,15 @@ start() {
|
|||||||
sh "${PI_HOLE_SCRIPT_DIR}/pihole-FTL-prestart.sh"
|
sh "${PI_HOLE_SCRIPT_DIR}/pihole-FTL-prestart.sh"
|
||||||
|
|
||||||
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_IPC_LOCK,CAP_CHOWN+eip "/usr/bin/pihole-FTL"; then
|
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_IPC_LOCK,CAP_CHOWN+eip "/usr/bin/pihole-FTL"; then
|
||||||
su -s /bin/sh -c "/usr/bin/pihole-FTL" pihole || exit $?
|
su -s /bin/sh -c "/usr/bin/pihole-FTL" pihole || ec=$?
|
||||||
else
|
else
|
||||||
echo "Warning: Starting pihole-FTL as root because setting capabilities is not supported on this system"
|
echo "Warning: Starting pihole-FTL as root because setting capabilities is not supported on this system"
|
||||||
/usr/bin/pihole-FTL || exit $?
|
/usr/bin/pihole-FTL || ec=$?
|
||||||
|
fi
|
||||||
|
# Cleanup if startup failed
|
||||||
|
if [ -n "${ec}" ] && [ "${ec}" != 0 ]; then
|
||||||
|
cleanup
|
||||||
|
exit $ec
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
@ -65,8 +75,7 @@ stop() {
|
|||||||
else
|
else
|
||||||
echo "Not running"
|
echo "Not running"
|
||||||
fi
|
fi
|
||||||
# Run post-stop script, which does cleanup among runtime files
|
cleanup
|
||||||
sh "${PI_HOLE_SCRIPT_DIR}/pihole-FTL-poststop.sh"
|
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +93,9 @@ status() {
|
|||||||
|
|
||||||
### main logic ###
|
### main logic ###
|
||||||
|
|
||||||
|
# catch sudden termination
|
||||||
|
trap 'cleanup; exit 1' INT HUP TERM ABRT
|
||||||
|
|
||||||
# Get FTL's PID file path
|
# Get FTL's PID file path
|
||||||
FTL_PID_FILE="$(getFTLPIDFile)"
|
FTL_PID_FILE="$(getFTLPIDFile)"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user