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