diff --git a/xCAT/postscripts/syslog b/xCAT/postscripts/syslog index 51c16262c..0f7b597d0 100755 --- a/xCAT/postscripts/syslog +++ b/xCAT/postscripts/syslog @@ -179,26 +179,32 @@ config_rsyslog_V8() cp -f $conf_file $conf_file.XCATORIG fi - # check if already an old entry by xCAT. If so, we need to remove it - grep "$xCATSettingsOLD$" $conf_file 2>&1 1> /dev/null - if [ $? -eq 0 ]; then - sed -i "/$xCATSettingsOLD/,+1 d" $conf_file + if [ -e $conf_file ]; then + # check if already an old entry by xCAT. If so, we need to remove it + grep "$xCATSettingsOLD$" $conf_file 2>&1 1> /dev/null + if [ $? -eq 0 ]; then + sed -i "/$xCATSettingsOLD/,+1 d" $conf_file + fi + + # check if already a previous 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 "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $conf_file + fi fi - grep "$xCATSettingsOLD$" $remoteconf 2>&1 1> /dev/null - if [ $? -eq 0 ]; then - sed -i "/$xCATSettingsOLD/,+1 d" $remoteconf - fi + if [ -e $remoteconf ]; then + # check if already an old entry by xCAT. If so, we need to remove it + grep "$xCATSettingsOLD$" $remoteconf 2>&1 1> /dev/null + if [ $? -eq 0 ]; then + sed -i "/$xCATSettingsOLD/,+1 d" $remoteconf + fi - # check if already a previous 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 "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $conf_file - fi - - grep "$xCATSettingsSTART" $remoteconf 2>&1 1> /dev/null - if [ $? -eq 0 ]; then - sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $remoteconf + # check if already a previous entry by xCAT. If so, we need to remove it + grep "$xCATSettingsSTART" $remoteconf 2>&1 1> /dev/null + if [ $? -eq 0 ]; then + sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $remoteconf + fi fi if [ $goLocal -eq 1 ]; then