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
diff --git a/clean.sh b/clean.sh
index 035489c..fa7d56f 100755
--- a/clean.sh
+++ b/clean.sh
@@ -114,9 +114,16 @@
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