Show IP addresses on control panel about screen

This commit is contained in:
Bob Mottram 2016-10-18 17:47:41 +01:00
parent 3141e45f4f
commit e2a6600128
3 changed files with 20 additions and 3 deletions

View File

@ -66,9 +66,8 @@ function pihole_update {
return return
fi fi
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') IPv4_address=$(get_ipv4_address)
IPv4_address=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}') IPv6_address=$(get_ipv6_address)
IPv6_address=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
setupVars=$piholeDir/setupVars.conf setupVars=$piholeDir/setupVars.conf
echo "piholeInterface=${PIHOLE_IFACE}" > ${setupVars} echo "piholeInterface=${PIHOLE_IFACE}" > ${setupVars}

View File

@ -371,8 +371,17 @@ function show_tahoe_introducer {
echo '' echo ''
} }
function show_ip_addresses {
echo 'IP/DNS addresses'
echo '================'
echo ''
echo "IPv4: $(get_ipv4_address) IPv6: $(get_ipv6_address)"
echo ''
}
function show_about { function show_about {
clear clear
show_ip_addresses
show_domains show_domains
show_mirrors_password show_mirrors_password
show_tahoe_introducer show_tahoe_introducer

View File

@ -87,4 +87,13 @@ function install_static_network {
mark_completed $FUNCNAME mark_completed $FUNCNAME
} }
function get_ipv4_address {
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
echo $(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
}
function get_ipv6_address {
echo $(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
}
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0