added showinfo init script to print network configuration at boot

This commit is contained in:
Calin Crisan 2015-11-28 20:51:19 +02:00
parent a48ba71660
commit 9f5623a340
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,43 @@
#!/bin/bash
test -n "$os_version" || source /etc/init.d/base
msg_info() {
echo " # $1"
}
show_iface_ip_addr() {
addr=$(ip addr show dev $1 2>/dev/null | grep inet | tr -s ' ' | sed -r 's/^\s+//' | cut -d ' ' -f 2)
test -n "$addr" && msg_info "Interface $1 has IP address $addr"
}
show_gateway() {
gateway=$(ip route | grep default | cut -d ' ' -f 3)
test -n "$gateway" && msg_info "Default gateway is $gateway"
}
show_dns() {
dns=$(cat /etc/resolv.conf | cut -d ' ' -f 2)
test -n "$gateway" && msg_info "DNS server address is $dns"
}
case "$1" in
start)
show_iface_ip_addr eth0
show_iface_ip_addr wlan0
show_iface_ip_addr ppp0
show_gateway
show_dns
;;
stop)
true
;;
*)
echo "Usage: $0 {start}"
exit 1
esac
exit $?

View File

@ -5,7 +5,7 @@ board_sn=$(/etc/init.d/boardsn)
board_name=$(cat /etc/board)
msg_begin() {
echo -n "* $1: "
echo -n " * $1: "
}
msg_done() {