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
This commit is contained in:
Davanum Srinivas 2015-04-11 18:45:09 -04:00
parent 10f832e3ad
commit 93d09c24e3
1 changed files with 10 additions and 3 deletions

View File

@ -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