Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fe5213e
Improvements and Fine-Tuning
Martinski4GitHub Jan 4, 2026
7489ea7
Merge pull request #48 from Martinski4GitHub/develop
Martinski4GitHub Jan 4, 2026
8c1306b
Improvements and Fine-Tuning
Martinski4GitHub Jan 4, 2026
d5de94d
Merge pull request #49 from Martinski4GitHub/develop
Martinski4GitHub Jan 4, 2026
7ddf468
Improvements and Fine-Tuning
Martinski4GitHub Jan 4, 2026
76e9ad5
Merge pull request #50 from Martinski4GitHub/develop
Martinski4GitHub Jan 4, 2026
abe71a2
More Improvements and Fine-Tuning
Martinski4GitHub Jan 5, 2026
00edb52
Merge pull request #51 from Martinski4GitHub/develop
Martinski4GitHub Jan 5, 2026
9e109cf
Improvements and Fine-Tuning.
Martinski4GitHub Jan 6, 2026
277a9d1
Merge pull request #52 from Martinski4GitHub/develop
Martinski4GitHub Jan 6, 2026
bacb15c
Fixes and Improvements
Martinski4GitHub Jan 12, 2026
13e105e
Merge pull request #53 from Martinski4GitHub/develop
Martinski4GitHub Jan 12, 2026
7a683d3
Code Improvements
Martinski4GitHub Jan 13, 2026
f336ee3
Merge pull request #54 from Martinski4GitHub/develop
Martinski4GitHub Jan 13, 2026
836a249
Update syslog-ng.conf-scribe
Martinski4GitHub Jan 16, 2026
8f9f93e
Update rc.func.syslog-ng
Martinski4GitHub Jan 16, 2026
7be7e4f
Code Improvements and Fine-Tuning
Martinski4GitHub Jan 16, 2026
05832e2
Merge pull request #55 from Martinski4GitHub/develop
Martinski4GitHub Jan 16, 2026
4b35f0f
Removed "postrotate/endscript" directives
Martinski4GitHub Jan 20, 2026
2fa5dc7
Merge pull request #56 from Martinski4GitHub/develop
Martinski4GitHub Jan 20, 2026
2b14cbd
Update README.md
Martinski4GitHub Jan 25, 2026
4bfd76b
Merge pull request #57 from Martinski4GitHub/develop
Martinski4GitHub Jan 25, 2026
0d6673f
Merge branch 'master' into develop
Martinski4GitHub Jan 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

**scribe** is a **syslog-ng** and **logrotate** installer for ASUS routers running **Asuswrt-Merlin**

## v3.2.6
### Updated on 2025-Dec-22
## v3.2.7
### Updated on 2026-Jan-24

## Getting Started

Expand Down
181 changes: 107 additions & 74 deletions init.d/rc.func.syslog-ng
Original file line number Diff line number Diff line change
@@ -1,39 +1,63 @@
#!/bin/sh -
#
# NB: rc.func only runs PRECMD on "start"
# Last Modified: 2025-Nov-23
# VERSION="3.1.2"
# Last Modified: 2026-Jan-15
# VERSION="3.1.3"
#-------------------------------------------

## Run the F/W built-in native commands ##
psCmd="$(which -a ps | grep -v '^/opt/')"
awkCmd="$(which -a awk | grep -v '^/opt/')"
cutCmd="$(which -a cut | grep -v '^/opt/')"
grepCmd="$(which -a grep | grep -v '^/opt/')"
pidofCmd="$(which -a pidof | grep -v '^/opt/')"
loggerCmd="$(which -a logger | grep -v '^/opt/')"
logTagStr="Scribe:kill_logger[$$]"
psCmd="$(which -a ps | $grepCmd -v '^/opt/')"
rmCmd="$(which -a rm | $grepCmd -v '^/opt/')"
lnCmd="$(which -a ln | $grepCmd -v '^/opt/')"
lsCmd="$(which -a ls | $grepCmd -v '^/opt/')"
awkCmd="$(which -a awk | $grepCmd -v '^/opt/')"
catCmd="$(which -a cat | $grepCmd -v '^/opt/')"
cutCmd="$(which -a cut | $grepCmd -v '^/opt/')"
pidofCmd="$(which -a pidof | $grepCmd -v '^/opt/')"
loggerCmd="$(which -a logger | $grepCmd -v '^/opt/')"
logTagStr="scribe:kill_logger[$$]"
logPrioNum="-p 4"

