Last active
June 11, 2023 06:52
-
-
Save ljm42/f6d7d8f22d2965909f69c03df53529f6 to your computer and use it in GitHub Desktop.
copy custom rsyslog filter configurations for Unraid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# copy custom rsyslog filter configurations | |
# latest version: https://gist.github.com/ljm42/f6d7d8f22d2965909f69c03df53529f6 | |
# | |
# setup: | |
# 1. create the /boot/config/custom/rsyslog.d/ folder on your flash drive | |
# 2. place this script in that folder, name it rsyslog_copy | |
# 3. add this line to the top of your go script (before starting emhttp): | |
# bash /boot/config/custom/rsyslog.d/rsyslog_copy | |
# | |
# to test new rsyslog filters: | |
# * add or edit a .conf file in /boot/config/custom/rsyslog.d/ | |
# * then at the shell type: | |
# bash /boot/config/custom/rsyslog.d/rsyslog_copy | |
# * this will copy the .conf file and restart rsyslogd if it is running | |
# * then review your local syslogs at /mnt/user/system/ (or wherever you have configured them to go) | |
# | |
# note: the syntax for the filters is complex and beyond the scope of this script | |
# see: https://www.rsyslog.com/doc/v8-stable/configuration/filters.html | |
# | |
# also see: # https://forums.unraid.net/topic/55459-add-option-for-remote-syslog-in-webgui/ | |
# | |
SCRIPT=$(basename $0) | |
for FILE in /boot/config/custom/rsyslog.d/*.conf; do | |
DEST="/etc/rsyslog.d/$(basename $FILE)" | |
echo "$SCRIPT: copying $DEST" | |
logger "$SCRIPT: copying $DEST" | |
fromdos < $FILE > $DEST | |
done | |
chmod 644 /etc/rsyslog.d/*.conf | |
if [ -d "/mnt/user" ]; then | |
# the array is running, restart rsyslogd | |
echo "$SCRIPT: restarting rsyslogd" | |
logger "$SCRIPT: restarting rsyslogd" | |
/etc/rc.d/rc.rsyslogd restart > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment