From 7e915dc1e86d26290ee73f059be700e60416a9a4 Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Tue, 8 Sep 2026 20:22:14 -0700 Subject: [PATCH] Checking for /opt/var/lib directory Added checks to make sure the '/opt/var/lib' directory is found, and create it if it's missing, and additional extra checks for the 'logrotate.status' file permissions. --- README.md | 2 +- init.d/rc.func.syslog-ng | 23 ++++++++++---------- scribe.sh | 46 ++++++++++++++++++++++++++++------------ 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 4e264f9..80dea8c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ **scribe** is a **syslog-ng** and **logrotate** installer for ASUS routers running **Asuswrt-Merlin** ## v3.2.13 -### Updated on 2026-Aug-16 +### Updated on 2026-Sep-08 ## Getting Started diff --git a/init.d/rc.func.syslog-ng b/init.d/rc.func.syslog-ng index c1eabf4..1b481bd 100644 --- a/init.d/rc.func.syslog-ng +++ b/init.d/rc.func.syslog-ng @@ -1,8 +1,8 @@ #!/bin/sh - # # NB: rc.func only runs PRECMD on "start" -# Last Modified: 2026-Apr-09 -# VERSION="3.1.6" +# Last Modified: 2026-Sep-08 +# VERSION="3.1.7" #------------------------------------------- ## Run the F/W built-in native commands ## @@ -21,10 +21,11 @@ logTagStr="scribe:kill_logger[$$]" logPrioNum="-p 4" ##----------------------------------------## -## Modified by Martinski W. [2026-Apr-09] ## +## Modified by Martinski W. [2026-Sep-08] ## ##----------------------------------------## kill_logger() { + local varLibDIR lrStatusFILE local serviceCallOK prevSysLog_Loc messagesLogSAVED local scribeScriptFPath="/jffs/scripts/scribe" local booleanStr=false filterSyslogInitRebootLogMsgs=true @@ -100,14 +101,14 @@ kill_logger() [ "$syslog_loc" = "$jffslog" ] && isjffs=true - # Touch 'logrotate.status' if it doesn't exist so syslog-ng doesn't whine # - [ ! -f /var/lib/logrotate.status ] && touch /var/lib/logrotate.status - - ##----------------------------------------## - ## Modified by Martinski W. [2025-Jun-16] ## - ##----------------------------------------## - # Set correct permissions to avoid "world-readable" status # - chmod 600 /var/lib/logrotate.status + [ ! -d /opt/var/lib ] && mkdir -p -m 755 /opt/var/lib + for varLibDIR in /var/lib /opt/var/lib + do + lrStatusFILE="${varLibDIR}/logrotate.status" + [ ! -f "$lrStatusFILE" ] && touch "$lrStatusFILE" + # Set correct permissions to avoid "world-readable" status # + chmod 600 "$lrStatusFILE" + done # Export timezone if not already set # [ -z "${TZ:+xSETx}" ] && export TZ="$($catCmd /etc/TZ)" diff --git a/scribe.sh b/scribe.sh index c4270e3..c43a339 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-Aug-16 +# Last Modified: 2026-Sep-08 #----------------------------------------------------------------- ################ Shellcheck directives ################ @@ -37,7 +37,7 @@ readonly script_name="scribe" readonly scribe_ver="v3.2.13" -readonly scriptVer_TAG="26081609" +readonly scriptVer_TAG="26090820" scribe_branch="develop" script_branch="$scribe_branch" @@ -547,6 +547,22 @@ Create_Config() # Assume uiScribe is still running if it was before stopping syslog-ng # } +##-------------------------------------## +## Added by Martinski W. [2026-Sep-08] ## +##-------------------------------------## +_Check_LogRotate_StatusFile_() +{ + local varLibDIR lrStatusFILE + [ ! -d /opt/var/lib ] && mkdir -p -m 755 /opt/var/lib + for varLibDIR in /var/lib /opt/var/lib + do + lrStatusFILE="${varLibDIR}/logrotate.status" + [ ! -f "$lrStatusFILE" ] && touch "$lrStatusFILE" + # Set correct permissions to avoid "world-readable" status # + chmod 600 "$lrStatusFILE" + done +} + ##----------------------------------------## ## Modified by Martinski W. [2026-Jan-30] ## ##----------------------------------------## @@ -572,12 +588,7 @@ Read_Config() then _Config_Option_Update_ FILTER_INIT_REBOOT_LOG true fi - - # Set correct permissions to avoid "world-readable" status # - if [ "$action" != "debug" ] && \ - [ -f /var/lib/logrotate.status ] - then chmod 600 /var/lib/logrotate.status - fi + [ "$action" != "debug" ] && _Check_LogRotate_StatusFile_ } ##----------------------------------------## @@ -1002,8 +1013,7 @@ LogRotate_CronJob_PostMount_Check() else present fi - # Set correct permissions to avoid "world-readable" status # - [ -f /var/lib/logrotate.status ] && chmod 600 /var/lib/logrotate.status + _Check_LogRotate_StatusFile_ } ##----------------------------------------## @@ -1562,13 +1572,16 @@ _AcquireFLock_() if [ $# -gt 0 ] && [ "$1" = "waitblock" ] then opts="" fi - eval exec "$LR_FLock_FD>$LR_FLock_FName" + eval exec "${LR_FLock_FD}>$LR_FLock_FName" flock -x $opts "$LR_FLock_FD" 2>/dev/null return "$?" } _ReleaseFLock_() -{ flock -u "$LR_FLock_FD" 2>/dev/null ; } +{ + flock -u "$LR_FLock_FD" 2>/dev/null + eval exec "${LR_FLock_FD}>&-" +} ##-------------------------------------## ## Added by Martinski W. [2026-Jan-04] ## @@ -2458,7 +2471,14 @@ Gather_Debug() printf "\n%s\n### init.d directory:\n" "$debug_sep" ls -l /opt/etc/init.d printf "\n%s\n### check logrotate.status \n" "$debug_sep" - ls -l /var/lib/logrotate.status + for varLibDIR in /var/lib /opt/var/lib + do + lrStatusFILE="${varLibDIR}/logrotate.status" + if [ -f "$lrStatusFILE" ] + then ls -lL "$lrStatusFILE" + else printf "*WARNING*: Status file '$lrStatusFILE' is NOT found.\n" + fi + done printf "\n%s\n### contents of S01syslog-ng\n" "$debug_sep" cat /opt/etc/init.d/S01syslog-ng printf "\n%s\n### /opt/var/log directory:\n" "$debug_sep"