1
1
#! /bin/sh /etc/rc.common
2
2
START=99
3
3
4
+ PATH=/bin:/sbin:/usr/bin:/usr/sbin
4
5
CONFIG=/bin/config
5
6
AP_MODE=$( $CONFIG get ap_mode)
6
7
BRIDGE_MODE=$( $CONFIG get bridge_mode)
@@ -9,34 +10,47 @@ KVER=`uname -r | cut -f 1`
9
10
MODULE_PATH=/lib/modules/$KVER
10
11
11
12
start () {
12
- # Check if not router mode
13
+ # Check: is router mode, exit if "no"
13
14
if [ " $AP_MODE " != " 0" ] || [ " $BRIDGE_MODE " != " 0" ] || [ " $EXTENDER_MODE " != " 0" ]; then
14
15
exit 0;
15
16
fi
16
17
17
- # Check is cable attached to WAN port, exit if "yes"
18
+ # Check: is cable attached to WAN port, exit if "yes"
18
19
detcable show | grep " WAN : Plug in" > /dev/null
19
20
if [ $? -eq 0 ]; then
20
21
exit 0;
21
22
fi
22
23
23
- # Add kernel object and switch mode of modem
24
- /sbin/insmod $MODULE_PATH /rndis_host.ko
25
- /sbin/usbmode -s
26
- /bin/sleep 10
24
+ # Try to load kernel object, switch modem mode and up interface eth0
25
+ insmod $MODULE_PATH /rndis_host.ko
26
+ usbmode -s
27
+ sleep 10
28
+ ifconfig eth0 up
27
29
28
- # Check is modem attached
29
- /sbin/ifconfig eth0 up
30
+ # Check: is modem attached
30
31
if [ $? -eq 0 ]; then
32
+ # Attached, rename eth0 to brwan
33
+ ifconfig eth0 down
34
+ ip link delete brwan
35
+ ip link set eth0 name brwan
36
+ ifconfig brwan up
37
+
38
+ # Stop services
31
39
/etc/init.d/net-wan stop
32
40
/etc/init.d/detcable stop
33
41
/etc/init.d/watchdog stop
34
- echo -n 1 > /tmp/port_status
42
+ /etc/init.d/ntpclient stop
35
43
echo modem > /tmp/modem
44
+ echo -n 1 > /tmp/port_status
45
+
46
+ # Start services and restart firewall
36
47
/etc/init.d/net-wan start
37
- /usr/sbin/net-wall restart
48
+ net-wall restart
49
+ killall ntpclient
50
+ sleep 15
51
+ /etc/init.d/ntpclient start
38
52
else
39
- # No modem found, restore kernel objects
40
- /sbin/ rmmod rndis_host
53
+ # No modem found, just unload kernel objects
54
+ rmmod rndis_host
41
55
fi
42
56
}
0 commit comments