From f6f9b014fd838af3cf8ccaa284f743c137b4df6e Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Sun, 16 Nov 2025 12:08:22 -0800 Subject: [PATCH] Code Improvements Modified code to make sure we get correct parameters when changing settings from the WebUI. --- README.md | 4 ++-- ntpmerlin.sh | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cdee321..ea5b3be 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ntpMerlin -## v3.4.11 -### Updated on 2025-Nov-08 +## v3.4.12 +### Updated on 2025-Nov-16 ## About ntpMerlin implements an NTP time server for AsusWRT Merlin with charts for daily, weekly and monthly summaries of performance. A choice between ntpd and chrony is available. diff --git a/ntpmerlin.sh b/ntpmerlin.sh index df15de6..82033ab 100644 --- a/ntpmerlin.sh +++ b/ntpmerlin.sh @@ -14,7 +14,7 @@ ## Forked from https://github.com/jackyaz/ntpMerlin ## ## ## ############################################################## -# Last Modified: 2025-Nov-04 +# Last Modified: 2025-Nov-16 #------------------------------------------------------------- ############### Shellcheck directives ############# @@ -36,8 +36,8 @@ ### Start of script variables ### readonly SCRIPT_NAME="ntpMerlin" readonly SCRIPT_NAME_LOWER="$(echo "$SCRIPT_NAME" | tr 'A-Z' 'a-z' | sed 's/d//')" -readonly SCRIPT_VERSION="v3.4.11" -readonly SCRIPT_VERSTAG="25110422" +readonly SCRIPT_VERSION="v3.4.12" +readonly SCRIPT_VERSTAG="25111608" SCRIPT_BRANCH="develop" SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH" readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME_LOWER.d" @@ -478,7 +478,7 @@ Validate_Number() } ##----------------------------------------## -## Modified by Martinski W. [2025-Jan-19] ## +## Modified by Martinski W. [2025-Nov-15] ## ##----------------------------------------## Conf_FromSettings() { @@ -507,7 +507,7 @@ Conf_FromSettings() rm -f "$TMPFILE" rm -f "${SETTINGSFILE}.bak" - if diff "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" | grep -q "STORAGELOCATION=" + if diff -U0 "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" | grep -qE "[-+]STORAGELOCATION=" then STORAGEtype="$(ScriptStorageLocation check)" if [ "$STORAGEtype" = "jffs" ] @@ -521,13 +521,15 @@ Conf_FromSettings() then ScriptStorageLocation usb fi + Create_Dirs + Conf_Exists Create_Symlinks fi - if diff "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" | grep -qE "(OUTPUTTIMEMODE=|DAYSTOKEEP=|LASTXRESULTS=)" + if diff -U0 "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" | grep -qE "(OUTPUTTIMEMODE=|DAYSTOKEEP=|LASTXRESULTS=)" then Generate_CSVs fi - if diff "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" | grep -q "TIMESERVER=" + if diff -U0 "$SCRIPT_CONF" "${SCRIPT_CONF}.bak" | grep -qE "[-+]TIMESERVER=" then TimeServer "$(TimeServer check)" fi @@ -1265,7 +1267,10 @@ ScriptStorageLocation() mkdir -p "/opt/share/$SCRIPT_NAME_LOWER.d/" rm -f "/jffs/addons/$SCRIPT_NAME_LOWER.d/ntpdstats.db-shm" rm -f "/jffs/addons/$SCRIPT_NAME_LOWER.d/ntpdstats.db-wal" - [ -d "/opt/share/$SCRIPT_NAME_LOWER.d/csv" ] && rm -fr "/opt/share/$SCRIPT_NAME_LOWER.d/csv" + if [ -d "/opt/share/$SCRIPT_NAME_LOWER.d/csv" ] && \ + [ -d "/jffs/addons/$SCRIPT_NAME_LOWER.d/csv" ] + then rm -fr "/opt/share/$SCRIPT_NAME_LOWER.d/csv" + fi mv -f "/jffs/addons/$SCRIPT_NAME_LOWER.d/csv" "/opt/share/$SCRIPT_NAME_LOWER.d/" 2>/dev/null mv -f "/jffs/addons/$SCRIPT_NAME_LOWER.d/config" "/opt/share/$SCRIPT_NAME_LOWER.d/" 2>/dev/null mv -f "/jffs/addons/$SCRIPT_NAME_LOWER.d/config.bak" "/opt/share/$SCRIPT_NAME_LOWER.d/" 2>/dev/null @@ -1290,7 +1295,10 @@ ScriptStorageLocation() TIMESERVER_NAME="$(TimeServer check)" sed -i 's/^STORAGELOCATION.*$/STORAGELOCATION=jffs/' "$SCRIPT_CONF" mkdir -p "/jffs/addons/$SCRIPT_NAME_LOWER.d/" - [ -d "/jffs/addons/$SCRIPT_NAME_LOWER.d/csv" ] && rm -fr "/jffs/addons/$SCRIPT_NAME_LOWER.d/csv" + if [ -d "/opt/share/$SCRIPT_NAME_LOWER.d/csv" ] && \ + [ -d "/jffs/addons/$SCRIPT_NAME_LOWER.d/csv" ] + then rm -fr "/jffs/addons/$SCRIPT_NAME_LOWER.d/csv" + fi mv -f "/opt/share/$SCRIPT_NAME_LOWER.d/csv" "/jffs/addons/$SCRIPT_NAME_LOWER.d/" 2>/dev/null mv -f "/opt/share/$SCRIPT_NAME_LOWER.d/config" "/jffs/addons/$SCRIPT_NAME_LOWER.d/" 2>/dev/null mv -f "/opt/share/$SCRIPT_NAME_LOWER.d/config.bak" "/jffs/addons/$SCRIPT_NAME_LOWER.d/" 2>/dev/null