wuwei
2025-06-16 9f7d99e9aa7fe85c6951d2f60361766e76c7bdfe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
json="/usr/sbin/jsoner"
file="/work/config.json"
#**************************************************************
 
 
#***********************************************************
# set mac addr
#***********************************************************
setMacAddr()
{
    netNo=$1
    mac=`$json -g $file eth$netNo\.mac`
    ret=$?
    if [ $ret -ne 0 ]
    then
           mac=`$json -g $file eth$netNo\.mac`
        echo "ret: $?, mac$netNo: $mac"
    fi
    
 
    ifconfig eth$netNo down
    ifconfig eth$netNo hw ether $mac
    ifconfig eth$netNo up
    
    
    echo set mac$netNo $mac
 
}
 
#********************************************************************
 
setMacAddr 0
setMacAddr 1
 
#-set eth0----------------------------------
ip=`$json -g $file "eth0.ip"`
mask=`jsoner -g $file "eth0.mask"`
dhcp0=`$json -g $file "eth0.dhcp"`
if [ $? -eq 0 ]
then 
    echo "dhcp0 : $dhcp0"
    if [ $dhcp0 == "on" ]
    then
        echo "dhcp1 is true"
        udhcpc -i eth0 &
    else 
        ifconfig eth0 $ip netmask $mask up
    fi
else 
    ifconfig eth0 $ip netmask $mask up
 
fi
 
gate=`$json -g $file "eth0.gate"`
route del default dev eth0 
route add default gw $gate dev eth0 
 
#-set eth1----------------------------------
ip=`$json -g $file "eth1.ip"`
mask=`jsoner -g $file "eth1.mask"`
#ifconfig eth1 down
ifconfig eth1 $ip netmask $mask up
 
#VALID_WIFI=`$json -g $file "wifi.enable"`
#VALID_4G=`$json -g $file "4g.enable"`
 
#ÉèÖÃwifi
#if [ ${VALID_WIFI} = "true" ]; then
#    echo "start wifi..."
#    /sbin/route del default
#    $startWifi &
#fi
 
#ÉèÖÃ4g
#if [ ${VALID_4G} = "true" ]
#then
#    $start4G &
#fi