blob: 62eefd729992c524553f5043bd6365b5c08c63a7 [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"
48
49sh $path_sh/config-udhcpd.sh "lan" -s $start
50sh $path_sh/config-udhcpd.sh "lan" -e $end
51sh $path_sh/config-udhcpd.sh "lan" -i $lan_if
52sh $path_sh/config-udhcpd.sh "lan" -m $mask
53sh $path_sh/config-udhcpd.sh "lan" -d $dns
54echo "Info: config-udhcpd.sh lan -d $dns" >> $test_log
55if [ "-$gw" != "-" ]; then
56 sh $path_sh/config-udhcpd.sh "lan" -g $gw
57 echo "Info: config-udhcpd.sh lan -g $gw" >> $test_log
58fi
59if [ "-$lease" != "-" ]; then
60 sh $path_sh/config-udhcpd.sh "lan" -t $lease
61fi
62
63static_ip_init
64
65sh $path_sh/config-udhcpd.sh "lan" -p $pidfile
66sh $path_sh/config-udhcpd.sh "lan" -l $leasesfile