From b294805a2295e91844144d2af1a2f70e16d3e4ec Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 27 May 2020 10:56:43 +0200 Subject: [PATCH] Provide more detailed network information * Display information about all configured IP addresses (excluding localhost) * Display SSH information whenever sshd process is running, since boot option ssh might isn't strictly necessary (boot option services=ssh or a custom netscript might start it as well as a customized Grml ISO) * Display zeroconf hostname information (when service avahi-daemon is running and avahi-resolve-address is available) Closes: grml/grml-quickconfig#1 --- quickconfig/002-ipaddr.sh | 83 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 17 deletions(-) diff --git a/quickconfig/002-ipaddr.sh b/quickconfig/002-ipaddr.sh index c7cc3c8..41248bb 100644 --- a/quickconfig/002-ipaddr.sh +++ b/quickconfig/002-ipaddr.sh @@ -1,26 +1,75 @@ -ROOTPWD=$(grep -Eo '\/dev/null | awk '{print $2}')" + if [ -n "${AVAHI_INFO:-}" ] ; then + LINE+="print_line '-> Hostname: ${AVAHI_INFO}';" + NETINFO_PRESENT=true fi +fi - LINE='print_line "You can connect with SSH to: $IPADDR $IPADDR6"; -print_line "The password for user root/$USER is: $ROOTPWD"; - print_delim; -' +# list all non-localhost IP addresses +declare -a IP_LIST +for ip in $( + { + ip -4 -o addr show | grep ' inet ' | sed -e 's/.*inet \([^ ]*\) .*/\1/' -e 's/\/.*//' + ip -6 -o addr show | grep ' inet6 ' | sed -e 's/.*inet6 \([^ ]*\) .*/\1/' -e 's/\/.*//' + } | sort -u) ; do + case "${ip}" in + 127.0.0.*) + continue + ;; + ::1) + continue + ;; + fe80::*) + continue + ;; + *) + LINE+="print_line '-> IP address: $ip';" + NETINFO_PRESENT=true + ;; + esac +done + +if [ "${NETINFO_PRESENT}" = "false" ] ; then + LINE+="print_line '-> network seems to be unconfigured (yet)';" fi -display_entry() { return 0; } +LINE+='print_delim;' +display_entry() { return 0; } -- 2.1.4