mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-31 10:06:39 +00:00
Merge pull request #1288 from gurevichmark/syslog_script
Remove only xCAT entries from rsyslog.conf file
This commit is contained in:
commit
8b30a52bbe
@ -34,6 +34,9 @@ isSN=0
|
||||
isLinux=1
|
||||
isRsyslog=0
|
||||
isC3=0
|
||||
xCATSettingsSTART="xCAT settings START"
|
||||
xCATSettingsEND="xCAT settings END"
|
||||
xCATSettingsInfo="Entries between the START and END lines will be replaced on the next xCAT install or update"
|
||||
#systemdEnabled=0
|
||||
# pmatch determines if 1st argument string is matched by 2nd argument pattern
|
||||
|
||||
@ -87,13 +90,15 @@ config_Rsyslog_C3()
|
||||
cp -f $2 $2.XCATORIG
|
||||
fi
|
||||
|
||||
grep "xCAT settings" $conf_file 2>&1 1> /dev/null
|
||||
grep "$xCATSettingsSTART" $conf_file 2>&1 1> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
#remove the previous syslog rule generated by xCAT
|
||||
sed -i "/# xCAT settings/,$ d" $2
|
||||
sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $2
|
||||
fi
|
||||
|
||||
echo "# xCAT settings" >> $2
|
||||
# Mark the start of xCAT section
|
||||
echo "# $xCATSettingsSTART" >> $2
|
||||
echo "# $xCATSettingsInfo" >> $2
|
||||
#enable to receive remote logging
|
||||
if [ $isReceiving -eq 1 ]; then
|
||||
#listen on the udp and tcp port to receive the remote logs
|
||||
@ -119,6 +124,8 @@ config_Rsyslog_C3()
|
||||
s/^\(news\|local7\|mail\|authpriv\|cron\|kern\)\./\#\1\./' $2
|
||||
echo "*.* @$master" >> $2
|
||||
fi
|
||||
# Mark the end of xCAT section
|
||||
echo "# $xCATSettingsEND" >> $2
|
||||
}
|
||||
|
||||
# This sets up rsyslog 8.x, different from the previous rsyslog versions.
|
||||
@ -157,15 +164,15 @@ config_rsyslog_V8()
|
||||
cp -f $conf_file $conf_file.XCATORIG
|
||||
fi
|
||||
|
||||
# check if already an entry by xCAT. If so, we need to replace it
|
||||
grep "xCAT settings" $conf_file 2>&1 1> /dev/null
|
||||
# check if already an entry by xCAT. If so, we need to remove it
|
||||
grep "$xCATSettingsSTART" $conf_file 2>&1 1> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
sed -i "/# xCAT settings/,$ d" $conf_file
|
||||
sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $conf_file
|
||||
fi
|
||||
|
||||
grep "xCAT settings" $remoteconf 2>&1 1> /dev/null
|
||||
grep "$xCATSettingsSTART" $remoteconf 2>&1 1> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
sed -i "/# xCAT settings/,$ d" $remoteconf
|
||||
sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $remoteconf
|
||||
fi
|
||||
|
||||
if [ $goLocal -eq 1 ]; then
|
||||
@ -182,7 +189,9 @@ config_rsyslog_V8()
|
||||
# to prevent duplicate logs after "syslog" script is run
|
||||
sed -i '/^[^#].*\/var\/log\/messages/s/^/#/' $conf_file
|
||||
|
||||
echo "# xCAT settings" >> $conf_file
|
||||
# Mark the start of xCAT section
|
||||
echo "# $xCATSettingsSTART" >> $conf_file
|
||||
echo "# $xCATSettingsInfo" >> $conf_file
|
||||
echo "#*.debug /var/log/messages" >> $conf_file
|
||||
# Need to uncomment the lines $ModLoad imudp.so and $UDPServerRun 514,
|
||||
# to make the MN be able to receive syslog from remote hosts
|
||||
@ -205,6 +214,8 @@ config_rsyslog_V8()
|
||||
s/#input(type="imtcp" port="514")/input(type="imtcp" port="514")/' $conf_file
|
||||
fi
|
||||
|
||||
# Mark the end of xCAT section
|
||||
echo "# $xCATSettingsEND" >> $conf_file
|
||||
else
|
||||
# not logging local, forward logging
|
||||
# backup the existing remote.conf file from the install
|
||||
@ -223,8 +234,10 @@ config_rsyslog_V8()
|
||||
|
||||
|
||||
# add xCAT entries
|
||||
echo "# xCAT settings" >> $remoteconf
|
||||
echo "# $xCATSettingsSTART" >> $remoteconf
|
||||
echo "# $xCATSettingsInfo" >> $remoteconf
|
||||
echo "*.* @$master" >> $remoteconf
|
||||
echo "# $xCATSettingsEND" >> $remoteconf
|
||||
fi
|
||||
# restart syslog ( could be service or systemctl call depending on the OS)
|
||||
restartservice syslog
|
||||
|
Loading…
x
Reference in New Issue
Block a user