mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-03 04:30:55 +00:00
Include port in status function
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
3d3bb45a46
commit
ef30a85afb
81
pihole
81
pihole
@ -312,42 +312,55 @@ analyze_ports() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
statusFunc() {
|
statusFunc() {
|
||||||
# Determine if there is a pihole service is listening on port 53
|
# Determine if there is pihole-FTL service is listening on any UDP port
|
||||||
local listening
|
local listening pid port
|
||||||
listening="$(lsof -Pni:53)"
|
|
||||||
if grep -q "pihole" <<< "${listening}"; then
|
|
||||||
if [[ "${1}" != "web" ]]; then
|
|
||||||
analyze_ports "${listening}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
case "${1}" in
|
|
||||||
"web") echo "-1";;
|
|
||||||
*) echo -e " ${CROSS} DNS service is NOT listening";;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine if Pi-hole's blocking is enabled
|
pid="$(getFTLPID)"
|
||||||
if grep -q "BLOCKING_ENABLED=false" /etc/pihole/setupVars.conf; then
|
if [[ "$pid" -eq "-1" ]]; then
|
||||||
# A config is commented out
|
case "${1}" in
|
||||||
case "${1}" in
|
"web") echo "-1";;
|
||||||
"web") echo 0;;
|
*) echo -e " ${CROSS} DNS service is NOT running";;
|
||||||
*) echo -e " ${CROSS} Pi-hole blocking is disabled";;
|
esac
|
||||||
esac
|
return 0
|
||||||
elif grep -q "BLOCKING_ENABLED=true" /etc/pihole/setupVars.conf; then
|
|
||||||
# Configs are set
|
|
||||||
case "${1}" in
|
|
||||||
"web") echo 1;;
|
|
||||||
*) echo -e " ${TICK} Pi-hole blocking is enabled";;
|
|
||||||
esac
|
|
||||||
else
|
else
|
||||||
# No configs were found
|
#get the port pihole-FTL is listening on
|
||||||
case "${1}" in
|
port="$(lsof -Pni UDP -p ${pid} -a | grep -m1 : | awk -F ":" '{print $2}')"
|
||||||
"web") echo 99;;
|
listening="$(lsof -Pni:53)"
|
||||||
*) echo -e " ${INFO} Pi-hole blocking will be enabled";;
|
if [[ ! -z "$port" ]]; then
|
||||||
esac
|
if [[ "${1}" != "web" ]]; then
|
||||||
# Enable blocking
|
analyze_ports "${listening}"
|
||||||
"${PI_HOLE_BIN_DIR}"/pihole enable
|
fi
|
||||||
|
else
|
||||||
|
case "${1}" in
|
||||||
|
"web") echo "-1";;
|
||||||
|
*) echo -e " ${CROSS} DNS service is NOT listening";;
|
||||||
|
esac
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine if Pi-hole's blocking is enabled
|
||||||
|
if grep -q "BLOCKING_ENABLED=false" /etc/pihole/setupVars.conf; then
|
||||||
|
# A config is commented out
|
||||||
|
case "${1}" in
|
||||||
|
"web") echo 0;;
|
||||||
|
*) echo -e " ${CROSS} Pi-hole blocking is disabled";;
|
||||||
|
esac
|
||||||
|
elif grep -q "BLOCKING_ENABLED=true" /etc/pihole/setupVars.conf; then
|
||||||
|
# Configs are set
|
||||||
|
case "${1}" in
|
||||||
|
"web") echo "$port";;
|
||||||
|
*) echo -e " ${TICK} Pi-hole blocking is enabled";;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# No configs were found
|
||||||
|
case "${1}" in
|
||||||
|
"web") echo -2;;
|
||||||
|
*) echo -e " ${INFO} Pi-hole blocking will be enabled";;
|
||||||
|
esac
|
||||||
|
# Enable blocking
|
||||||
|
"${PI_HOLE_BIN_DIR}"/pihole enable
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user