mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #4319 from pi-hole/development
Sync Dev -> release/v5.4
This commit is contained in:
commit
2feea70311
3 changed files with 17 additions and 38 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: pihole-FTL
|
# Provides: pihole-FTL
|
||||||
# Required-Start: $remote_fs $syslog $network
|
# Required-Start: $remote_fs $syslog $network
|
||||||
|
@ -9,11 +9,8 @@
|
||||||
# Description: Enable service provided by pihole-FTL daemon
|
# Description: Enable service provided by pihole-FTL daemon
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
FTLUSER=pihole
|
|
||||||
PIDFILE=/run/pihole-FTL.pid
|
|
||||||
|
|
||||||
is_running() {
|
is_running() {
|
||||||
pgrep -o "pihole-FTL" > /dev/null 2>&1
|
pgrep -xo "pihole-FTL" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,28 +20,18 @@ start() {
|
||||||
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)
|
||||||
touch /var/log/pihole-FTL.log /var/log/pihole.log
|
mkdir -pm 0755 /run/pihole
|
||||||
touch /run/pihole-FTL.pid /run/pihole-FTL.port
|
touch /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole-FTL.log /var/log/pihole.log /etc/pihole/dhcp.leases
|
||||||
touch /etc/pihole/dhcp.leases
|
|
||||||
mkdir -p /run/pihole
|
|
||||||
mkdir -p /var/log/pihole
|
|
||||||
chown pihole:pihole /run/pihole /var/log/pihole
|
|
||||||
# Remove possible leftovers from previous pihole-FTL processes
|
|
||||||
rm -f /dev/shm/FTL-* 2> /dev/null
|
|
||||||
rm /run/pihole/FTL.sock 2> /dev/null
|
|
||||||
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
|
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
|
||||||
chown pihole:pihole /run/pihole-FTL.pid /run/pihole-FTL.port
|
chown pihole:pihole /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole-FTL.log /var/log/pihole.log /etc/pihole/dhcp.leases /run/pihole /etc/pihole
|
||||||
chown pihole:pihole /etc/pihole /etc/pihole/dhcp.leases 2> /dev/null
|
chmod 0644 /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole-FTL.log /var/log/pihole.log /etc/pihole/dhcp.leases /etc/pihole/macvendor.db
|
||||||
chown pihole:pihole /var/log/pihole-FTL.log /var/log/pihole.log
|
|
||||||
chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole.log
|
|
||||||
chmod 0644 /etc/pihole/macvendor.db
|
|
||||||
# Chown database files to the user FTL runs as. We ignore errors as the files may not (yet) exist
|
# Chown database files to the user FTL runs as. We ignore errors as the files may not (yet) exist
|
||||||
chown pihole:pihole /etc/pihole/pihole-FTL.db /etc/pihole/gravity.db /etc/pihole/macvendor.db 2> /dev/null
|
chown -f pihole:pihole /etc/pihole/pihole-FTL.db /etc/pihole/gravity.db /etc/pihole/macvendor.db
|
||||||
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_IPC_LOCK,CAP_CHOWN+eip "$(which 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" "$FTLUSER"
|
su -s /bin/sh -c "/usr/bin/pihole-FTL" pihole
|
||||||
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
|
/usr/bin/pihole-FTL
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
@ -53,20 +40,20 @@ start() {
|
||||||
# Stop the service
|
# Stop the service
|
||||||
stop() {
|
stop() {
|
||||||
if is_running; then
|
if is_running; then
|
||||||
pkill -o pihole-FTL
|
pkill -xo "pihole-FTL"
|
||||||
for i in {1..5}; do
|
for i in 1 2 3 4 5; do
|
||||||
if ! is_running; then
|
if ! is_running; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "."
|
printf "."
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
|
|
||||||
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"
|
||||||
pkill -o -9 pihole-FTL
|
pkill -xo -9 "pihole-FTL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Stopped"
|
echo "Stopped"
|
||||||
|
@ -74,6 +61,8 @@ stop() {
|
||||||
else
|
else
|
||||||
echo "Not running"
|
echo "Not running"
|
||||||
fi
|
fi
|
||||||
|
# Cleanup
|
||||||
|
rm -f /run/pihole/FTL.sock /dev/shm/FTL-*
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +91,7 @@ case "$1" in
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|restart|reload|status}"
|
echo "Usage: $0 {start|stop|restart|reload|status}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -78,11 +78,6 @@ $HTTP["url"] =~ "^/admin/" {
|
||||||
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
||||||
"X-Frame-Options" => "DENY"
|
"X-Frame-Options" => "DENY"
|
||||||
)
|
)
|
||||||
|
|
||||||
$HTTP["url"] =~ "\.(eot|otf|tt[cf]|woff2?)$" {
|
|
||||||
# Allow Block Page access to local fonts
|
|
||||||
setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Block . files from being served, such as .git, .github, .gitignore
|
# Block . files from being served, such as .git, .github, .gitignore
|
||||||
|
|
|
@ -86,11 +86,6 @@ $HTTP["url"] =~ "^/admin/" {
|
||||||
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
||||||
"X-Frame-Options" => "DENY"
|
"X-Frame-Options" => "DENY"
|
||||||
)
|
)
|
||||||
|
|
||||||
$HTTP["url"] =~ "\.(eot|otf|tt[cf]|woff2?)$" {
|
|
||||||
# Allow Block Page access to local fonts
|
|
||||||
setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Block . files from being served, such as .git, .github, .gitignore
|
# Block . files from being served, such as .git, .github, .gitignore
|
||||||
|
|
Loading…
Reference in a new issue