Introduce HIDE_LOCAL_IPV6 which removes all local ipv6 addressed from display

This commit is contained in:
Igor Pecovnik
2025-03-23 20:12:12 +01:00
committed by Igor
parent 1ee5216a69
commit dea159a596
2 changed files with 9 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
MOTD_DISABLE="clear"
ONE_WIRE=""
HIDE_IP_PATTERN="^dummy0|^lo|^docker|^hassio|^br-|^veth|^vnet|^virbr"
HIDE_LOCAL_IPV6="true"
PRIMARY_INTERFACE="$(ip route | grep '^default' | sed "s/.*dev //" | cut -d" " -f1)"
PRIMARY_DIRECTION="rx"
STORAGE=/dev/sda1

View File

@@ -12,6 +12,7 @@
THIS_SCRIPT="header"
MOTD_DISABLE=""
HIDE_IP_PATTERN="^dummy0|^lo|^docker|^hassio|^br-|^veth|^vnet|^virbr"
HIDE_LOCAL_IPV6="true"
# Read image configuration
[[ -f /etc/armbian-image-release ]] && . /etc/armbian-image-release
@@ -85,6 +86,9 @@ function get_ip_addresses() {
ipv4=$(echo "${ipv4}" | cut -d'/' -f1)
ipv4=$(echo "${ipv4}" | awk '!x[$0]++')
ipv6=$(ip -6 addr show dev "${intf}")
if [[ "${HIDE_LOCAL_IPV6}" == true ]]; then
ipv6=$(ip -6 addr show dev "${intf}" | grep -v fe80)
fi
ipv6=$(echo "${ipv6}" | grep -v "${intf}:avahi")
ipv6=$(echo "${ipv6}" | awk '/inet6/ {print $2}')
ipv6=$(echo "${ipv6}" | cut -d'/' -f1)
@@ -206,9 +210,11 @@ if [[ -n "${wan_ip6_address}" && "${ipv6s}" == *${wan_ip6_address}* ]]; then
ipv6s=$(echo $ipv6s | sed "s/"${wan_ip6_address}"//g" | xargs )
fi
if [[ -n ${ipv6s} ]]; then
if [[ -n ${ipv6s} || -n ${wan_ip6_address} ]]; then
all_ip6_address=" IPv6: "
if [[ -n ${ipv6s} ]]; then
all_ip6_address+="\x1B[96m${ipv6s// /, }\x1B[0m "
fi
if [[ -n ${wan_ip6_address} ]]; then
all_ip6_address+="\x1B[93m(WAN)\x1B[0m \x1B[95m${wan_ip6_address}\x1B[0m "
fi