From 93d09c24e35611cc7fc1ef8e6796d177d460fecc Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sat, 11 Apr 2015 18:45:09 -0400 Subject: [PATCH] Setting LOGFILE to a file in root directory wipes everything clean.sh picks the parent of LOGFILE and wipes it clean! So if you set it to a log file in the users root directory, you lose everything We should delete just the LOGFILE and cleanup LOGDIR and SCREEN_LOGDIR if they are explicitly set. Change-Id: I45745427dcaed3dcf0b78cc9ed680833d9d555e8 --- clean.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/clean.sh b/clean.sh index 035489c045..fa7d56fbac 100755 --- a/clean.sh +++ b/clean.sh @@ -114,9 +114,16 @@ sudo rm -f /etc/tgt/conf.d/* cleanup_rpc_backend cleanup_database -# Clean out data, logs and status -LOGDIR=$(dirname "$LOGFILE") -sudo rm -rf $DATA_DIR $LOGDIR $DEST/status +# Clean out data and status +sudo rm -rf $DATA_DIR $DEST/status + +# Clean out the log file and log directories +if [[ -n "$LOGFILE" ]] && [[ -f "$LOGFILE" ]]; then + sudo rm -f $LOGFILE +fi +if [[ -n "$LOGDIR" ]] && [[ -d "$LOGDIR" ]]; then + sudo rm -rf $LOGDIR +fi if [[ -n "$SCREEN_LOGDIR" ]] && [[ -d "$SCREEN_LOGDIR" ]]; then sudo rm -rf $SCREEN_LOGDIR fi