-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move daemon.* to /var/log/messages #12433
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
# platform = multi_platform_all | ||
|
||
declare -A REMOTE_METHODS=( ['auth.*']='^[^#]*auth\.\*.*$' ['authpriv.*']='^[^#]*authpriv\.\*.*$' ['daemon.*']='^[^#]*daemon\.\*.*$' ) | ||
declare -A LOCATIONS=( ['auth.*']='/var/log/secure' ['authpriv.*']='/var/log/secure' ['daemon.*']='/var/log/messages' ) | ||
|
||
if [[ ! -f /etc/rsyslog.conf ]]; then | ||
# Something is not right, create the file | ||
touch /etc/rsyslog.conf | ||
fi | ||
|
||
APPEND_LINE=$(sed -rn '/^\S+\s+\/var\/log\/secure$/p' /etc/rsyslog.conf) | ||
|
||
# Loop through the remote methods associative array | ||
for K in "${!REMOTE_METHODS[@]}" | ||
do | ||
# Check to see if selector/value exists | ||
if ! grep -rq "${REMOTE_METHODS[$K]}" /etc/rsyslog.*; then | ||
APPEND_LINE=$(sed -rn "/^\S+\s+\${LOCATIONS[$K]}$/p" /etc/rsyslog.conf) | ||
# Make sure we have a line to insert after, otherwise append to end | ||
if [[ ! -z ${APPEND_LINE} ]]; then | ||
# Add selector to file | ||
sed -r -i "0,/^(\S+\s+\/var\/log\/secure$)/s//\1\n${K} \/var\/log\/secure/" /etc/rsyslog.conf | ||
else | ||
echo "${K} /var/log/secure" >> /etc/rsyslog.conf | ||
echo "${K} ${LOCATIONS[$K]}" >> /etc/rsyslog.conf | ||
fi | ||
fi | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# platform = multi_platform_all | ||
|
||
declare -A REMOTE_METHODS=( ['auth.*']='^.*auth\.\*.*$' ['authpriv.*']='^.*authpriv\.\*.*$' ['daemon.*']='^.*daemon\.\*.*$' ) | ||
RSYSLOG_CONF='/etc/rsyslog.conf' | ||
RSYSLOG_D_FOLDER='/etc/rsyslog.d' | ||
RSYSLOG_D_FILES='/etc/rsyslog.d/*' | ||
|
||
|
||
# clean up .d conf files (if applicable) | ||
if [[ -d ${RSYSLOG_D_FOLDER} ]]; then | ||
for rsyslog_d_file in ${RSYSLOG_D_FILES} | ||
do | ||
for K in ${!REMOTE_METHODS[@]} | ||
do | ||
if grep -q "${REMOTE_METHODS[$K]}" ${rsyslog_d_file}; then | ||
sed -i "/${REMOTE_METHODS[$K]}/d" ${rsyslog_d_file} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The curly braces aren't needed if the variable isn't an array. |
||
fi | ||
done | ||
done | ||
fi | ||
|
||
if [[ ! -f /etc/rsyslog.conf ]]; then | ||
# Something is not right, create the file | ||
touch /etc/rsyslog.conf | ||
fi | ||
|
||
echo "auth.*,authpriv.* /var/log/secure" >> $RSYSLOG_CONF | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be a comma or a semicolon between the asterisk and a? The rule description has a semicolon and here you have a comma. |
||
echo "daemon.* /var/log/messages" >> $RSYSLOG_CONF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in the test scenario file name