Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/pihole
diff options
context:
space:
mode:
authorChristian König <ckoenig@posteo.de>2021-12-26 19:10:48 +0300
committerChristian König <ckoenig@posteo.de>2021-12-26 19:10:48 +0300
commitef30a85afb1653df4d3ce393dd6b8d7ecbb29ab0 (patch)
treeb6012e5b4ab84cae6ac1b538dfb8ec41cbf8c2c9 /pihole
parent3d3bb45a464d94e7f726a865c40f41502a9ea4c0 (diff)
Include port in status function
Signed-off-by: Christian König <ckoenig@posteo.de>
Diffstat (limited to 'pihole')
-rwxr-xr-xpihole81
1 files changed, 47 insertions, 34 deletions
diff --git a/pihole b/pihole
index 055bd702..faa9fc2e 100755
--- a/pihole
+++ b/pihole
@@ -312,42 +312,55 @@ analyze_ports() {
}
statusFunc() {
- # Determine if there is a pihole service is listening on port 53
- local listening
- listening="$(lsof -Pni:53)"
- if grep -q "pihole" <<< "${listening}"; then
- if [[ "${1}" != "web" ]]; then
- analyze_ports "${listening}"
- fi
+ # Determine if there is pihole-FTL service is listening on any UDP port
+ local listening pid port
+
+ pid="$(getFTLPID)"
+ if [[ "$pid" -eq "-1" ]]; then
+ case "${1}" in
+ "web") echo "-1";;
+ *) echo -e " ${CROSS} DNS service is NOT running";;
+ esac
+ return 0
else
- case "${1}" in
- "web") echo "-1";;
- *) echo -e " ${CROSS} DNS service is NOT listening";;
- esac
- return 0
- fi
+ #get the port pihole-FTL is listening on
+ port="$(lsof -Pni UDP -p ${pid} -a | grep -m1 : | awk -F ":" '{print $2}')"
+ listening="$(lsof -Pni:53)"
+ if [[ ! -z "$port" ]]; 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
+ 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
- # 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 1;;
- *) echo -e " ${TICK} Pi-hole blocking is enabled";;
- esac
- else
- # No configs were found
- case "${1}" in
- "web") echo 99;;
- *) echo -e " ${INFO} Pi-hole blocking will be enabled";;
- esac
- # Enable blocking
- "${PI_HOLE_BIN_DIR}"/pihole enable
fi
}