mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-01-25 22:09:49 +00:00
add detect IP function
This commit is contained in:
parent
8c5c1316dd
commit
8fd9a22d18
1 changed files with 29 additions and 4 deletions
|
@ -234,6 +234,31 @@ processor_check() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detect_ip_addresses() {
|
||||||
|
# First argument should be a 4 or a 6
|
||||||
|
local protocol=${1}
|
||||||
|
# Use ip to show the addresses for the chosen protocol
|
||||||
|
# Store the values in an arry so they can be looped through
|
||||||
|
# Get the lines that are in the file(s) and store them in an array for parsing later
|
||||||
|
declare -a ip_addr_list=( $(ip -${protocol} addr show dev ${PIHOLE_INTERFACE} | awk -F ' ' '{ for(i=1;i<=NF;i++) if ($i ~ '/^inet/') print $(i+1) }') )
|
||||||
|
|
||||||
|
# If there is something in the IP address list,
|
||||||
|
if [[ -n ${ip_addr_list} ]]; then
|
||||||
|
# Local iterator
|
||||||
|
local i
|
||||||
|
echo -e " ${INFO} IPv${protocol}"
|
||||||
|
# display the contents to the user
|
||||||
|
echo -e " ${INFO} Interface: ${PIHOLE_INTERFACE}"
|
||||||
|
for i in "${ip_addr_list[@]}"; do
|
||||||
|
echo -e " ${INFO} $i"
|
||||||
|
done
|
||||||
|
# Othwerwise explain that the protocol is not configured
|
||||||
|
else
|
||||||
|
echo -e " ${CROSS} No IPv${protocol} found on ${PIHOLE_INTERFACE}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
parse_file() {
|
parse_file() {
|
||||||
# Set the first argument passed to tihs function as a named variable for better readability
|
# Set the first argument passed to tihs function as a named variable for better readability
|
||||||
local filename="${1}"
|
local filename="${1}"
|
||||||
|
@ -260,8 +285,8 @@ diagnose_setup_variables() {
|
||||||
# If the variable file exists,
|
# If the variable file exists,
|
||||||
file_exists "${VARSFILE}" && \
|
file_exists "${VARSFILE}" && \
|
||||||
# source it
|
# source it
|
||||||
echo -e " ${INFO} Sourcing ${VARSFILE}...";
|
|
||||||
source ${VARSFILE};
|
source ${VARSFILE};
|
||||||
|
echo -e " ${INFO} Sourcing ${VARSFILE}...";
|
||||||
# and display a green check mark with ${DONE}
|
# and display a green check mark with ${DONE}
|
||||||
echo_succes_or_fail "${VARSFILE} is readable and has been sourced." || \
|
echo_succes_or_fail "${VARSFILE} is readable and has been sourced." || \
|
||||||
# Othwerwise, error out
|
# Othwerwise, error out
|
||||||
|
@ -316,8 +341,8 @@ initiate_debug
|
||||||
check_core_version
|
check_core_version
|
||||||
check_web_version
|
check_web_version
|
||||||
check_ftl_version
|
check_ftl_version
|
||||||
|
diagnose_setup_variables
|
||||||
diagnose_operating_system
|
diagnose_operating_system
|
||||||
processor_check
|
processor_check
|
||||||
check_critical_dependencies
|
check_critical_dependencies
|
||||||
diagnose_setup_variables
|
|
||||||
check_dnsmasq_d
|
check_dnsmasq_d
|
||||||
|
|
Loading…
Add table
Reference in a new issue