diff --git a/package/network/services/odhcpd/Makefile b/package/network/services/odhcpd/Makefile index 9d125734a7..92dfd823b4 100644 --- a/package/network/services/odhcpd/Makefile +++ b/package/network/services/odhcpd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcpd.git -PKG_MIRROR_HASH:=7d2a69c9f514c01c4e520034554fe7da9a9fe065b9bccb9f0c7063f657c5b9fb -PKG_SOURCE_DATE:=2025-12-04 -PKG_SOURCE_VERSION:=79252ed0c0c26659a95729da0f2accaa0ddb458d +PKG_MIRROR_HASH:=cce1d4f3c88f4eec0cf8b19429f12e6fc2f47dca9b4d643a31569c1209f8fabc +PKG_SOURCE_DATE:=2025-12-10 +PKG_SOURCE_VERSION:=ca00527e5fc3d8d2b8c1a60fbeb6a25e2bf68674 PKG_MAINTAINER:=Álvaro Fernández Rojas PKG_LICENSE:=GPL-2.0 diff --git a/package/network/services/odhcpd/files/odhcpd.defaults b/package/network/services/odhcpd/files/odhcpd.defaults index 76c75b060a..fbb7ec92af 100644 --- a/package/network/services/odhcpd/files/odhcpd.defaults +++ b/package/network/services/odhcpd/files/odhcpd.defaults @@ -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