From 67aa8a23ea3332943025e499bebee602cb3bb7e5 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 17 Nov 2021 11:22:12 -0500 Subject: [PATCH] syslog postscript check for config files --- xCAT/postscripts/syslog | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) 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