diff --git a/README.md b/README.md index da245e3..bf88928 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.11 -### Updated on 2026-Feb-28 +### Updated on 2026-Mar-02 ## Getting Started diff --git a/scribe.sh b/scribe.sh index a2cf969..f52e11a 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-27 +# Last Modified: 2026-Mar-02 #----------------------------------------------------------------- ################ Shellcheck directives ################ @@ -35,7 +35,7 @@ readonly script_name="scribe" readonly scribe_ver="v3.2.11" -readonly scriptVer_TAG="26022723" +readonly scriptVer_TAG="26030223" scribe_branch="develop" script_branch="$scribe_branch" @@ -190,17 +190,18 @@ readonly syslogNgStr="syslog-ng" readonly logRotateStr="logrotate" readonly syslogNgCmd="/opt/sbin/$syslogNgStr" readonly logRotateCmd="/opt/sbin/$logRotateStr" -readonly logRotateDir="/opt/etc/${logRotateStr}.d" +readonly logRotateConfDir="/opt/etc/${logRotateStr}.d" readonly logRotateShareDir="/opt/share/$logRotateStr" readonly logRotateExamplesDir="${logRotateShareDir}/examples" readonly logRotateTopConfig="/opt/etc/${logRotateStr}.conf" readonly logRotateGlobalName="A01global" -readonly logRotateGlobalConf="${logRotateDir}/$logRotateGlobalName" +readonly logRotateGlobalConf="${logRotateConfDir}/$logRotateGlobalName" readonly LR_FLock_FD=513 readonly LR_FLock_FName="/tmp/scribeLogRotate.flock" readonly logFilesRegExp="${optVarLogDir}/.*([.]log)?" readonly filteredLogList="${config_d}/.filteredlogs" readonly noConfigLogList="${config_d}/.noconfiglogs" +readonly syslogNg_ConfDir="/opt/etc/${syslogNgStr}.d" readonly syslogNg_ShareDir="/opt/share/$syslogNgStr" readonly syslogNg_ExamplesDir="${syslogNg_ShareDir}/examples" readonly syslogNg_ConfName=${syslogNgStr}.conf @@ -212,6 +213,13 @@ readonly sysLogLinesMAX=20480 readonly sysLogMsgeSizeMAX=2048 sysLogFiFoSizeMIN=1600 +readonly debugMsgDiscardFilterName="A0DebugMsgsDiscard" +readonly debugMsgDiscardFilterConf="${syslogNg_ConfDir}/$debugMsgDiscardFilterName" +readonly debugMsgDiscardFilterSrce="${syslogNg_ExamplesDir}/$debugMsgDiscardFilterName" +readonly debugMsgCaptureFilterName="A0DebugMsgsCapture" +readonly debugMsgCaptureFilterConf="${syslogNg_ConfDir}/$debugMsgCaptureFilterName" +readonly debugMsgCaptureFilterSrce="${syslogNg_ExamplesDir}/$debugMsgCaptureFilterName" + # color constants # readonly red="\033[1;31m" readonly green="\033[1;32m" @@ -533,6 +541,10 @@ Read_Config() then _Config_Option_Update_ LR_CRONJOB_HOUR 24 fi + if ! _Config_Option_Check_ DEBUG_LOG_LEVEL_MSG + then + _Config_Option_Update_ DEBUG_LOG_LEVEL_MSG Allowed + fi if ! _Config_Option_Check_ FILTER_INIT_REBOOT_LOG then _Config_Option_Update_ FILTER_INIT_REBOOT_LOG true @@ -648,12 +660,19 @@ Get_ZIP_File() fi } +##----------------------------------------## +## Modified by Martinski W. [2026-Mar-02] ## +##----------------------------------------## Restart_uiScribe() { + local from="" if "$uiScribeInstalled" then printf "\n$white Restarting ${uiscribeName}...\n" - $uiscribePath startup + if [ $# -gt 0 ] && [ "$1" = "true" ] + then from="Scribe" + fi + $uiscribePath startup $from fi } @@ -662,7 +681,7 @@ Reload_SysLogNg_Config() printf "$white reloading %s ... $cyan" "$( strip_path $sng_conf )" $sngctl_loc reload printf "\n$std" - Restart_uiScribe + Restart_uiScribe "$@" } Copy_SysLogNg_RcFunc() @@ -676,19 +695,20 @@ Copy_SysLogNg_RcFunc() ##-------------------------------------## ## Added by Martinski W. [2026-Feb-27] ## ##-------------------------------------## -_Find_WildcardFile_TopConfigLines_() +_TopLevelConfigLinesCheck_() { if [ $# -eq 0 ] || [ -z "$1" ] || [ ! -s "$1" ] then return 1 fi - local retCode=0 lineNum lineStr1 lineStr2 lineStr3 lineStr4 + local retCode=0 lineNum=1 + local lineStr1 lineStr2 lineStr3 lineStr4 lineStr5 lineStr1='wildcard_file(base_dir("/opt/var/log")' lineStr2='filename_pattern("syslogd.ScribeInitReboot.LOG")' lineStr3='recursive(no) max-files(1) follow_freq(1)' lineStr4='log_iw_size(1200) log_fetch_limit(1000) flags(syslog-protocol))' - - lineNum=1 + lineStr5='filter \{ level\((info|debug)..emerg\); \}' + while read -r theLINE && [ -n "$theLINE" ] do if ! echo "$theLINE" | grep -qF "$(eval echo '$'"lineStr$lineNum")" @@ -698,6 +718,11 @@ _Find_WildcardFile_TopConfigLines_() done < "$noConfigLogList" @@ -2229,7 +2364,7 @@ ScriptUpdateFromAMTM() return "$?" } -menu_forgrnd() +SyslogNg_DebugMode() { local doStart=false if SyslogNg_Running @@ -2706,29 +2841,40 @@ EOF } ##----------------------------------------## -## Modified by Martinski W. [2025-Jan-04] ## +## Modified by Martinski W. [2026-Mar-02] ## ##----------------------------------------## Utils_Menu() { - printf "$magenta %s Utilities ${CLRct}\n\n" "$script_name" - printf " ${GRNct}bu${CLRct}. Backup configuration files\n" - printf " ${GRNct}rt${CLRct}. Restore configuration files\n\n" - printf " ${GRNct}d${CLRct}. Generate debug file\n" - printf " ${GRNct}rd${CLRct}. Re-detect syslog.log location\n" - printf " ${GRNct}ck${CLRct}. Check on-disk %s config\n" "$sng" + local debugLogMsgOpt debugLogMsgOptStr="UNKNOWN" + + debugLogMsgOpt="$(_Config_Option_Get_ DEBUG_LOG_LEVEL_MSG)" + case "$debugLogMsgOpt" in + Discard) debugLogMsgOptStr="Discarded" ;; + Capture) debugLogMsgOptStr="Captured" ;; + Allowed) debugLogMsgOptStr="Allowed" ;; + esac + + printf " ${magenta}%s Utilities${CLRct}\n\n" "$script_name" + printf " ${GRNct}bu${CLRct}. Backup configuration files\n" + printf " ${GRNct}rt${CLRct}. Restore configuration files\n\n" + printf " ${GRNct}d${CLRct}. Generate %s debug file\n" "$script_name" + printf " ${GRNct}rd${CLRct}. Re-detect syslog.log location\n" if SyslogNg_Running then - printf " ${GRNct}lc${CLRct}. Show loaded %s config\n" "$sng" + printf " ${GRNct}lc${CLRct}. Show loaded %s configuration\n" "$sng" fi - printf " ${GRNct}sd${CLRct}. Run %s debugging mode\n" "$sng" - printf " ${GRNct}ld${CLRct}. Show %s debug info\n\n" "$lr" - printf " ${GRNct}ui${CLRct}. " + printf " ${GRNct}ck${CLRct}. Check on-disk %s configuration\n" "$sng" + printf " ${GRNct}sd${CLRct}. Run %s in debugging mode\n" "$sng" + printf " ${GRNct}ld${CLRct}. Show %s debugging information\n" "$lr" + printf " ${GRNct}dm${CLRct}. Messages with 'debug' severity level\n" + printf " [Currently: ${GRNct}${debugLogMsgOptStr}${CLRct}]\n\n" + printf " ${GRNct}ui${CLRct}. " if "$uiScribeInstalled" then printf "Run" else printf "Install" fi printf " %s\n" "$uiscribeName" - printf " ${GRNct}e${CLRct}. Exit to Main Menu\n" + printf " ${GRNct}e${CLRct}. Exit to Main Menu\n" } ##----------------------------------------## @@ -2747,7 +2893,7 @@ Main_Menu() else insPrefix="Rei" fi fi - andLRcron="& $lr cron" + andLRcron="& $lr cron job" if "$scribeInstalled" then @@ -2755,39 +2901,39 @@ Main_Menu() then _ShowSysLogNg_WaitStart_Msge_ fi - printf " ${GRNct}s${CLRct}. Show %s status\n" "$script_name" + printf " ${GRNct}s${CLRct}. Show %s status\n" "$script_name" if SyslogNg_Running then - printf " ${GRNct}rl${CLRct}. Reload %s.conf\n" "$sng" - printf " ${GRNct}lr${CLRct}. Run logrotate now\n" + printf " ${GRNct}lr${CLRct}. Run logrotate now\n" fi if SyslogNg_Running || [ ! -f "$syslogNg_WaitnSEM_FPath" ] then - printf " ${GRNct}rs${CLRct}. %s %s " "${resPrefix}tart" "$sng" + printf " ${GRNct}rs${CLRct}. %s %s " "${resPrefix}tart" "$sng" SyslogNg_Running && echo || printf "${andLRcron}\n" fi if SyslogNg_Running then - printf " ${GRNct}st${CLRct}. Stop %s ${andLRcron}\n" "$sng" - printf " ${GRNct}ct${CLRct}. Set $lr cron job run frequency\n\n" - printf " ${GRNct}u${CLRct}. Check for script updates\n" - printf " ${GRNct}uf${CLRct}. Force update %s with latest version\n" "$script_name" - printf " ${GRNct}ft${CLRct}. Update filters\n" + printf " ${GRNct}rl${CLRct}. Reload %s configuration\n" "$sng" + printf " ${GRNct}st${CLRct}. Stop %s ${andLRcron}\n" "$sng" + printf " ${GRNct}ct${CLRct}. Set $lr cron job run frequency\n\n" + printf " ${GRNct}u${CLRct}. Check for latest script updates\n" + printf " ${GRNct}uf${CLRct}. Force update %s with latest version\n" "$script_name" + printf " ${GRNct}ft${CLRct}. Update filters\n" fi if [ -f "$syslogNg_WaitnSEM_FPath" ] then echo else - printf " ${GRNct}su${CLRct}. %s utilities\n\n" "$script_name" + printf " ${GRNct}su${CLRct}. %s utilities\n\n" "$script_name" fi fi - printf " ${GRNct}e${CLRct}. Exit %s\n" "$script_name" - printf " ${GRNct}is${CLRct}. %s %s\n" "${insPrefix}nstall" "$script_name" - printf " ${GRNct}zs${CLRct}. Remove %s\n" "$script_name" + printf " ${GRNct}e${CLRct}. Exit %s\n" "$script_name" + printf " ${GRNct}is${CLRct}. %s %s\n" "${insPrefix}nstall" "$script_name" + printf " ${GRNct}zs${CLRct}. Remove %s\n" "$script_name" } ##----------------------------------------## -## Modified by Martinski W. [2025-Dec-05] ## +## Modified by Martinski W. [2026-Mar-01] ## ##----------------------------------------## Scribe_Menu() { @@ -2807,7 +2953,7 @@ Scribe_Menu() ;; esac printf "\n$menuSepStr" - printf "$magenta Please select an option: $std" + printf " ${magenta}Please select an option:${std} " read -r choice if "$scribeInstalled" || \ @@ -2852,7 +2998,7 @@ Scribe_Menu() ct) if SyslogNg_Running then - menu_LogRotate_CronJob_Time + Menu_LogRotate_CronJob_Time [ $? -ne 0 ] && pause=false else not_recog=true @@ -2873,8 +3019,13 @@ Scribe_Menu() fi ;; su) - menu_type="utils" - pause=false + if [ "$menu_type" = "main" ] + then + menu_type="utils" + pause=false + else + not_recog=true + fi ;; bu) menu_backup @@ -2904,7 +3055,17 @@ Scribe_Menu() fi ;; sd) - menu_forgrnd + SyslogNg_DebugMode + ;; + dm) if SyslogNg_Running && \ + [ "$menu_type" = "utils" ] + then + if ! DebugLogLevelMsgHandling + then pause=false + fi + else + not_recog=true + fi ;; ld) delfr "$lr_temp" @@ -2932,7 +3093,7 @@ Scribe_Menu() e) if [ "$menu_type" = "main" ] then - printf "\n$white Thanks for using scribe! $std\n\n\n" + printf "\n ${white}Thanks for using scribe!${std}\n\n\n" exit 0 else menu_type="main" diff --git a/syslog-ng.share/A0DebugMsgsCapture b/syslog-ng.share/A0DebugMsgsCapture index d313853..3abf6f5 100644 --- a/syslog-ng.share/A0DebugMsgsCapture +++ b/syslog-ng.share/A0DebugMsgsCapture @@ -1,6 +1,6 @@ ####################################################### # Capture all incoming log messages that are tagged -# with the 'debug' log priority level. +# with the 'debug' severity level. # /opt/var/log/debugMessages.log # Last Modified: 2026-Mar-01 ####################################################### diff --git a/syslog-ng.share/A0DebugMsgsDiscard b/syslog-ng.share/A0DebugMsgsDiscard index 86750b8..68989ec 100644 --- a/syslog-ng.share/A0DebugMsgsDiscard +++ b/syslog-ng.share/A0DebugMsgsDiscard @@ -1,6 +1,6 @@ ####################################################### # Discard all incoming log messages that are tagged -# with the 'debug' log priority level. +# with the 'debug' severity level. # Last Modified: 2026-Mar-01 #######################################################