1 # always try to gather network information
2 LOCAL_IF=$(ip -o route show | sed -nre '/^default /s/^default .*dev ([^ ]+).*/\1/p' | head -1)
3 if [ -n "${LOCAL_IF}" ] ; then
4 IPADDR=$(ip -o addr show "${LOCAL_IF}" | grep ' inet ' | head -n 1 | sed -e 's/.*inet \([^ ]*\) .*/\1/' -e 's/\/.*//')
7 LOCAL_IF6=$(ip -6 -o route show | sed -nre '/^default /s/^default .*dev ([^ ]+).*/\1/p' | head -1)
8 if [ -n "${LOCAL_IF6}" ] ; then
9 IPADDR6=$(ip -6 -o addr show "${LOCAL_IF6}" | grep ' inet6 ' | head -n 1 | sed -e 's/.*inet6 \([^ ]*\) .*/\1/' -e 's/\/.*//')
12 # ssh / password information
13 SSHD_PID=$(pgrep sshd || true)
14 SSH_OPTION=$(grep -Eo '\<ssh=[^ ]+' /proc/cmdline || true)
15 PWD_OPTION=$(grep -Eo '\<passwd=[^ ]+' /proc/cmdline || true)
17 if [ -n "${SSHD_PID:-}" ] ; then
18 LINE+="print_line 'You can connect with SSH to: ${IPADDR:-} ${IPADDR6:-} ${AVAHI_INFO:-}';"
21 USER=$(getent passwd 1000 | cut -d: -f1)
22 [ -n "${USER:-}" ] || USER="grml"
23 if [ -n "${PWD_OPTION:-}" ] ; then
24 PWD_OPTION=${PWD_OPTION#*=}
25 LINE+="print_line 'The password for user root/${USER} is: ${PWD_OPTION:-}';"
26 elif [ -n "${SSH_OPTION:-}" ] ; then
27 SSH_OPTION=${SSH_OPTION#*=}
28 LINE+="print_line 'The password for user root/${USER} is: ${SSH_OPTION:-}';"
31 LINE+="print_line 'Network information:';"
35 # zeroconf information
36 AVAHI_PID=$(pgrep avahi-daemon || true)
37 if [ -n "${AVAHI_PID:-}" ] && [ -x "$(which avahi-resolve-address)" ] && [ -n "${IPADDR:-}" ] ; then
38 AVAHI_INFO="$(avahi-resolve-address "${IPADDR}" 2>/dev/null | awk '{print $2}')"
39 if [ -n "${AVAHI_INFO:-}" ] ; then
40 LINE+="print_line '-> Hostname: ${AVAHI_INFO}';"
45 # list all non-localhost IP addresses
49 ip -4 -o addr show | grep ' inet ' | sed -e 's/.*inet \([^ ]*\) .*/\1/' -e 's/\/.*//'
50 ip -6 -o addr show | grep ' inet6 ' | sed -e 's/.*inet6 \([^ ]*\) .*/\1/' -e 's/\/.*//'
63 LINE+="print_line '-> IP address: $ip';"
69 if [ "${NETINFO_PRESENT}" = "false" ] ; then
70 LINE+="print_line '-> network seems to be unconfigured (yet)';"
75 display_entry() { return 0; }