##----------------------------------------##
## Modified by Martinski W. [2025-Nov-21] ##
## Modified by Martinski W. [2026-Jan-11] ##
##----------------------------------------##
kill_logger()
{
# these will be set if coming from scribe; on bootup, these will not be set #
local serviceCallOK prevSysLog_Loc messagesLogSAVED
local scribeScriptFPath="/jffs/scripts/scribe"
local syslogNg_WaitnSEM_FPath="/tmp/var/tmp/scribe_SysLogNg.WAITN.SEM"
local syslogNg_StartSEM_FPath="/tmp/var/tmp/scribe_SysLogNg.START.SEM"

if [ $# -eq 0 ] || [ -z "$1" ] || [ "$1" = "true" ]
then
serviceCallOK=true
else
serviceCallOK=false
[ ! -f "$syslogNg_StartSEM_FPath" ] && exit 1
fi

# If START Semaphore NOT found, call Scribe to set it up after a specified delay #
if [ ! -f "$syslogNg_StartSEM_FPath" ]
then
$loggerCmd -t "$logTagStr" $logPrioNum "Calling Scribe SysLogNgStartDelay..."
echo "150" > "$syslogNg_WaitnSEM_FPath"
nohup "$scribeScriptFPath" SysLogNgStartDelay >/dev/null 2>&1 &
exit 1
fi
$rmCmd -f "$syslogNg_WaitnSEM_FPath" #Done waiting. We can start now#

# These will be set if coming from Scribe; on bootup, these will NOT be set #
[ -z "$tmplog" ] && tmplog="/tmp/syslog.log"
[ -z "$jffslog" ] && jffslog="/jffs/syslog.log"
[ -z "$optmsg" ] && optmsg="/opt/var/log/messages"
[ -z "$script_conf" ] && script_conf="/jffs/addons/scribe.d/config"
isjffs=false
prevSysLog_Loc="$syslog_loc"
messagesLogSAVED="${optmsg}.SAVED.LOG"

if [ $# -eq 0 ] || [ -z "$1" ]
then postLogMsgs=true
else postLogMsgs=false
fi

# figure out where syslogd expects log file to live #
if [ -z "$syslog_loc" ] # don't look for config file if $syslog_loc is defined #
# 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
Expand All @@ -49,12 +73,12 @@ kill_logger()
syslog_loc="$tmplog" # Make a reasonable guess #
fi
elif [ -z "$syslog_loc" ]
then # no config file, $syslog_loc not set, & syslogd not running!!!
then # NO config file, $syslog_loc not set, & syslogd not running!!!
syslog_loc="$tmplog" # Make a reasonable guess #
fi
fi

if "$postLogMsgs"
if "$serviceCallOK"
then
$loggerCmd -t "$logTagStr" $logPrioNum "optmsg=[$optmsg]"
$loggerCmd -t "$logTagStr" $logPrioNum "syslog_loc=[$syslog_loc]"
Expand All @@ -63,71 +87,80 @@ kill_logger()

[ "$syslog_loc" = "$jffslog" ] && isjffs=true

# kill any/all running klogd and/or syslogd #
count=30
klgk=false
sldk=false
while [ "$count" -gt 0 ]
do
[ -n "$( $pidofCmd klogd )" ] && killall -q klogd
[ -n "$( $pidofCmd syslogd )" ] && killall -q syslogd
sleep 2 # give them a moment to shut down / unknown process to restart them #
[ -z "$( $pidofCmd klogd )" ] && klgk=true
[ -z "$( $pidofCmd syslogd )" ] && sldk=true
if "$klgk" && "$sldk" ; then count=-1 ; fi
count="$(( count - 1 ))"
done
[ "$count" -eq 0 ] && exit 1

# if syslog-ng was stopped by Scribe, /opt/var/log/messages will symlink to '$syslog_loc' #
[ -L "$optmsg" ] && /bin/rm -f "$optmsg"

# if syslogd was running, '$syslog_loc' will exist and be a regular file (NOT a link) #
# this might be during bootup, or when starting scribe #
# 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

# Export timezone if not already set #
[ -z "${TZ:+xSETx}" ] && export TZ="$($catCmd /etc/TZ)"

if [ "$prevSysLog_Loc" = "$syslog_loc" ] && ! "$serviceCallOK"
then return 0
fi

##----------------------------------------##
## Modified by Martinski W. [2026-Jan-10] ##
##----------------------------------------##
# Kill any/all running klogd and/or syslogd #
[ -n "$( $pidofCmd klogd )" ] && killall -q klogd
[ -n "$( $pidofCmd syslogd )" ] && killall -q syslogd
# Give them a moment to shut down / unknown process to restart them #
usleep 500000 #0.5 sec#
# Background process to check and make sure built-in system loggers are terminated #
nohup "$scribeScriptFPath" SysLoggerCheck >/dev/null 2>&1 &

# If syslog-ng was stopped by Scribe, /opt/var/log/messages will symlink to '$syslog_loc' #
[ -L "$optmsg" ] && $rmCmd -f "$optmsg"

##----------------------------------------##
## Modified by Martinski W. [2026-Jan-11] ##
##----------------------------------------##
# If syslogd was running, '$syslog_loc' will exist as a regular file (NOT a link) #
# This might be during bootup, or when starting Scribe #
if [ ! -L "$syslog_loc" ]
then
/bin/cat "$syslog_loc" >> "$optmsg"
/bin/rm -f "$syslog_loc" "$syslog_loc-1"
/bin/ln -s "$optmsg" "$syslog_loc"
echo "### Top of Log File ###" >> "${syslog_loc}-1"
if [ -s "$messagesLogSAVED" ]
then
$catCmd "$messagesLogSAVED" >> "$optmsg"
$rmCmd -f "$messagesLogSAVED"
fi
log1Msg="### Top of Log File ###"
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"
fi
$catCmd "$syslog_loc" >> "$optmsg"
$rmCmd -f "$syslog_loc" "${syslog_loc}-1"
$lnCmd -s "$optmsg" "$syslog_loc"
echo "$log1Msg" > "${syslog_loc}-1"
fi

# make /jffs/syslog.log and log-1 directories if default syslog location is not at /jffs #
# prevents system log saver from writing to jffs (not strictly necessary on newer routers) #
# Make /jffs/syslog.log and .log-1 directories if default syslog location is NOT at /jffs #
# Prevents system log saver from writing to jffs (not strictly necessary on newer routers) #
if ! "$isjffs" && [ ! -d "$jffslog" ]
then
/bin/rm -rf "$jffslog" "$jffslog-1"
/bin/mkdir "$jffslog" "$jffslog-1"
$rmCmd -rf "$jffslog" "${jffslog}-1"
/bin/mkdir "$jffslog" "${jffslog}-1"
elif "$isjffs"
then
# if syslogd is writing to /jffs, then ensure logfiles in /tmp #
# are properly linked in case something goes looking there #
[ ! -L "$tmplog" ] && /bin/ln -s "$optmsg" "$tmplog"
[ ! -L "$tmplog-1" ] && /bin/ln -s "${syslog_loc}-1" "${tmplog}-1"
fi

if "$postLogMsgs"
then
$loggerCmd -t "$logTagStr" $logPrioNum "optmsg=[$(ls -ld "$optmsg")]"
$loggerCmd -t "$logTagStr" $logPrioNum "syslog_loc=[$(ls -ld "$syslog_loc")]"
$loggerCmd -t "$logTagStr" $logPrioNum "script_conf=[$(ls -ld "$script_conf")]"
# If syslogd is writing to /jffs, then ensure logfiles in /tmp #
# are properly linked, in case something goes looking there #
[ ! -L "$tmplog" ] && $lnCmd -s "$optmsg" "$tmplog"
[ ! -L "${tmplog}-1" ] && $lnCmd -s "${syslog_loc}-1" "${tmplog}-1"
fi

# create /opt/var/run/syslog-ng/ directory if it doesn't exist #
# not needed for older versions of syslog-ng, but doesn't hurt anything #
[ ! -d "/opt/var/run/syslog-ng" ] && mkdir "/opt/var/run/syslog-ng"

# 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

# export timezone if not already set #
[ -z "${TZ:+xSETx}" ] && export TZ="$(/bin/cat /etc/TZ)"
# Create /opt/var/run/syslog-ng/ directory if it doesn't exist #
# Not needed for older versions of syslog-ng, but doesn't hurt anything #
[ ! -d "/opt/var/run/syslog-ng" ] && /bin/mkdir "/opt/var/run/syslog-ng"
}

PRECMD="kill_logger"
Expand Down
3 changes: 0 additions & 3 deletions logrotate.share/acsd
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/opt/var/log/acsd.log {
rotate 2
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/afpd
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/opt/var/log/afpd.log {
rotate 2
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/bcm63xx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/opt/var/log/bcm63.log {
monthly
rotate 1
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/bsd
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/opt/var/log/bsd.log {
rotate 2
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/crash
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/opt/var/log/crash.log {
minsize 1024k
daily
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
4 changes: 1 addition & 3 deletions logrotate.share/diversion
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/opt/var/log/diversion.log {
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
minsize 512k
}
4 changes: 1 addition & 3 deletions logrotate.share/ethernet
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/opt/var/log/ethernet.log {
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
minsize 512k
}
3 changes: 0 additions & 3 deletions logrotate.share/hostapd
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/opt/var/log/hostapd.log {
rotate 2
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/ioctl
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/opt/var/log/ioctl.log {
monthly
rotate 1
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/jffs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
minsize 1024k
daily
rotate 1
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
4 changes: 1 addition & 3 deletions logrotate.share/meshUDB
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/opt/var/log/meshUDB.log {
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
minsize 512k
}
3 changes: 0 additions & 3 deletions logrotate.share/netdata
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
minsize 1024k
daily
rotate 9
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
4 changes: 1 addition & 3 deletions logrotate.share/ntpd
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/opt/var/log/ntp.log {
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
minsize 512k
}
3 changes: 0 additions & 3 deletions logrotate.share/openvpn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
minsize 1024k
daily
rotate 9
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/pixelserv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
minsize 1024K
daily
rotate 9
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
3 changes: 0 additions & 3 deletions logrotate.share/roamast
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/opt/var/log/roamast.log {
daily
rotate 7
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
4 changes: 1 addition & 3 deletions logrotate.share/spdmerlin
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/opt/var/log/spdmerlin.log {
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
minsize 512k
}
3 changes: 0 additions & 3 deletions logrotate.share/suricata
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
minsize 1024k
daily
rotate 9
postrotate
/usr/bin/killall -HUP syslog-ng
endscript
}
Loading