From dea159a596dec302a680a3051ffe2cd8af12913e Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Sun, 23 Mar 2025 20:12:12 +0100 Subject: [PATCH] Introduce HIDE_LOCAL_IPV6 which removes all local ipv6 addressed from display --- packages/bsp/common/etc/default/armbian-motd.dpkg-dist | 1 + .../bsp/common/etc/update-motd.d/10-armbian-header | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/bsp/common/etc/default/armbian-motd.dpkg-dist b/packages/bsp/common/etc/default/armbian-motd.dpkg-dist index 00e19cc46..8f0b0a17f 100644 --- a/packages/bsp/common/etc/default/armbian-motd.dpkg-dist +++ b/packages/bsp/common/etc/default/armbian-motd.dpkg-dist @@ -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 diff --git a/packages/bsp/common/etc/update-motd.d/10-armbian-header b/packages/bsp/common/etc/update-motd.d/10-armbian-header index 0c14586e9..07a4967c1 100755 --- a/packages/bsp/common/etc/update-motd.d/10-armbian-header +++ b/packages/bsp/common/etc/update-motd.d/10-armbian-header @@ -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: " - all_ip6_address+="\x1B[96m${ipv6s// /, }\x1B[0m " + 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