lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | path_sh=`nv get path_sh` |
| 4 | . $path_sh/global.sh |
| 5 | echo "Info: user-config-udhcpd.sh start" >> $test_log |
| 6 | |
| 7 | lan_enable=`nv get LanEnable` |
| 8 | if [ "-$lan_enable" == "-0" ]; then |
| 9 | exit 0 |
| 10 | fi |
| 11 | |
| 12 | static_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 | |
| 39 | start=`nv get dhcpStart` |
| 40 | end=`nv get dhcpEnd` |
| 41 | dns=`nv get dhcpDns` |
| 42 | mask=`nv get lan_netmask` |
| 43 | gw=`nv get lan_ipaddr` |
| 44 | lease=`nv get dhcpLease_hour` |
| 45 | lease=`expr $lease \* 3600` |
| 46 | pidfile=$path_conf"/udhcpd.pid" |
| 47 | leasesfile=$path_conf"/udhcpd.leases" |
xf.li | e31de8b | 2023-12-26 23:38:58 -0800 | [diff] [blame] | 48 | gw_in_cap=`nv get gw_in_cap` |
| 49 | if [ "x$gw_in_cap" == "x1" ]; then |
| 50 | dns=`nv get dhcpDns_cap` |
| 51 | gw=`nv get lan_ipaddr_cap` |
| 52 | fi |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 53 | |
| 54 | sh $path_sh/config-udhcpd.sh "lan" -s $start |
| 55 | sh $path_sh/config-udhcpd.sh "lan" -e $end |
| 56 | sh $path_sh/config-udhcpd.sh "lan" -i $lan_if |
| 57 | sh $path_sh/config-udhcpd.sh "lan" -m $mask |
| 58 | sh $path_sh/config-udhcpd.sh "lan" -d $dns |
| 59 | echo "Info: config-udhcpd.sh lan -d $dns" >> $test_log |
| 60 | if [ "-$gw" != "-" ]; then |
| 61 | sh $path_sh/config-udhcpd.sh "lan" -g $gw |
| 62 | echo "Info: config-udhcpd.sh lan -g $gw" >> $test_log |
| 63 | fi |
| 64 | if [ "-$lease" != "-" ]; then |
| 65 | sh $path_sh/config-udhcpd.sh "lan" -t $lease |
| 66 | fi |
| 67 | |
| 68 | static_ip_init |
| 69 | |
| 70 | sh $path_sh/config-udhcpd.sh "lan" -p $pidfile |
| 71 | sh $path_sh/config-udhcpd.sh "lan" -l $leasesfile |