From 7923a4c1b572b05f477f0478c5332eec57083048 Mon Sep 17 00:00:00 2001
From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com>
Date: Wed, 18 Feb 2026 02:08:16 -0800
Subject: [PATCH] New Functionality
- Initial code to support automatic script updates via AMTM.
- Adjusted code to allow searching for log files under a subdirectory of the "/opt/var/log" directory. Note that the 'messages' log file is a special case and cannot located be in a subdirectory.
---
Main_LogStatus_Content.asp | 4 +-
Main_LogStatus_Content.js | 4 +-
README.md | 4 +-
uiScribe.sh | 143 +++++++++++++++++++++++++++----------
4 files changed, 111 insertions(+), 44 deletions(-)
diff --git a/Main_LogStatus_Content.asp b/Main_LogStatus_Content.asp
index 0b4e1b1..106f183 100644
--- a/Main_LogStatus_Content.asp
+++ b/Main_LogStatus_Content.asp
@@ -25,7 +25,7 @@ p{font-weight:bolder}thead.collapsible-jquery{color:#fff;padding:0;width:100%;bo
diff --git a/Main_LogStatus_Content.js b/Main_LogStatus_Content.js
index b1f0a44..d897a99 100644
--- a/Main_LogStatus_Content.js
+++ b/Main_LogStatus_Content.js
@@ -1,5 +1,5 @@
/**----------------------------**/
-/** Last Modified: 2025-Dec-07 **/
+/** Last Modified: 2026-Feb-16 **/
/**----------------------------**/
var timeoutsenabled = true;
@@ -563,7 +563,7 @@ function GetLogFileSizeInfo(theFileName)
{
logFilePath = logRotate_InfoListArray[indx].LOG_PATH;
logFileSize = logRotate_InfoListArray[indx].LOG_SIZE;
- logFileName = logFilePath.replace('/opt/var/log/','');
+ logFileName = logFilePath.substring(logFilePath.lastIndexOf('/')+1);
if (logFileName === theFileName)
{ fileSizeOK = true; break; }
}
diff --git a/README.md b/README.md
index 5eb678f..02af09c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# uiScribe
-## v1.4.12
-### Updated on 2026-Feb-15
+## v1.4.13
+### Updated on 2026-Feb-18
## About
uiScribe updates the System Log page to show log files created by Scribe (syslog-ng). Requires [**Scribe**](https://github.com/cynicastic/scribe)
diff --git a/uiScribe.sh b/uiScribe.sh
index 322dba8..433583b 100644
--- a/uiScribe.sh
+++ b/uiScribe.sh
@@ -13,7 +13,7 @@
## Forked from https://github.com/jackyaz/uiScribe ##
## ##
########################################################
-# Last Modified: 2026-Feb-15
+# Last Modified: 2026-Feb-18
#-------------------------------------------------------
########### Shellcheck directives ##########
@@ -29,8 +29,8 @@
### Start of script variables ###
readonly SCRIPT_NAME="uiScribe"
-readonly SCRIPT_VERSION="v1.4.12"
-readonly SCRIPT_VERSTAG="26021523"
+readonly SCRIPT_VERSION="v1.4.13"
+readonly SCRIPT_VERSTAG="26021800"
SCRIPT_BRANCH="develop"
SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH"
readonly SCRIPT_DIR="/jffs/addons/${SCRIPT_NAME}.d"
@@ -50,6 +50,9 @@ readonly branchxStr_TAG="[Branch: $SCRIPT_BRANCH]"
readonly versionDev_TAG="${SCRIPT_VERSION}_${SCRIPT_VERSTAG}"
readonly versionMod_TAG="$SCRIPT_VERSION on $ROUTER_MODEL"
+# To support automatic script updates from AMTM #
+doScriptUpdateFromAMTM=true
+
##-------------------------------------##
## Added by Martinski W. [2025-Nov-28] ##
##-------------------------------------##
@@ -278,9 +281,11 @@ Update_Version()
localver="$(echo "$updatecheckresult" | cut -f2 -d',')"
serverver="$(echo "$updatecheckresult" | cut -f3 -d',')"
- if [ "$isupdate" = "version" ]; then
+ if [ "$isupdate" = "version" ]
+ then
Print_Output true "New version of $SCRIPT_NAME available - $serverver" "$PASS"
- elif [ "$isupdate" = "md5" ]; then
+ elif [ "$isupdate" = "md5" ]
+ then
Print_Output true "MD5 hash of $SCRIPT_NAME does not match - hotfix available - $serverver" "$PASS"
fi
@@ -339,6 +344,23 @@ Update_Version()
fi
}
+##-------------------------------------##
+## Added by Martinski W. [2026-Feb-18] ##
+##-------------------------------------##
+ScriptUpdateFromAMTM()
+{
+ if ! "$doScriptUpdateFromAMTM"
+ then
+ printf "Automatic script updates via AMTM are currently disabled.\n\n"
+ return 1
+ fi
+ if [ $# -gt 0 ] && [ "$1" = "check" ]
+ then return 0
+ fi
+ Update_Version force unattended
+ return "$?"
+}
+
##----------------------------------------##
## Modified by Martinski W. [2025-Jun-15] ##
##----------------------------------------##
@@ -428,8 +450,12 @@ Create_Dirs()
##----------------------------------------##
_Generate_ListOf_Filtered_LogFiles_()
{
+ local logDirPath logFilePath setDirPerms=false
local tmpSysLogList="${HOMEdir}/${SCRIPT_NAME}_tempSysLogList_$$.txt"
local tmpFilterList="${HOMEdir}/${SCRIPT_NAME}_tempFltLogList_$$.txt"
+ if [ $# -gt 0 ] && [ "$1" = "true" ]
+ then setDirPerms=true
+ fi
printf '' > "$tmpFilterList"
[ ! -f "$filteredLogList" ] && printf '' > "$filteredLogList"
@@ -443,8 +469,15 @@ _Generate_ListOf_Filtered_LogFiles_()
then continue #Avoid duplicates#
fi
echo "$logFilePath" >> "$tmpFilterList"
+ if "$setDirPerms"
+ then
+ logDirPath="$(dirname "$logFilePath")"
+ if echo "$logDirPath" | grep -qE "^${optVarLogDir}/.+"
+ then chmod 0755 "$logDirPath" 2>/dev/null
+ fi
+ fi
done </dev/null
+ echo "$theLogFilePath"
+ return 0
+}
+
+##-------------------------------------##
+## Added by Martinski W. [2025-Nov-28] ##
+##-------------------------------------##
+_Get_LogRotate_ConfigFile_()
+{
+ if [ $# -eq 0 ] || [ -z "$1" ] || [ ! -s "$1" ]
+ then echo ; return 1
+ fi
local theConfigFile theConfLogExp configFileOK
configFileOK=false
@@ -861,7 +923,7 @@ _Get_LogRotate_ConfigFile_()
! grep -qE "$logFilesRegExp" "$theConfigFile"
then continue
fi
- if grep -qE "${optVarLogDir}/$1" "$theConfigFile"
+ if grep -qE "$1" "$theConfigFile"
then
configFileOK=true ; break
fi
@@ -941,7 +1003,7 @@ _RotateAllLogFiles_Preamble_()
local tmpLogRotateAction="${HOMEdir}/${SCRIPT_NAME}_tempLogRotateAction_$$.txt"
doPostRotateCleanup=false
- _Generate_ListOf_Filtered_LogFiles_
+ _Generate_ListOf_Filtered_LogFiles_ true
_Update_ListOf_UserCheck_LogFiles_
_Generate_ListOf_LogFiles_Without_Configs_
@@ -995,13 +1057,15 @@ _Run_RotateLogFile_()
return 1
fi
+ local logFilePath=""
local doPostRotateCleanup=false
local logRotateConf="$logRotateTopConf"
case "$1" in
ALL) _RotateAllLogFiles_Preamble_
;;
- *) logRotateConf="$(_Get_LogRotate_ConfigFile_ "$1")"
+ *) logFilePath="$(_GetFilteredLogFilePath_ "$1")"
+ logRotateConf="$(_Get_LogRotate_ConfigFile_ "$logFilePath")"
;;
esac
@@ -1009,9 +1073,9 @@ _Run_RotateLogFile_()
then
echo "var logRotateStatus = 'ERROR';" > "$logRotateStatusJS"
{
- if [ "$1" != "ALL" ] && [ ! -s "${optVarLogDir}/$1" ]
+ if [ -n "$logFilePath" ] && [ ! -s "$logFilePath" ]
then
- echo "Log file [${optVarLogDir}/$1] NOT found or is EMPTY."
+ echo "Log file [$logFilePath] NOT found or is EMPTY."
fi
[ -n "$logRotateConf" ] && \
echo "Check if LogRotate config file [$logRotateConf] exists."
@@ -1092,16 +1156,14 @@ EOF
##-------------------------------------##
_Get_LogRotate_TempConfig_()
{
- if [ $# -eq 0 ] || [ -z "$1" ] || \
- [ ! -s "${optVarLogDir}/$1" ]
- then
- echo ; return 1
+ if [ $# -eq 0 ] || [ -z "$1" ] || [ ! -s "$1" ]
+ then echo ; return 1
fi
- local logFileName="$1" configFPath
+ local configFPath logFileName="${1##*/}"
configFPath="${optTempDir}/RotateLog_${logFileName%.*}.conf"
rm -f "$configFPath"
- echo "${optVarLogDir}/$logFileName" > "$configFPath"
+ echo "$1" > "$configFPath"
_Set_LogRotate_ConfigOptions_ >> "$configFPath"
chmod 644 "$configFPath"
echo "$configFPath"
@@ -1142,19 +1204,17 @@ _PrependGlobalDirectives_()
##-------------------------------------##
_Get_LogRotateClear_ConfigFile_()
{
- if [ $# -eq 0 ] || [ -z "$1" ] || \
- [ ! -s "${optVarLogDir}/$1" ]
- then
- echo ; return 1
+ if [ $# -eq 0 ] || [ -z "$1" ] || [ ! -s "$1" ]
+ then echo ; return 1
fi
- local logFileName="$1" theConfigFile
- theConfigFile="${optTempDir}/ClearLog_${logFileName%.*}.conf"
- rm -f "$theConfigFile"
-
- echo "${optVarLogDir}/$logFileName" > "$theConfigFile"
- _Set_LogRotateClear_ConfigOptions_ >> "$theConfigFile"
- chmod 644 "$theConfigFile"
- echo "$theConfigFile"
+ local configFPath logFileName="${1##*/}"
+ configFPath="${optTempDir}/ClearLog_${logFileName%.*}.conf"
+ rm -f "$configFPath"
+
+ echo "$1" > "$configFPath"
+ _Set_LogRotateClear_ConfigOptions_ >> "$configFPath"
+ chmod 644 "$configFPath"
+ echo "$configFPath"
}
##-------------------------------------##
@@ -1220,22 +1280,24 @@ _Run_ClearLogFile_()
echo "ERROR: LogRotate is NOT available." > "$logClearStatusJS"
return 1
fi
- local logFilePath logRotateConf=""
+ local logFilePath="" logRotateConf=""
case "$1" in
ALL) _Run_ClearAllLogFiles_ ; return "$?"
;;
- *) logRotateConf="$(_Get_LogRotateClear_ConfigFile_ "$1")"
+ *) logFilePath="$(_GetFilteredLogFilePath_ "$1")"
+ logRotateConf="$(_Get_LogRotateClear_ConfigFile_ "$logFilePath")"
;;
esac
if [ -z "$logRotateConf" ] || [ ! -s "$logRotateConf" ]
then
- logFilePath="${optVarLogDir}/$1"
echo "var logClearStatus = 'ERROR';" > "$logClearStatusJS"
{
- [ ! -s "$logFilePath" ] && \
- echo "Log file [$logFilePath] NOT found or is EMPTY."
+ if [ -n "$logFilePath" ] && [ ! -s "$logFilePath" ]
+ then
+ echo "Log file [$logFilePath] NOT found or is EMPTY."
+ fi
[ -n "$logRotateConf" ] && \
echo "Check if LogRotate config file [$logRotateConf] exists."
} > "$logClearStatusT"
@@ -1821,7 +1883,7 @@ then
fi
##----------------------------------------##
-## Modified by Martinski W. [2025-Dec-19] ##
+## Modified by Martinski W. [2026-Feb-18] ##
##----------------------------------------##
case "$1" in
install)
@@ -1881,6 +1943,11 @@ case "$1" in
Update_Version force
exit 0
;;
+ amtmupdate)
+ shift
+ ScriptUpdateFromAMTM "$@"
+ exit "$?"
+ ;;
setversion)
sed -i '/\/dev\/null/d' "$userCheckLogList"
Create_Dirs