diff --git a/README.md b/README.md index b9849ff..f1ca255 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.8 -### Updated on 2026-Jan-25 +## v3.2.9 +### Updated on 2026-Feb-07 ## Getting Started diff --git a/init.d/rc.func.syslog-ng b/init.d/rc.func.syslog-ng index a90d559..54f977e 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-Jan-25 -# VERSION="3.1.4" +# Last Modified: 2026-Jan-31 +# VERSION="3.1.5" #------------------------------------------- ## Run the F/W built-in native commands ## @@ -21,12 +21,14 @@ logTagStr="scribe:kill_logger[$$]" logPrioNum="-p 4" ##----------------------------------------## -## Modified by Martinski W. [2026-Jan-25] ## +## Modified by Martinski W. [2026-Jan-30] ## ##----------------------------------------## kill_logger() { local serviceCallOK prevSysLog_Loc messagesLogSAVED local scribeScriptFPath="/jffs/scripts/scribe" + local booleanStr=false filterSyslogInitRebootLogMsgs=true + local syslogD_InitRebootLogPath="/opt/var/log/syslogd.ScribeInitReboot.LOG" local syslogNG_WaitnSEM_FPath="/tmp/var/tmp/scribe_SysLogNg.WAITN.SEM" local syslogNG_StartSEM_FPath="/tmp/var/tmp/scribe_SysLogNg.START.SEM" @@ -42,7 +44,7 @@ kill_logger() if [ ! -f "$syslogNG_StartSEM_FPath" ] then $loggerCmd -t "$logTagStr" $logPrioNum "Calling Scribe SysLogNgStartDelay..." - echo "150" > "$syslogNG_WaitnSEM_FPath" + [ ! -f "$syslogNG_WaitnSEM_FPath" ] && echo "150" > "$syslogNG_WaitnSEM_FPath" nohup "$scribeScriptFPath" SysLogNgStartDelay >/dev/null 2>&1 & exit 1 fi @@ -55,14 +57,14 @@ kill_logger() [ -z "$script_conf" ] && script_conf="/jffs/addons/scribe.d/config" isjffs=false prevSysLog_Loc="$syslog_loc" - messagesLogSAVED="${optmsg}.SAVED.LOG" + messagesLogSAVED="${optmsg}.Scribe_SAVED.LOG" # Figure out where syslogd expects log file to live # if [ -z "$syslog_loc" ] # do NOT look for config file if $syslog_loc is defined # then if [ -s "$script_conf" ] && $grepCmd -q "^SYSLOG_LOC=" "$script_conf" then - syslog_loc="$($grepCmd "^SYSLOG_LOC=" "$script_conf" | $cutCmd -f2 -d'=')" + syslog_loc="$($grepCmd "^SYSLOG_LOC=" "$script_conf" | $cutCmd -d'=' -f2)" elif [ -n "$($pidofCmd syslogd)" ] then findStr="$($psCmd ww | $grepCmd '/syslogd' | $grepCmd -oE '\-O .*/syslog.log')" @@ -79,6 +81,16 @@ kill_logger() fi fi + if [ -s "$script_conf" ] && \ + $grepCmd -q "^FILTER_INIT_REBOOT_LOG=" "$script_conf" + then + booleanStr="$($grepCmd "^FILTER_INIT_REBOOT_LOG=" "$script_conf" | $cutCmd -d'=' -f2)" + fi + if [ "$booleanStr" = "true" ] + then filterSyslogInitRebootLogMsgs=true + else filterSyslogInitRebootLogMsgs=false + fi + if "$serviceCallOK" then $loggerCmd -t "$logTagStr" $logPrioNum "optmsg=[$optmsg]" @@ -131,15 +143,26 @@ kill_logger() $rmCmd -f "$messagesLogSAVED" fi log1Msg="### Top of Log File ###" + printf '' > "$syslogD_InitRebootLogPath" + if [ ! -d "${syslog_loc}-1" ] && \ [ ! -L "${syslog_loc}-1" ] && \ [ -s "${syslog_loc}-1" ] && \ [ "$(head -n1 "${syslog_loc}-1")" != "$log1Msg" ] && \ [ "$(tail -n1 "${syslog_loc}-1")" != "$log1Msg" ] then ## Transfer 1st part of the system log ## - $catCmd "${syslog_loc}-1" >> "$optmsg" + if ! "$filterSyslogInitRebootLogMsgs" + then $catCmd "${syslog_loc}-1" >> "$optmsg" + else $catCmd "${syslog_loc}-1" > "$syslogD_InitRebootLogPath" + fi + fi + if [ -s "$syslog_loc" ] + then + if ! "$filterSyslogInitRebootLogMsgs" + then $catCmd "$syslog_loc" >> "$optmsg" + else $catCmd "$syslog_loc" >> "$syslogD_InitRebootLogPath" + fi fi - [ -s "$syslog_loc" ] && $catCmd "$syslog_loc" >> "$optmsg" $rmCmd -f "$syslog_loc" "${syslog_loc}-1" $lnCmd -snf "$optmsg" "$syslog_loc" echo "$log1Msg" > "${syslog_loc}-1" diff --git a/scribe.sh b/scribe.sh index 6d1c443..b15d6a2 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-Jan-25 +# Last Modified: 2026-Feb-07 #----------------------------------------------------------------- ################ Shellcheck directives ################ @@ -34,9 +34,9 @@ ################################################################# readonly script_name="scribe" -readonly scribe_ver="v3.2.8" -readonly scriptVer_TAG="26012523" -scribe_branch="master" +readonly scribe_ver="v3.2.9" +readonly scriptVer_TAG="26020700" +scribe_branch="develop" script_branch="$scribe_branch" # Ensure firmware binaries are used, not Entware # @@ -196,9 +196,10 @@ readonly syslogNg_ConfName=${syslogNgStr}.conf readonly syslogNg_TopConfig="/opt/etc/$syslogNg_ConfName" readonly syslogNg_WaitnSEM_FPath="${TEMPdir}/scribe_SysLogNg.WAITN.SEM" readonly syslogNg_StartSEM_FPath="${TEMPdir}/scribe_SysLogNg.START.SEM" +readonly syslogD_InitRebootLogFPath="${optVarLogDir}/syslogd.ScribeInitReboot.LOG" readonly sysLogLinesMAX=20480 readonly sysLogMsgeSizeMAX=2048 -sysLogFiFoSizeMIN=1024 +sysLogFiFoSizeMIN=1600 # color constants # readonly red="\033[1;31m" @@ -276,19 +277,20 @@ PressEnterTo() VersionStrToNum() { echo "$1" | sed 's/v//; s/_/./' | awk -F. '{ printf("%d%03d%02d\n", $1, $2, $3); }'; } -md5_file(){ md5sum "$1" | awk '{ printf( $1 ); }'; } +MD5_Hash(){ md5sum "$1" | awk -F' ' '{print $1}' ; } strip_path(){ basename "$1"; } delfr(){ rm -fr "$1"; } -same_same(){ if [ "$( md5_file "$1" )" = "$( md5_file "$2" )" ]; then true; else false; fi; } +Same_MD5_Hash(){ if [ "$(MD5_Hash "$1")" = "$(MD5_Hash "$2")" ]; then true; else false; fi; } -date_stamp(){ [ -e "$1" ] && mv -f "$1" "$1-$( date -Iseconds | cut -c 1-19 )"; } +AppendDateTimeStamp() +{ [ -e "$1" ] && mv -f "$1" "${1}_$(date +'%Y-%m-%d_T%H%M%S')" ; } -SyslogNg_Running(){ if [ -n "$( pidof $sng )" ]; then true; else false; fi; } +SyslogNg_Running(){ if [ -n "$(pidof "$sng")" ]; then true; else false; fi; } -SyslogD_Running(){ if [ -n "$( pidof $sld )" ]; then true; else false; fi; } +SyslogD_Running(){ if [ -n "$(pidof "$sld")" ]; then true; else false; fi; } ##-------------------------------------## ## Added by Martinski W. [2025-Nov-30] ## @@ -500,7 +502,7 @@ Create_Config() } ##----------------------------------------## -## Modified by Martinski W. [2025-Nov-29] ## +## Modified by Martinski W. [2026-Jan-30] ## ##----------------------------------------## Read_Config() { @@ -516,6 +518,10 @@ Read_Config() then _Config_Option_Update_ LR_CRONJOB_HOUR 24 fi + if ! _Config_Option_Check_ FILTER_INIT_REBOOT_LOG + then + _Config_Option_Update_ FILTER_INIT_REBOOT_LOG true + fi # Set correct permissions to avoid "world-readable" status # if [ "$action" != "debug" ] && \ @@ -529,8 +535,8 @@ Read_Config() ##----------------------------------------## Update_File() { - if [ $# -gt 2 ] && [ "$3" = "backup" ] - then date_stamp "$2" + if [ $# -gt 2 ] && [ "$3" = "BACKUP" ] + then AppendDateTimeStamp "$2" fi cp -fp "$1" "$2" } @@ -646,7 +652,7 @@ Reload_SysLogNg_Config() Copy_SysLogNg_RcFunc() { - printf "$white copying %s to %s ...$std" "$rcfunc_sng" "$init_d" + printf " ${white}copying %s to %s ...$std" "$rcfunc_sng" "$init_d" cp -fp "${unzip_dirPath}/init.d/$rcfunc_sng" "$init_d/" chmod 644 "$rcfunc_loc" finished @@ -658,6 +664,7 @@ Copy_SysLogNg_RcFunc() Copy_SysLogNg_Top_Config() { local forceUpdate=false + local diffFile="/opt/tmp/syslogNG_diffs.TEMP.txt" local srceFile="${unzip_dirPath}/${syslogNgStr}.share/${syslogNg_ConfName}-scribe" [ ! -s "$srceFile" ] && return 1 @@ -668,11 +675,31 @@ Copy_SysLogNg_Top_Config() for destFile in "$syslogNg_TopConfig" "${syslogNg_ExamplesDir}/${syslogNg_ConfName}-scribe" do - if [ ! -s "$destFile" ] || "$forceUpdate" + if [ ! -s "$destFile" ] || [ "$destFile" != "$syslogNg_TopConfig" ] then cp -fp "$srceFile" "$destFile" - chmod 644 "$destFile" + elif "$forceUpdate" || ! Same_MD5_Hash "$srceFile" "$destFile" + then + diff -U0 "$srceFile" "$destFile" 2>/dev/null | \ + grep -Ev "^(\-\-\-|\+\+\+)" | grep -E "^(\-|\+)" | \ + grep -Ev "^(\-|\+)[[:blank:]]+log_fifo_size\(" > "$diffFile" + if [ -s "$diffFile" ] && \ + grep -qE "^(\-|\+)" "$diffFile" && \ + [ "$(wc -l < "$diffFile")" -gt 0 ] + then + printf " ${yellow}updating $destFile ..." + Update_File "$srceFile" "$destFile" "BACKUP" + finished + printf " ${red}------------\n ***NOTICE***\n ------------${std}\n" + printf " ${yellow}The file ${green}/opt/etc/syslog-ng.conf${yellow} has been replaced with" + printf " a newer version.\n This means that any custom configuration options that you may" + printf " have added\n or modified in the previously installed file are now removed.\n A backup" + printf " of the previous file was created in the '${green}/opt/etc${yellow}' directory.${std}\n\n" + PressEnterTo "continue..." + fi + rm -f "$diffFile" fi + chmod 644 "$destFile" done } @@ -1064,15 +1091,20 @@ _SysLogMsgSizeFromConfig_() if [ -n "$msgSizeNum" ] && [ "$msgSizeNum" -gt "$sysLogMsgeSizeMAX" ] then msgSizeOK=false fi - "$msgSizeOK" && return 0 - if [ "$1" = "check" ] - then return 1 - elif [ "$1" = "update" ] - then - sed -i "s/log_msg_size($msgSizeNum)/log_msg_size($sysLogMsgeSizeMAX)/g" "$sng_conf" - return 0 - fi + case "$1" in + check) + "$msgSizeOK" && return 0 || return 1 + ;; + update) + "$msgSizeOK" && return 1 #NO Change# + sed -i "s/log_msg_size($msgSizeNum)/log_msg_size($sysLogMsgeSizeMAX)/g" "$sng_conf" + return 0 + ;; + *) + return 1 + ;; + esac } ##-------------------------------------## @@ -1089,25 +1121,30 @@ _SysLogFiFoSizeFromConfig_() if [ -n "$fifoSizeNum" ] && [ "$fifoSizeNum" -lt "$sysLogFiFoSizeMIN" ] then fifoSizeOK=false fi - "$fifoSizeOK" && return 0 - if [ "$1" = "check" ] - then return 1 - elif [ "$1" = "update" ] - then - sed -i "s/log_fifo_size($fifoSizeNum)/log_fifo_size($sysLogFiFoSizeMIN)/g" "$sng_conf" - return 0 - fi + case "$1" in + check) + "$fifoSizeOK" && return 0 || return 1 + ;; + update) + "$fifoSizeOK" && return 1 #NO Change# + sed -i "s/log_fifo_size($fifoSizeNum)/log_fifo_size($sysLogFiFoSizeMIN)/g" "$sng_conf" + return 0 + ;; + *) + return 1 + ;; + esac } ##----------------------------------------## -## Modified by Martinski W. [2026-Jan-03] ## +## Modified by Martinski W. [2026-Jan-29] ## ##----------------------------------------## SysLogNg_Config_Sync() { local sng_conf_vtag1 sng_conf_vtag2 sng_version_str sng_conf_verstr - printf "$white %34s" "$( strip_path "$sng_conf" ) version check ..." + printf " ${white}%34s" "$(strip_path "$sng_conf") options check ..." sng_conf_vtag1="@version:" sng_conf_vtag2="${sng_conf_vtag1}[[:blank:]]*" sng_version_str="$( $sng --version | grep -m1 "$sng" | grep -oE '[0-9]{1,2}([_.][0-9]{1,2})' )" @@ -1118,29 +1155,42 @@ SysLogNg_Config_Sync() ! _SysLogFiFoSizeFromConfig_ check || \ [ "$sng_version_str" != "$sng_conf_verstr" ] then - printf "$red out of sync! (%s) $std\n" "$sng_conf_verstr" - printf "$cyan *** Updating %s and restarting %s *** $std\n" "$( strip_path "$sng_conf" )" "$sng" + printf " ${red}out of sync!${std}\n" + printf " ${cyan}*** Updating %s and restarting %s ***${std}\n" "$(strip_path "$sng_conf")" "$sng" $S01sng_init stop old_doc="doc\/syslog-ng-open" new_doc="list\/syslog-ng-open-source-edition" sed -i "s/$old_doc.*/$new_doc/" "$sng_conf" stats_freq="$( grep -m1 'stats_freq(' "$sng_conf" | cut -d ';' -f 1 | grep -oE '[0-9]*' )" [ -n "$stats_freq" ] && sed -i "s/stats_freq($stats_freq)/stats(freq($stats_freq))/g" "$sng_conf" + if [ -n "$sng_version_str" ] && \ [ -n "$sng_conf_verstr" ] && \ [ "$sng_version_str" != "$sng_conf_verstr" ] then + printf "\n ${red}%34s${std}\n" "version number out of sync!" sed -i "s/^${sng_conf_vtag2}${sng_conf_verstr}.*/$sng_conf_vtag1 $sng_version_str/" "$sng_conf" + printf " ${white}%34s" "$(strip_path "$sng_conf") version ..." + printf " ${yellow}updated! (%s)${std}\n" "$sng_version_str" + logger -t "$script_name" "$(strip_path "$sng_conf") version number updated ($sng_version_str)!" + fi + if _SysLogMsgSizeFromConfig_ update + then + printf "\n ${red}%34s${std}\n" "Log message size out of sync!" + printf " ${white}%34s" "$(strip_path "$sng_conf") log message size ..." + printf " ${yellow}updated! (%d)${std}\n" "$sysLogMsgeSizeMAX" fi - _SysLogMsgSizeFromConfig_ update - _SysLogFiFoSizeFromConfig_ update + if _SysLogFiFoSizeFromConfig_ update + then + printf "\n ${red}%34s${std}\n" "Log FIFO size out of sync!" + printf " ${white}%34s" "$(strip_path "$sng_conf") log FIFO size ..." + printf " ${yellow}updated! (%d)${std}\n" "$sysLogFiFoSizeMIN" + fi + echo $S01sng_init start Restart_uiScribe - printf "$white %34s" "$( strip_path "$sng_conf" ) version ..." - printf "$yellow updated! (%s) $std\n" "$sng_version_str" - logger -t "$script_name" "$( strip_path "$sng_conf" ) version number updated ($sng_version_str)!" else - printf "$green in sync. (%s) $std\n" "$sng_version_str" + printf " ${green}in sync. (v%s)${std}\n" "$sng_version_str" fi } @@ -1156,10 +1206,10 @@ SysLogNg_Config_SyntaxCheck() ##----------------------------------------## ## Modified by Martinski W. [2025-Jul-07] ## ##----------------------------------------## -get_vers() +GetScribeVersion() { # only get scribe from github once # - script_md5="$( md5_file "$script_loc")" + script_md5="$(MD5_Hash "$script_loc")" delfr "$script_tmp_file" curl -LSs --retry 4 --retry-delay 5 --retry-connrefused "$script_repoFile" -o "$script_tmp_file" [ ! -e "$script_tmp_file" ] && \ @@ -1167,7 +1217,7 @@ get_vers() github_ver="$( grep -m1 "scribe_ver=" "$script_tmp_file" | grep -oE "$scribeVerRegExp" )" github_branch="$( grep -m1 "scribe_branch=" "$script_tmp_file" | awk -F\" '{ printf ( $2 ); }'; )" githubVer_long="$github_ver ($github_branch)" - github_md5="$( md5_file "$script_tmp_file")" + github_md5="$(MD5_Hash "$script_tmp_file")" new_vers="none" if [ "$( VersionStrToNum "$github_ver" )" -lt "$( VersionStrToNum "$scribe_ver" )" ]; then new_vers="older" elif [ "$( VersionStrToNum "$github_ver" )" -gt "$( VersionStrToNum "$scribe_ver" )" ]; then new_vers="major" @@ -1176,25 +1226,25 @@ get_vers() delfr "$script_tmp_file" } -prt_vers() +ShowScribeVersion() { - printf "\n$white %34s$green %s \n" "$script_name installed version:" "$scriptVer_long" - printf "$white %34s$green %s $std\n" "$script_name GitHub version:" "$githubVer_long" + printf "\n ${white}%34s ${green}%s\n" "$script_name installed version:" "$scriptVer_long" + printf " ${white}%34s ${green}%s${std}\n" "$script_name GitHub version:" "$githubVer_long" case "$new_vers" in older) - printf "$red Local %s version greater than GitHub version!" "$script_name" + printf " ${red}Local %s version GREATER THAN GitHub version!" "$script_name" ;; major) - printf "$yellow %45s" "New version available for $script_name" + printf " ${yellow}%45s" "New version available for $script_name" ;; minor) - printf "$blue %45s" "Minor patch available for $script_name" + printf " ${blue}%45s" "Minor patch available for $script_name" ;; none) - printf "$green %40s" "$script_name is up to date!" + printf " ${green}%40s" "$script_name is up to date!" ;; esac - printf "$std\n\n" + printf "${std}\n\n" } # Install default file in /opt/etc/$1.d # @@ -1231,7 +1281,7 @@ setup_exmpls() if [ ! -e "$shrfile" ] || [ "$2" = "ALL" ] then Update_File "$exmpl" "$shrfile" - elif ! same_same "$exmpl" "$shrfile" + elif ! Same_MD5_Hash "$exmpl" "$shrfile" then printf " updating %s\n" "$shrfile" Update_File "$exmpl" "$shrfile" @@ -1240,7 +1290,7 @@ setup_exmpls() if [ -e "$conf_opkg" ] then - Update_File "$conf_opkg" "$share/examples/$opkg" "backup" + Update_File "$conf_opkg" "$share/examples/$opkg" "BACKUP" delfr "$conf_opkg" elif [ ! -e "$share/examples/$opkg" ] then @@ -1510,7 +1560,7 @@ Menu_Status() { Check_SysLogNg SysLogd_Check - printf "\n$magenta checking system for necessary %s hooks ...\n\n" "$script_name" + printf "\n ${magenta}checking system for necessary %s hooks ...\n\n" "$script_name" sed_SysLogNg_Init if SyslogNg_Running then sed_srvcEvent @@ -1522,11 +1572,11 @@ Menu_Status() LogRotate_CronJob_Check Check_Dir_Links fi - printf "\n$magenta checking %s configuration ...\n\n" "$sng" + printf "\n ${magenta}checking %s configuration ...\n\n" "$sng" SysLogNg_Config_Sync SysLogNg_Config_SyntaxCheck - get_vers - prt_vers + GetScribeVersion + ShowScribeVersion } sng_ver_chk() @@ -1542,17 +1592,21 @@ sng_ver_chk() fi } +##----------------------------------------## +## Modified by Martinski W. [2026-Jan-30] ## +##----------------------------------------## Setup_SysLogNG() { - printf "\n$magenta setting up %s ...\n$std" "$sng" + printf "\n ${magenta}setting up %s ...${std}\n" "$sng" Copy_SysLogNg_RcFunc + Copy_LogRotate_Global_Options force sed_SysLogNg_Init sed_srvcEvent sed_unMount - if [ "$( md5_file "$sng_share/examples/${sng}.conf-scribe" )" != "$( md5_file "$sng_conf" )" ] + if ! Same_MD5_Hash "$sng_share/examples/${sng}.conf-scribe" "$sng_conf" then - printf "$white %34s" "updating $( strip_path "$sng_conf" ) ..." - Update_File "$sng_share/examples/${sng}.conf-scribe" "$sng_conf" "backup" + printf " ${white}%34s" "updating $(strip_path "$sng_conf") ..." + Update_File "$sng_share/examples/${sng}.conf-scribe" "$sng_conf" "BACKUP" finished fi SysLogNg_Config_Sync @@ -1561,7 +1615,7 @@ Setup_SysLogNG() Setup_LogRotate() { # Assumes since Entware is required/installed, post-mount exists and is properly executable # - printf "\n$magenta setting up %s ...\n" "$lr" + printf "\n ${magenta}setting up %s ...\n" "$lr" LogRotate_CronJob_PostMount_Check LogRotate_CronJob_Check } @@ -1589,7 +1643,7 @@ Do_Install() ##----------------------------------------## Setup_Scribe() { - printf "\n$white setting up %s ...\n" "$script_name" + printf "\n ${white}setting up %s ...\n" "$script_name" cp -fp "$unzip_dirPath/${script_name}.sh" "$script_loc" chmod 0755 "$script_loc" [ ! -e "/opt/bin/$script_name" ] && ln -s "$script_loc" /opt/bin @@ -1723,7 +1777,7 @@ PreInstall_Check() } ##----------------------------------------## -## Modified by Martinski W. [2026-Jan-25] ## +## Modified by Martinski W. [2026-Jan-30] ## ##----------------------------------------## Menu_Install() { @@ -1737,7 +1791,8 @@ Menu_Install() fi echo rm -f "$syslogNg_WaitnSEM_FPath" - echo "1" > "$syslogNg_StartSEM_FPath" + echo '1' > "$syslogNg_StartSEM_FPath" + printf '' > "$syslogD_InitRebootLogFPath" $S01sng_init start if [ ! -e "$lr_loc" ] @@ -1783,22 +1838,16 @@ Menu_Restart() printf "\n ${white}%s ${red}NOT${white} running! ${yellow}Starting...${std}\n" "$sng" $S01sng_init start fi - sleep 1 #Allow time to start up# + sleep 2 #Allow time to start up# Restart_uiScribe } -##----------------------------------------## -## Modified by Martinski W. [2026-Jan-11] ## -##----------------------------------------## -StopSyslogNg() +##-------------------------------------## +## Added by Martinski W. [2026-Jan-30] ## +##-------------------------------------## +_MoveLogMsgsToSystemLogFile_() { local lastNLines logNumLines logFileSize - local messagesLogSAVED="${optmsg}.SAVED.LOG" - - printf "\n ${white}Stopping %s...\n" "$sng" - $S01sng_init stop - # Remove any syslog links # - Clear_Syslog_Links ## Do NOT move very large files into JFFS/TMPFS ## lastNLines=100 @@ -1818,10 +1867,28 @@ StopSyslogNg() fi fi tail -n $lastNLines "$optmsg" > "$syslog_loc" +} + +##----------------------------------------## +## Modified by Martinski W. [2026-Jan-30] ## +##----------------------------------------## +StopSyslogNg() +{ + local messagesLogSAVED="${optmsg}.Scribe_SAVED.LOG" + + printf "\n ${white}Stopping %s...\n" "$sng" + $S01sng_init stop + # Remove any syslog links # + Clear_Syslog_Links - if ! "$usbUnmountCaller" - then rm -f "$messagesLogSAVED" - else mv -f "$optmsg" "$messagesLogSAVED" + ##OFF##_MoveLogMsgsToSystemLogFile_ + printf '' > "$syslog_loc" + printf '' > "${syslog_loc}-1" + printf '' > "$syslogD_InitRebootLogFPath" + + if [ -s "$optmsg" ] + then + mv -f "$optmsg" "$messagesLogSAVED" fi ln -snf "$syslog_loc" "$optmsg" @@ -1971,7 +2038,7 @@ Menu_Filters() for upd_file in "$check_dir"/* do comp_file="$comp_dir/$( strip_path "$upd_file" )" - if [ -e "$comp_file" ] && ! same_same "$upd_file" "$comp_file" + if [ -e "$comp_file" ] && ! Same_MD5_Hash "$upd_file" "$comp_file" then processed=false printf "\n$white Update available for$yellow %s$white.\n" "$upd_file" @@ -1982,11 +2049,11 @@ Menu_Filters() case "$dispo" in a) Update_File "$comp_file" "$upd_file" - printf "\n$green %s updated!$std\n" "$upd_file" + printf "\n ${green}%s updated!${std}\n" "$upd_file" processed=true ;; r) - printf "\n$magenta %s not updated!$std\n" "$upd_file" + printf "\n ${magenta}%s not updated!${std}\n" "$upd_file" processed=true ;; v) @@ -2010,46 +2077,50 @@ Menu_Filters() } ##----------------------------------------## -## Modified by Martinski W. [2026-Jan-25] ## +## Modified by Martinski W. [2026-Jan-30] ## ##----------------------------------------## Menu_Update() { + local doUpdate=false + if [ $# -eq 0 ] || [ -z "$1" ] then if [ "$new_vers" = "major" ] || [ "$new_vers" = "minor" ] then if [ "$new_vers" = "major" ] - then printf "\n$green New version" - else printf "\n$cyan Minor patch" + then printf "\n ${green}New version" + else printf "\n ${cyan}Minor patch" fi - printf "$white available!\n" - printf " Do you wish to upgrade? [y|n]$std " + printf " ${white}available!\n" + printf " Do you wish to upgrade? [y|n]${std} " else - printf "\n$white No new version available. (GitHub version" + printf "\n ${white}No new version available. GitHub version" if [ "$new_vers" = "none" ] - then printf " equal to " - else printf "$red LESS THAN $white" + then printf " equal to" + else printf " ${red}LESS THAN$white" fi - printf "local version)\n" - printf " Do you wish to force re-installation of %s script? [y|n]$std " "$script_name" + printf " local version.\n" + printf " Do you wish to force re-installation of %s? [y|n]${std} " "$script_name" fi + Yes_Or_No && doUpdate=true || doUpdate=false fi - if { [ $# -gt 0 ] && [ "$1" = "force" ] ; } || Yes_Or_No + if { [ $# -gt 0 ] && [ "$1" = "force" ] ; } || "$doUpdate" then Get_ZIP_File Setup_Scribe "NEWER" Copy_SysLogNg_RcFunc Copy_SysLogNg_Top_Config "$@" Copy_LogRotate_Global_Options "$@" - printf "\n$white %s updated!$std\n" "$script_name" + printf "\n ${white}%s updated!${std}\n" "$script_name" rm -f "$syslogNg_WaitnSEM_FPath" - echo "1" > "$syslogNg_StartSEM_FPath" + echo '1' > "$syslogNg_StartSEM_FPath" + printf '' > "$syslogD_InitRebootLogFPath" sh "$script_loc" filters gotzip nologo sh "$script_loc" status nologo run_scribe=true else - printf "\n$white *** %s$red not$white updated! *** $std\n\n" "$script_name" + printf "\n ${white}*** %s ${red}NOT${white} updated! *** ${std}\n\n" "$script_name" fi } @@ -2060,8 +2131,8 @@ Update_Version() { if SyslogNg_Running then - get_vers - prt_vers + GetScribeVersion + ShowScribeVersion Menu_Update "$@" else not_recog=true @@ -2070,7 +2141,7 @@ Update_Version() menu_forgrnd() { - restrt=false + local doStart=false if SyslogNg_Running then warning_sign @@ -2079,20 +2150,20 @@ menu_forgrnd() printf " Debugging mode is intended for troubleshooting when\n" printf " %s will not start.\n\n" "$sng" printf " Are you certain you wish to start debugging mode [y|n]? $std" - if ! Yes_Or_No; then return; fi - restrt=true + if ! Yes_Or_No; then return 1; fi + doStart=true fi printf "\n$yellow NOTE: If there are no errors, debugging mode will\n" printf " continue indefinitely. If this happens, type\n" printf " to halt debugging mode output.\n\n" PressEnterTo "start:" - if "$restrt" + if "$doStart" then $S01sng_init stop; echo fi trap '' 2 $sng_loc -Fevd trap - 2 - if "$restrt" + if "$doStart" then echo ; $S01sng_init start fi echo @@ -2107,7 +2178,7 @@ Gather_Debug() delfr "$script_debug" "$debugTarball" printf "\n$white gathering debugging information...\n" - get_vers + GetScribeVersion { printf "%s\n" "$debug_sep" @@ -2215,7 +2286,7 @@ Gather_Debug() menu_backup() { printf "\n$white Backing up %s and %s Configurations ... \n" "$sng" "$lr" - date_stamp "$script_bakname" + AppendDateTimeStamp "$script_bakname" tar -zcvf "$script_bakname" "$sng_conf" "$sngd_d" "$lr_conf" "$lrd_d" "$config_d" printf "\n$std Backup data is stored in $cyan%s$std.\n\n" "$script_bakname" } @@ -2281,7 +2352,9 @@ _LogDebugMsg_() then echo "${timeNow}: $1" > "$logFilePath" else echo "${timeNow}: $1" >> "$logFilePath" fi - logger -t "$logTagStr" "$1" + if [ $# -gt 1 ] && [ "$2" != "false" ] + then logger -t "$logTagStr" "$1" + fi } trap '' HUP @@ -2326,24 +2399,23 @@ do then sysLogNg_Param=start else sysLogNg_Param=restart fi - _LogDebugMsg_ "Calling [$S01syslogNg_srvc $sysLogNg_Param]..." rm -f "$syslogNg_WaitnSEM_FPath" + _LogDebugMsg_ "Calling [$S01syslogNg_srvc $sysLogNg_Param]..." true echo "$cntSleepSecs" > "$syslogNg_StartSEM_FPath" - "$S01syslogNg_srvc" "$sysLogNg_Param" - - _LogDebugMsg_ "Exiting Background Loop [$cntSleepSecs][$$]..." + nohup "$S01syslogNg_srvc" "$sysLogNg_Param" & + _LogDebugMsg_ "Exiting Background Loop [$cntSleepSecs][$$]..." true break fi if [ "$cntSleepSecs" -ge "$sleepSecsMAX" ] then rm -f "$syslogNg_WaitnSEM_FPath" - _LogDebugMsg_ "Exiting Background Loop [$cntSleepSecs][$$]..." - break #Escape WITHOUT starting service# + _LogDebugMsg_ "Exiting Background Loop [$cntSleepSecs][$$]..." true + break #Escape WITHOUT starting service??# fi if "$timeCheckStatus" then - _LogDebugMsg_ "Sleeping $checkSecs secs [$cntSleepSecs][$$]..." + _LogDebugMsg_ "Sleeping $checkSecs secs [$cntSleepSecs][$$]..." true fi sleep "$sleepSecs" cntSleepSecs="$((cntSleepSecs + sleepSecs))" @@ -2354,7 +2426,7 @@ do fi done -_LogDebugMsg_ "End of Background Script [$scriptFName][$$]" +_LogDebugMsg_ "End of Background Script [$scriptFName][$$]" false rm -f "$0" #EOF# @@ -2489,7 +2561,6 @@ _Launch_SysLoggerCheck_BGScript_() fi "$bgScript_FPath" & taskPID=$! - logger -st "$logTag" -p 5 "INFO: Background script [$bgScript_FName] started. PID: [$taskPID]" } ##----------------------------------------## @@ -2830,7 +2901,6 @@ SetUpRepoBranchVars ## Increase FIFO queue size if 1GB RAM or more ## if _HasRouterMoreThan512MBtotalRAM_ then sysLogFiFoSizeMIN=2048 -else sysLogFiFoSizeMIN=1024 fi if ! SyslogD_Running && ! SyslogNg_Running && \ @@ -2842,7 +2912,8 @@ then fi if [ "$action" != "help" ] && \ - [ "$action" != "about" ] + [ "$action" != "about" ] && \ + [ "$action" != "install" ] then # Read or create config file # Read_Config @@ -2933,13 +3004,16 @@ case "$action" in then Menu_Restart Menu_Status + cliParamCheck=false fi ;; #Stop syslog-ng & logrotate Cron Job# stop) if SyslogNg_Running || "$usbUnmountCaller" - then Menu_Stop + then + Menu_Stop + cliParamCheck=false fi ;; @@ -3030,9 +3104,7 @@ esac if ! "$scribeInstalled" && "$cliParamCheck" then printf "\n${yellow} %s ${white}is NOT installed, command \"%s\" not valid!${std}\n\n" "$script_name" "$action" -elif ! SyslogNg_Running && \ - "$cliParamCheck" && \ - [ "$action" != "stop" ] +elif ! SyslogNg_Running && "$cliParamCheck" then printf "\n${yellow} %s ${white}is NOT running, command \"%s\" not valid!${std}\n\n" "$sng" "$action" else diff --git a/syslog-ng.share/README.1ST b/syslog-ng.share/README.1ST index 90993b5..fffa873 100644 --- a/syslog-ng.share/README.1ST +++ b/syslog-ng.share/README.1ST @@ -1,6 +1,6 @@ -### README.1ST --- 22 June 2020 +### README.1ST --- Revised: 2026-Jan-30 -Please READ before copying any of these files to /opt/etc/syslog-ng.d/ +Please READ *BEFORE* copying any of these files to /opt/etc/syslog-ng.d/ **** If you simply copy all of the files in this directory to **** **** /opt/etc/syslog-ng.d/ the next time you try to restart **** @@ -12,18 +12,21 @@ log files. Note that when copying the files, they must be writable by the user only, i.e. chmod 600. If the group or others can write to them, they will not be loaded by syslog-ng. -It is highly recommended to copy the corresponding file of the same name -in /opt/share/logrotate/examples/ to /opt/etc/logroate.d/ to ensure the -log files do not grow too large. If there is not corresponding file in -/opt/share/logrotate/examples, then either the file is not intended to be -used permanently (e.g. expandlog); or should generate no or very few log -entries (e.g. blankmsg, errormsg); or its logs are handled by other -programs (e.g. skynet). +It is NOT required to copy the corresponding file of the same name found +in "/opt/share/logrotate/examples" to "/opt/etc/logrotate.d" directory. +The logrotate configuration files are optional; they are needed ONLY IF +you want to override any of the default global directives already preset +in the "A00global" and "A01global" configuration files. -Notes: 1) All ".log" files will be in /opt/var/log/. +If there's not corresponding file in "/opt/share/logrotate/examples" then +either the file is not intended to be used permanently (e.g. expandlog); +or should generate no or very few log entries (e.g. blankmsg, errormsg); +or its logs are handled by some other programs (e.g. skynet). + +Notes: 1) All ".log" files MUST be in the "/opt/var/log" directory. 2) Unless otherwise noted, all filters are "final", meaning - messages matched by the filter will not be logged in the - default messages file. + messages matched by the filter will NOT be logged in the + default "/opt/var/log/messages" log file. The files in this directory are: A00remote Sends _ALL_ messages to a remote logging facility before diff --git a/syslog-ng.share/syslog-ng.conf-scribe b/syslog-ng.share/syslog-ng.conf-scribe index e00d53e..2858b5a 100644 --- a/syslog-ng.share/syslog-ng.conf-scribe +++ b/syslog-ng.share/syslog-ng.conf-scribe @@ -1,11 +1,14 @@ ############################################################################# # syslog-ng.conf customized for Scribe on Asuswrt-Merlin firmware -# Compare to /opt/share/syslog-ng/examples/syslog-ng.conf-opkg for differences from the Entware distribution +# Last Modified: 2026-Feb-01 +# +# Compare to /opt/share/syslog-ng/examples/syslog-ng.conf-opkg for +# differences from the Entware distribution # # syslog-ng documentation: https://www.syslog-ng.com/technical-documents/list/syslog-ng-open-source-edition # # Release notes: https://github.com/syslog-ng/syslog-ng/releases - +# @version: 4.7 #@include "scl.conf" # uncomment this line to for additional functionality, see syslog-ng documentation @include "/opt/etc/syslog-ng.d/" # Put any customization files in this directory @@ -14,7 +17,7 @@ options { chain_hostnames(no); # Enable or disable the chained hostname format. create_dirs(yes); keep_hostname(yes); # Enable or disable hostname rewriting. - log_fifo_size(1024); # The number of messages that the output queue can store. + log_fifo_size(1500); # The number of messages that the output queue can store. log_msg_size(2048); # Maximum length of a message in bytes. stats(freq(21600)); # The period between two STATS messages sent by syslog-ng, containing statistics about dropped logs in seconds; 0 disables. (21,600 seconds = 6 hours) flush_lines(0); # How many lines are flushed to a destination at a time. @@ -27,24 +30,31 @@ options { source src { unix-dgram("/dev/log" so_rcvbuf(65536) flags(syslog-protocol)); file("/proc/kmsg" program_override("kernel") flags(kernel)); + wildcard_file(base_dir("/opt/var/log") + filename_pattern("syslogd.ScribeInitReboot.LOG") + recursive(no) max-files(1) follow_freq(1) + log_iw_size(1200) log_fetch_limit(1000) flags(syslog-protocol)); internal(); -#OFF# udp(ip(192.168.x.y) port(514)); # uncomment this line to pass all network messages through syslog-ng filters +# uncomment the line below to pass ALL network log messages through syslog-ng filters # +#OFF# udp(port(514) flags(syslog-protocol)); }; # if you only want to pass network messages through some syslog-ng filters, uncomment the source line below -# then add "source(net);" to the log statement in any filter you want to pass network messages through -#OFF# source net { udp(ip(192.168.x.y) port(514)); }; +# then add "source(s_net);" to the log statement in any filter you want to pass network messages through +#OFF# source s_net { udp(port(514) flags(syslog-protocol)); }; -# set the filename for the default log file - anything not filtered out will end up here +# set the filename for the default log file - anything not filtered out will end up here # destination messages { file("/opt/var/log/messages"); }; -# to send log messages to the local network, uncomment the destination line below +# to send log messages to the local network, uncomment the destination line below # # then add "destination(log_server);" to the log statement in any filter you want to pass network messages through #OFF# destination log_server { udp("192.168.x.y" port(514)); }; log { source(src); -#OFF# source(net); # uncomment this and "source net" function above to get udp log messages from local network +# uncomment this and "source s_net" function above to get udp log messages from local network # +#OFF# source(s_net); destination(messages); -#OFF# destination(log_server); # uncomment this and "destination log_server" function above to send udp log messages to local network +# uncomment this and "destination log_server" function above to send udp log messages to local network # +#OFF# destination(log_server); };