I've also added one more netmsg and moved the netmsg direct into the function, for not having two different places for the broadcast-address.
Signed-off-by: Bastian Bittorf <[EMAIL PROTECTED]>
---
Index: package/base-files/files/etc/preinit
===================================================================
--- package/base-files/files/etc/preinit (Revision 11157)
+++ package/base-files/files/etc/preinit (Arbeitskopie)
@@ -1,18 +1,35 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
+
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
. /etc/diag.sh
-failsafe_ip() {
- ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast
192.168.1.255 up
+failsafe_ip ()
+{
+ local DEVICE="$1" # ARG1
+ local IP="192.168.1.1"
+ local MASK="255.255.255.0"
+ local BROADCAST="$( /bin/ipcalc.sh $IP $MASK | sed -n
's/^BROADCAST=\(.*\)/\1/p' )"
+ local PRE="$( /bin/ipcalc.sh $IP $MASK | sed -n
's/^PREFIX=\(.*\)/\1/p' )"
+
+ ifconfig $DEVICE $IP netmask $MASK broadcast $BROADCAST up || {
+ #
ifconfig n/a -> fallback to ip
+ ip addr add dev $DEVICE $IP/$PRE broadcast + #
broadcast is calculated (is this clean? we calc it anyway)
+ ip link set dev $DEVICE arp on # maybe
not necessary
+ ip link set dev $DEVICE up
+ }
+
+ netmsg $BROADCAST "set up $IP/$PRE dev $DEVICE" #
would'nt it be better to send
+ netmsg $BROADCAST "Entering Failsafe!" # this
messages to 255.255.255.255 ?
}
-failsafe() {
+failsafe ()
+{
[ -n "$ifname" ] && grep "$ifname" /proc/net/dev >/dev/null && {
- failsafe_ip
- netmsg 192.168.1.255 "Entering Failsafe!"
+ failsafe_ip $ifname
telnetd -l /bin/login <> /dev/null 2>&1
}
+
lock /tmp/.failsafe
ash --login
}
signature.asc
Description: Digital signature
_______________________________________________ openwrt-devel mailing list [email protected] http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
