mirror of https://github.com/OpenIPC/firmware.git
enable eth0 by default with highest priority, monitor ethenet state changes
parent
4b58adc412
commit
f444114ea6
|
@ -11,7 +11,6 @@ set_wireless() {
|
|||
elif $path/modem "$dev"; then
|
||||
ifup usb0
|
||||
fi
|
||||
[ -e /sys/class/net/eth0 ] && ifconfig eth0 "${net:-192.168.2.10}"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
@ -20,8 +19,10 @@ case "$1" in
|
|||
ifup lo
|
||||
if [ -n "$dev" ]; then
|
||||
set_wireless
|
||||
else
|
||||
fi
|
||||
if [ -e /sys/class/net/eth0 ]; then
|
||||
ifup eth0
|
||||
/usr/sbin/interface_monitor.sh eth0 &
|
||||
fi
|
||||
;;
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
|
||||
monitor_interface () {
|
||||
local fileoperstate=/sys/class/net/"$1"/operstate
|
||||
local state oldstate=$(cat "$fileoperstate")
|
||||
|
||||
while sleep 2; do
|
||||
state=$(cat "$fileoperstate")
|
||||
if [ "$oldstate" = "$state" ]; then
|
||||
continue
|
||||
fi
|
||||
oldstate="$state"
|
||||
echo "interface $1 is $state"
|
||||
case "$state" in
|
||||
down | lowerlayerdown)
|
||||
kill -12 `cat /var/run/udhcpc.$1.pid`
|
||||
;;
|
||||
up)
|
||||
kill -10 `cat /var/run/udhcpc.$1.pid`
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
monitor_interface "$1"
|
|
@ -54,7 +54,8 @@ case "$1" in
|
|||
if [ -x /usr/sbin/avahi-autoipd ]; then
|
||||
/usr/sbin/avahi-autoipd -c $interface || /usr/sbin/avahi-autoipd -wD $interface --no-chroot
|
||||
fi
|
||||
/sbin/ifconfig $interface $(fw_printenv -n ipaddr || echo -n 192.168.1.10) netmask $(fw_printenv -n netmask || echo -n 255.255.255.0) up
|
||||
#/sbin/ifconfig $interface $(fw_printenv -n ipaddr || echo -n 192.168.1.10) netmask $(fw_printenv -n netmask || echo -n 255.255.255.0) up
|
||||
/sbin/ifconfig $interface up
|
||||
;;
|
||||
|
||||
renew|bound)
|
||||
|
@ -73,7 +74,14 @@ case "$1" in
|
|||
done
|
||||
|
||||
for i in $router ; do
|
||||
route add default gw $i dev $interface
|
||||
if [ $interface = "eth0" ]; then
|
||||
metric=0
|
||||
elif [ $interface = "wlan0" ]; then
|
||||
metric=10
|
||||
else
|
||||
metric=20
|
||||
fi
|
||||
route add default gw $i dev $interface metric $metric
|
||||
done
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue