Compare commits
3 Commits
v5.1
...
fix/simpli
Author | SHA1 | Date | |
---|---|---|---|
|
eaaa0c1f7f | ||
|
cea9205136 | ||
|
0cc1e88608 |
@@ -10,20 +10,14 @@
|
|||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
FTLUSER=pihole
|
FTLUSER=pihole
|
||||||
|
BINARY="/usr/bin/pihole-FTL"
|
||||||
PIDFILE=/var/run/pihole-FTL.pid
|
PIDFILE=/var/run/pihole-FTL.pid
|
||||||
|
|
||||||
get_pid() {
|
. /lib/lsb/init-functions
|
||||||
pidof "pihole-FTL"
|
|
||||||
}
|
|
||||||
|
|
||||||
is_running() {
|
|
||||||
ps "$(get_pid)" > /dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Start the service
|
# Start the service
|
||||||
start() {
|
start() {
|
||||||
if is_running; then
|
if pidofproc -p "${PIDFILE}" > /dev/null 2>&1; then
|
||||||
echo "pihole-FTL is already running"
|
echo "pihole-FTL is already running"
|
||||||
else
|
else
|
||||||
# Touch files to ensure they exist (create if non-existing, preserve if existing)
|
# Touch files to ensure they exist (create if non-existing, preserve if existing)
|
||||||
@@ -43,10 +37,10 @@ start() {
|
|||||||
chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log
|
chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log
|
||||||
echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.piholeFTL
|
echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.piholeFTL
|
||||||
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN+eip "$(which pihole-FTL)"; then
|
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN+eip "$(which pihole-FTL)"; then
|
||||||
su -s /bin/sh -c "/usr/bin/pihole-FTL" "$FTLUSER"
|
start_daemon -p "${PIDFILE}" /usr/bin/su -s /bin/sh -c "${BINARY} -f" "$FTLUSER" &
|
||||||
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"
|
||||||
pihole-FTL
|
start_daemon -p "${PIDFILE}" "${BINARY}" -f &
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
@@ -54,11 +48,11 @@ start() {
|
|||||||
|
|
||||||
# Stop the service
|
# Stop the service
|
||||||
stop() {
|
stop() {
|
||||||
if is_running; then
|
if pidofproc -p "${PIDFILE}" > /dev/null 2>&1; then
|
||||||
/sbin/resolvconf -d lo.piholeFTL
|
/sbin/resolvconf -d lo.piholeFTL
|
||||||
kill "$(get_pid)"
|
killproc -p "${PIDFILE}" "${BINARY}"
|
||||||
for i in {1..5}; do
|
for i in {1..5}; do
|
||||||
if ! is_running; then
|
if ! pidofproc -p "${PIDFILE}" > /dev/null 2>&1; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -67,9 +61,9 @@ stop() {
|
|||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if is_running; then
|
if pidofproc -p "${PIDFILE}" > /dev/null 2>&1; 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)"
|
killproc -p "${PIDFILE}" "${BINARY}" 9
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Stopped"
|
echo "Stopped"
|
||||||
@@ -82,7 +76,7 @@ stop() {
|
|||||||
|
|
||||||
# Indicate the service status
|
# Indicate the service status
|
||||||
status() {
|
status() {
|
||||||
if is_running; then
|
if pidofproc -p "${PIDFILE}" > /dev/null 2>&1; then
|
||||||
echo "[ ok ] pihole-FTL is running"
|
echo "[ ok ] pihole-FTL is running"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user