| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh | 
 | 2 |  | 
 | 3 | path_sh=`nv get path_sh` | 
 | 4 | echo "Info: pppoe_updown.sh $1 start " >> $test_log | 
 | 5 | wan_if=`nv get ethwan` | 
 | 6 | . $path_sh/global.sh | 
 | 7 |  | 
 | 8 | pppoe_down() | 
 | 9 | { | 
 | 10 | 	nv set rj45_state="idle" | 
 | 11 |     #killall pppoecd | 
 | 12 | 	(/sbin/router_msg_proxy ipv4 pppoe_updown.sh 1>> $test_log 2>&1 || echo "Error: router_msg_proxy ipv4 pppoe_updown.sh failed." >> $test_log) & | 
 | 13 | 	if [ $? -ne 0 ];then | 
 | 14 | 	    echo "Error: router_msg_proxy ipv4 failed." >> $test_log | 
 | 15 |     fi | 
 | 16 | } | 
 | 17 | pppoe_up() | 
 | 18 | { | 
 | 19 |     udhcpc_kill | 
 | 20 | 	nv set rj45_state="working" | 
 | 21 | 	nv set eth_curmode="pppoe" | 
 | 22 | 	(/sbin/router_msg_proxy del_timer ethwan 1>> $test_log 2>&1 || echo "Error: router_msg_proxy del_timer failed." >> $test_log) & | 
 | 23 | 	if [ $? -ne 0 ];then | 
 | 24 | 	    echo "Error: router_msg_proxy del_timer failed." >> $test_log | 
 | 25 |     fi | 
 | 26 | 	(/sbin/router_msg_proxy ipv4 pppoe_updown.sh 1>> $test_log 2>&1 || echo "Error: router_msg_proxy ipv4 pppoe_updown.sh failed." >> $test_log) & | 
 | 27 | 	if [ $? -ne 0 ];then | 
 | 28 | 	    echo "Error: router_msg_proxy ipv4 failed." >> $test_log | 
 | 29 |     fi | 
 | 30 | 	 | 
 | 31 | 	wan_ip=`nv get $wan_if"_ip"` | 
 | 32 |     wan_gw=`nv get $wan_if"_gw"` | 
 | 33 | 	wan_pri=`nv get ethwan_priority` | 
 | 34 | 	rt_num=`expr $wan_pri \* 10 ` | 
 | 35 | 	ip rule add from $wan_ip table $rt_num 2>>$test_log | 
 | 36 | 	if [ $? -ne 0 ];then | 
 | 37 | 	    echo "Error: ip rule add from $wan_ip table $rt_num failed." >> $test_log | 
 | 38 |     fi | 
 | 39 | 	ip route add default via $wan_gw table $rt_num 2>>$test_log | 
 | 40 | 	if [ $? -ne 0 ];then | 
 | 41 | 	    echo "Error: ip route add default via $wan_gw table $rt_num failed." >> $test_log | 
 | 42 |     fi | 
 | 43 | 	ip route flush cache 2>>$test_log | 
 | 44 | 	if [ $? -ne 0 ];then | 
 | 45 | 	    echo "Error: ip route flush cache failed." >> $test_log | 
 | 46 |     fi | 
 | 47 | } | 
 | 48 |  | 
 | 49 | if [ "$1" == "up" ]; then | 
 | 50 |     pppoe_up | 
 | 51 | elif [ "$1" == "down" ]; then | 
 | 52 |     pppoe_down | 
 | 53 | fi | 
 | 54 |      |