|
|
@@ -1,13 +1,64 @@
|
|
|
#!/bin/sh
|
|
|
|
|
|
+. /usr/share/libubox/jshn.sh
|
|
|
+
|
|
|
+pio_file_check() {
|
|
|
+ local file valid
|
|
|
+
|
|
|
+ file=$1
|
|
|
+ valid=0
|
|
|
+
|
|
|
+ json_init
|
|
|
+ json_load_file $file 2> /dev/null
|
|
|
+
|
|
|
+ if json_is_a slaac array; then
|
|
|
+ local keys len
|
|
|
+
|
|
|
+ json_select slaac
|
|
|
+ json_get_keys keys
|
|
|
+
|
|
|
+ len=$(echo $keys | wc -w)
|
|
|
+ if [ $len -gt 0 ]; then
|
|
|
+ valid=1
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+
|
|
|
+ echo $valid
|
|
|
+}
|
|
|
+
|
|
|
+pio_folder_migrate() {
|
|
|
+ local piodir piofolder
|
|
|
+
|
|
|
+ piofolder=$1
|
|
|
+ piodir=$2
|
|
|
+
|
|
|
+ [ -d $piofolder ] || return
|
|
|
+ [ -d $piodir ] || mkdir -p $piodir
|
|
|
+
|
|
|
+ for file in $piofolder/*; do
|
|
|
+ [ -e "$file" ] || continue
|
|
|
+ if [ $(pio_file_check $file) -eq 1 ]; then
|
|
|
+ mv $file $piodir/odhcpd.pio.$(basename $file)
|
|
|
+ fi
|
|
|
+ done
|
|
|
+}
|
|
|
+
|
|
|
if [ -n "$(uci -q get dhcp.odhcpd)" ]; then
|
|
|
- local commit
|
|
|
- local hostsfile
|
|
|
+ local commit hostsfile piodir piofolder
|
|
|
|
|
|
commit=0
|
|
|
|
|
|
- if [ -z "$(uci -q get dhcp.odhcpd.piofolder)" ]; then
|
|
|
- uci set dhcp.odhcpd.piofolder=/tmp/odhcpd-piofolder
|
|
|
+ piodir=$(uci -q get dhcp.odhcpd.piodir)
|
|
|
+ if [ -z "$piodir" ]; then
|
|
|
+ piodir=/tmp/odhcpd-piodir
|
|
|
+ uci set dhcp.odhcpd.piodir=$piodir
|
|
|
+ commit=1
|
|
|
+ fi
|
|
|
+
|
|
|
+ piofolder=$(uci -q get dhcp.odhcpd.piofolder)
|
|
|
+ if [ -n "$piofolder" ]; then
|
|
|
+ pio_folder_migrate $piofolder $piodir
|
|
|
+ uci delete dhcp.odhcpd.piofolder
|
|
|
commit=1
|
|
|
fi
|
|
|
|
|
|
@@ -78,7 +129,7 @@ set dhcp.odhcpd.maindhcp=$ODHCPDONLY
|
|
|
set dhcp.odhcpd.leasefile=/tmp/odhcpd.leases
|
|
|
set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
|
|
|
set dhcp.odhcpd.loglevel=4
|
|
|
-set dhcp.odhcpd.piofolder=/tmp/odhcpd-piofolder
|
|
|
+set dhcp.odhcpd.piodir=/tmp/odhcpd-piodir
|
|
|
set dhcp.odhcpd.hostsdir=/tmp/hosts
|
|
|
set dhcp.lan.dhcpv4=$V4MODE
|
|
|
set dhcp.lan.dhcpv6=$V6MODE
|