blob: dd03b71a92231f2ec922b086222fb283f6958cfd [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/bin/sh
2
3path_sh=`nv get path_sh`
4. $path_sh/global.sh
5echo "Info: user-config-udhcpd.sh start" >> $test_log
6
7lan_enable=`nv get LanEnable`
8if [ "-$lan_enable" == "-0" ]; then
9 exit 0
10fi
11
12static_ip_init()
13{
14 mac_ip_list=`nv get mac_ip_list`
15 num_any=`echo $mac_ip_list| grep -c ";"`
16 num_one=`echo $mac_ip_list| grep -c "+"`
17
18 if [ "$num_any" -eq "0" ]; then
19 if [ "$num_one" -eq "1" ]; then
20 mac=`echo $mac_ip_list| awk -F '+' '{print $2}'`
21 ip=`echo $mac_ip_list| awk -F '+' '{print $3}'`
22 sh $path_sh/config-udhcpd.sh "lan" -S $mac $ip
23 else
24 echo "the mac_ip_list is null"
25
26 fi
27 else
28 var=`echo $mac_ip_list | sed "s/;/ /g"`
29 for list in $var
30 do
31 mac=`echo $list| awk -F '+' '{print $2}'`
32 ip=`echo $list| awk -F '+' '{print $3}'`
33 sh $path_sh/config-udhcpd.sh "lan" -S $mac $ip
34 done
35
36 fi
37}
38
39start=`nv get dhcpStart`
40end=`nv get dhcpEnd`
41dns=`nv get dhcpDns`
42mask=`nv get lan_netmask`
43gw=`nv get lan_ipaddr`
44lease=`nv get dhcpLease_hour`
45lease=`expr $lease \* 3600`
46pidfile=$path_conf"/udhcpd.pid"
47leasesfile=$path_conf"/udhcpd.leases"
xf.lie31de8b2023-12-26 23:38:58 -080048gw_in_cap=`nv get gw_in_cap`
49if [ "x$gw_in_cap" == "x1" ]; then
50 dns=`nv get dhcpDns_cap`
51 gw=`nv get lan_ipaddr_cap`
52fi
lh9ed821d2023-04-07 01:36:19 -070053
54sh $path_sh/config-udhcpd.sh "lan" -s $start
55sh $path_sh/config-udhcpd.sh "lan" -e $end
56sh $path_sh/config-udhcpd.sh "lan" -i $lan_if
57sh $path_sh/config-udhcpd.sh "lan" -m $mask
58sh $path_sh/config-udhcpd.sh "lan" -d $dns
59echo "Info: config-udhcpd.sh lan -d $dns" >> $test_log
60if [ "-$gw" != "-" ]; then
61 sh $path_sh/config-udhcpd.sh "lan" -g $gw
62 echo "Info: config-udhcpd.sh lan -g $gw" >> $test_log
63fi
64if [ "-$lease" != "-" ]; then
65 sh $path_sh/config-udhcpd.sh "lan" -t $lease
66fi
67
68static_ip_init
69
70sh $path_sh/config-udhcpd.sh "lan" -p $pidfile
71sh $path_sh/config-udhcpd.sh "lan" -l $leasesfile