mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-24 11:46:30 +00:00
added showinfo init script to print network configuration at boot
This commit is contained in:
parent
a48ba71660
commit
9f5623a340
43
board/common/overlay/etc/init.d/S98showinfo
Executable file
43
board/common/overlay/etc/init.d/S98showinfo
Executable 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 $?
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user