Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ipv6 addresses if present and sort ips #7299

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion packages/bsp/common/etc/update-motd.d/30-armbian-sysinfo
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,29 @@ function get_ip_addresses() {
[[ -n $tmp ]] && ips+=("$tmp")
fi
done
ips=($(printf "%s\n" "${ips[@]}" | sort -n))
echo "${ips[@]}"
} # get_ip_addresses

function get_ipv6_addresses() {
local ips=()
for f in /sys/class/net/*; do
local intf=$(basename $f)
# match only interface names "dummy0" and "lo"
if [[ $intf =~ $HIDE_IP_PATTERN ]]; then
continue
else
local tmp=$(ip -6 addr show dev $intf | grep -v "$intf:avahi" | awk '/inet6/ {print $2}' | cut -d'/' -f1 | grep -v "^fe80:" | uniq)
# add both name and IP - can be informative but becomes ugly with long persistent/predictable device names
#[[ -n $tmp ]] && ips+=("$intf: $tmp")
# add IP only
[[ -n $tmp ]] && ips+=("$tmp")
fi
done
ips=($(printf "%s\n" "${ips[@]}" | sort -n))
echo "${ips[@]}"
} # get_ipv6_addresses

function storage_info() {
# storage info
RootInfo=$(df -h /)
Expand All @@ -95,6 +115,7 @@ function storage_info() {
# Works only with ambienttemp and batteryinfo since A20 is slow enough :)
amb_temp=$(ambienttemp &)
ip_address=$(get_ip_addresses &)
ipv6_address=$(get_ipv6_addresses &)
wan_ip_address=$(get_wan_address &)
batteryinfo
storage_info
Expand Down Expand Up @@ -133,8 +154,11 @@ swap_total=$(awk '{print $(2)}' <<<${swap_info})

#echo ""
echo -en " IP addresses: \x1B[93m(LAN)\x1B[0m \x1B[92m$ip_address\x1B[0m "
if [[ -n $ipv6_address ]]; then
echo -e "\x1B[92m$ipv6_address\x1B[0m "
fi
if [[ -n $wan_ip_address ]]; then
echo -e "\x1B[93m(WAN)\x1B[0m $wan_ip_address"
echo -e "\x1B[93m(WAN)\x1B[0m $wan_ip_address"
fi
echo ""
printf "\e[0;90m Performance: \x1B[0m"
Expand Down Expand Up @@ -219,3 +243,4 @@ if [[ $(command -v zpool) ]]; then
fi
fi
echo ""