Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## v1.2.5

### Updated on 2026-Feb-18
### Updated on 2026-Mar-21

## About

Expand Down
29 changes: 15 additions & 14 deletions YazDHCP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## Forked from https://github.com/jackyaz/YazDHCP ##
## ##
##########################################################
# Last Modified: 2026-Feb-18
# Last Modified: 2026-Mar-21
#---------------------------------------------------------

#############################################
Expand All @@ -30,7 +30,7 @@
### Start of script variables ###
readonly SCRIPT_NAME="YazDHCP"
readonly SCRIPT_VERSION="v1.2.5"
readonly SCRIPT_VERSTAG="26021800"
readonly SCRIPT_VERSTAG="26032100"
SCRIPT_BRANCH="develop"
SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH"
readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d"
Expand Down Expand Up @@ -112,7 +112,6 @@ readonly NVRAM_3004_DHCPvar_RegExp="dhcp_staticlist=[<]?${MACaddr_RegEx}>.+"
readonly NVRAM_3006_DHCPvar_RegExp0="dhcpres[1-9][0-9]?_rl="
readonly NVRAM_3006_DHCPvar_RegExp1="${NVRAM_3006_DHCPvar_RegExp0}<${MACaddr_RegEx}>.+"

readonly addnDHCP_HostNames=true
readonly guestNetInfoJSfileName="GuestNetworkSubnetInfo.js"
readonly guestNetInfoJSfilePath="${SCRIPT_DIR}/$guestNetInfoJSfileName"
readonly dhcpGuestNetAllowVarKey="allowGuestNet_IPaddr_Reservations"
Expand Down Expand Up @@ -3617,7 +3616,7 @@ Update_Hostnames_GuestNet()
gnExistingMD5="$(md5sum "$hostNamesFileGNET" | awk '{print $1}')"
mv -f "$hostNamesFileGNET" "$hostNamesFileBKUP"
fi
printf "" > "$hostNamesFileGNET"
printf '' > "$hostNamesFileGNET"

gnIFaceVarStr="GNIFACE_${gnIFaceName}="
gnStartIPaddr4="$(echo "$gnInfoStr" | grep -E "^${gnIFaceVarStr}.*" | cut -d'=' -f2 | cut -d',' -f1)"
Expand Down Expand Up @@ -3808,7 +3807,7 @@ Update_StaticList_GuestNet()
gnExistingMD5="$(md5sum "$staticListFileGNET" | awk '{print $1}')"
mv -f "$staticListFileGNET" "$staticListFileBKUP"
fi
printf "" > "$staticListFileGNET"
printf '' > "$staticListFileGNET"

gnIFaceVarStr="GNIFACE_${gnIFaceName}="
gnStartIPaddr4="$(echo "$gnInfoStr" | grep -E "^${gnIFaceVarStr}.*" | cut -d'=' -f2 | cut -d',' -f1)"
Expand Down Expand Up @@ -3999,7 +3998,7 @@ Update_OptionsList_GuestNet()
gnExistingMD5="$(md5sum "$optionsListFileGNET" | awk '{print $1}')"
mv -f "$optionsListFileGNET" "$optionsListFileBKUP"
fi
printf "" > "$optionsListFileGNET"
printf '' > "$optionsListFileGNET"

gnIFaceVarStr="GNIFACE_${gnIFaceName}="
gnStartIPaddr4="$(echo "$gnInfoStr" | grep -E "^${gnIFaceVarStr}.*" | cut -d'=' -f2 | cut -d',' -f1)"
Expand Down Expand Up @@ -4104,17 +4103,14 @@ CleanUp_OptionsList_GuestNet()
Update_Hostnames()
{
local lanExistingMD5="" lanUpdatedMD5="" msgTagStr=""
local hostNamesFilePATH="$SCRIPT_DIR/.hostnames"
local hostNamesFileBKUP="${hostNamesFilePATH}.BKUP"

##OFF## ! "$addnDHCP_HostNames" && return 0 ##OFF##

if [ -s "$hostNamesFilePATH" ]
then
lanExistingMD5="$(md5sum "$hostNamesFilePATH" | awk '{print $1}')"
mv -f "$hostNamesFilePATH" "$hostNamesFileBKUP"
fi
printf "" > "$hostNamesFilePATH"
printf '' > "$hostNamesFilePATH"

Update_Hostnames_MainLAN
Update_Hostnames_GuestNet
Expand Down Expand Up @@ -4150,15 +4146,14 @@ Update_Hostnames()
Update_StaticList()
{
local lanExistingMD5="" lanUpdatedMD5="" msgTagStr=""
local staticListFilePATH="$SCRIPT_DIR/.staticlist"
local staticListFileBKUP="${staticListFilePATH}.BKUP"

if [ -s "$staticListFilePATH" ]
then
lanExistingMD5="$(md5sum "$staticListFilePATH" | awk '{print $1}')"
mv -f "$staticListFilePATH" "$staticListFileBKUP"
fi
printf "" > "$staticListFilePATH"
printf '' > "$staticListFilePATH"

Update_StaticList_MainLAN
Update_StaticList_GuestNet
Expand Down Expand Up @@ -4194,15 +4189,14 @@ Update_StaticList()
Update_OptionsList()
{
local lanExistingMD5="" lanUpdatedMD5="" msgTagStr=""
local optionsListFilePATH="$SCRIPT_DIR/.optionslist"
local optionsListFileBKUP="${optionsListFilePATH}.BKUP"

if [ -s "$optionsListFilePATH" ]
then
lanExistingMD5="$(md5sum "$optionsListFilePATH" | awk '{print $1}')"
mv -f "$optionsListFilePATH" "$optionsListFileBKUP"
fi
printf "" > "$optionsListFilePATH"
printf '' > "$optionsListFilePATH"

Update_OptionsList_MainLAN
Update_OptionsList_GuestNet
Expand Down Expand Up @@ -4238,6 +4232,10 @@ Update_OptionsList()
Process_DHCP_Clients()
{
local retCode=1 delBkupCopy=true verboseMode
local hostNamesFilePATH="$SCRIPT_DIR/.hostnames"
local staticListFilePATH="$SCRIPT_DIR/.staticlist"
local optionsListFilePATH="$SCRIPT_DIR/.optionslist"

if [ $# -gt 0 ] && { [ "$1" = "true" ] || [ "$1" = "false" ] ; }
then RESTART_DNSMASQ="$1"
else RESTART_DNSMASQ=false
Expand All @@ -4246,6 +4244,9 @@ Process_DHCP_Clients()
if [ ! -s "$SCRIPT_CONF" ] || \
! grep -qv "MAC,IP,HOSTNAME,DNS" "$SCRIPT_CONF"
then
printf '' > "$hostNamesFilePATH"
printf '' > "$staticListFilePATH"
printf '' > "$optionsListFilePATH"
Print_Output true "No DHCP client IP address assignments were found." "$WARN"
return 1
fi
Expand Down