From 672fcb4d3b342088d2f5c11e0fbb306eacae7b71 Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Wed, 18 Feb 2026 02:10:38 -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. --- README.md | 4 +-- scribe.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 057a219..803d17a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ **scribe** is a **syslog-ng** and **logrotate** installer for ASUS routers running **Asuswrt-Merlin** -## v3.2.10 -### Updated on 2026-Feb-15 +## v3.2.11 +### Updated on 2026-Feb-18 ## Getting Started diff --git a/scribe.sh b/scribe.sh index e128e59..41cba38 100644 --- a/scribe.sh +++ b/scribe.sh @@ -18,7 +18,7 @@ # curl --retry 3 "https://raw.githubusercontent.com/AMTM-OSR/scribe/master/scribe.h" -o "/jffs/scripts/scribe" && chmod 0755 /jffs/scripts/scribe && /jffs/scripts/scribe install # ################################################################## -# Last Modified: 2026-Feb-15 +# Last Modified: 2026-Feb-18 #----------------------------------------------------------------- ################ Shellcheck directives ################ @@ -34,11 +34,14 @@ ################################################################# readonly script_name="scribe" -readonly scribe_ver="v3.2.10" -readonly scriptVer_TAG="26021523" +readonly scribe_ver="v3.2.11" +readonly scriptVer_TAG="26021800" scribe_branch="develop" script_branch="$scribe_branch" +# To support automatic script updates from AMTM # +doScriptUpdateFromAMTM=true + # Ensure firmware binaries are used, not Entware # export PATH="/sbin:/bin:/usr/sbin:/usr/bin:$PATH" @@ -70,6 +73,14 @@ do action="$1" break ;; + amtmupdate) + action="$1" + if [ $# -gt 1 ] && [ "$2" = "check" ] + then banner=false + fi + shift + break + ;; *) action="$1" ; shift ;; @@ -237,6 +248,10 @@ readonly uiscribePath="$script_d/$uiscribeName" readonly uiscribeVerRegExp="v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})" readonly menuSepStr="${white} =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=${CLRct}\n\n" +isInteractive=false +[ -t 0 ] && ! tty | grep -qwi "NOT" && isInteractive=true +if ! "$isInteractive" ; then banner=false ; fi + # Check if Scribe is already installed by looking for link in /opt/bin # [ -e "/opt/bin/$script_name" ] && scribeInstalled=true || scribeInstalled=false @@ -1383,10 +1398,11 @@ _HasRouterMoreThan512MBtotalRAM_() } ##----------------------------------------## -## Modified by Martinski W. [2026-Feb-15] ## +## Modified by Martinski W. [2026-Feb-18] ## ##----------------------------------------## _Generate_ListOf_Filtered_LogFiles_() { + local logDirPath logFilePath setDirPerms=true local tmpSysLogList="${HOMEdir}/${script_name}_tempSysLogList_$$.txt" local tmpFilterList="${HOMEdir}/${script_name}_tempFltLogList_$$.txt" @@ -1402,8 +1418,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 < "$syslogNg_StartSEM_FPath" printf '' > "$syslogD_InitRebootLogFPath" @@ -2077,7 +2107,7 @@ Menu_Filters() } ##----------------------------------------## -## Modified by Martinski W. [2026-Jan-30] ## +## Modified by Martinski W. [2026-Feb-18] ## ##----------------------------------------## Menu_Update() { @@ -2116,11 +2146,16 @@ Menu_Update() rm -f "$syslogNg_WaitnSEM_FPath" echo '1' > "$syslogNg_StartSEM_FPath" printf '' > "$syslogD_InitRebootLogFPath" - sh "$script_loc" filters gotzip nologo + if "$isInteractive" + then + sh "$script_loc" filters gotzip nologo + fi sh "$script_loc" status nologo run_scribe=true + return 0 else printf "\n ${white}*** %s ${red}NOT${white} updated! *** ${std}\n\n" "$script_name" + return 1 fi } @@ -2139,6 +2174,28 @@ 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 ! SyslogNg_Running + then + printf "$sng is currently not running. Script updates are NOT allowed during this state.\n\n" + return 1 + fi + if [ $# -gt 0 ] && [ "$1" = "check" ] + then return 0 + fi + Menu_Update force + return "$?" +} + menu_forgrnd() { local doStart=false @@ -2964,6 +3021,10 @@ case "$action" in forceupdate) Update_Version force ;; + amtmupdate) + ScriptUpdateFromAMTM "$@" + exit "$?" + ;; develop) script_branch="develop" SetUpRepoBranchVars