From 6c4668840bc483fa8c5b17b425b5458aec1c8eaf Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 8 Jun 2016 16:05:51 -0400 Subject: [PATCH 1/2] Remove only xCAT entries from rsyslog.conf file --- xCAT/postscripts/syslog | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 183344238..b8f19ef2a 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -34,6 +34,8 @@ isSN=0 isLinux=1 isRsyslog=0 isC3=0 +xCATSettingsSTART="xCAT settings START" +xCATSettingsEND="xCAT settings END" #systemdEnabled=0 # pmatch determines if 1st argument string is matched by 2nd argument pattern @@ -87,13 +89,14 @@ 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 #enable to receive remote logging if [ $isReceiving -eq 1 ]; then #listen on the udp and tcp port to receive the remote logs @@ -119,6 +122,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 +162,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 +187,8 @@ 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 "#*.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 +211,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 +231,9 @@ config_rsyslog_V8() # add xCAT entries - echo "# xCAT settings" >> $remoteconf + echo "# $xCATSettingsSTART" >> $remoteconf echo "*.* @$master" >> $remoteconf + echo "# $xCATSettingsEND" >> $remoteconf fi # restart syslog ( could be service or systemctl call depending on the OS) restartservice syslog From 8d0bc5dee81c5c9c2b3a209ba02f900c6f6cba39 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 9 Jun 2016 13:11:29 -0400 Subject: [PATCH 2/2] Give user info about replacement of entries --- xCAT/postscripts/syslog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index b8f19ef2a..d9ee73d0b 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -36,6 +36,7 @@ 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 @@ -97,6 +98,7 @@ config_Rsyslog_C3() # 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 @@ -189,6 +191,7 @@ config_rsyslog_V8() # 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 @@ -232,6 +235,7 @@ config_rsyslog_V8() # add xCAT entries echo "# $xCATSettingsSTART" >> $remoteconf + echo "# $xCATSettingsInfo" >> $remoteconf echo "*.* @$master" >> $remoteconf echo "# $xCATSettingsEND" >> $remoteconf fi