diff --git a/clean_samba_trash.sh b/clean_samba_trash.sh index 040e210..c89374d 100755 --- a/clean_samba_trash.sh +++ b/clean_samba_trash.sh @@ -14,6 +14,7 @@ clean_up() { # Perform program exit housekeeping rm -rf "$LOCK_DIR" + blank_line exit $1 } @@ -74,17 +75,22 @@ info (){ echo_done() { if $terminal ; then - echo -e "\033[75G[ \033[32mdone\033[m ]" + echo -e "\033[85G[ \033[32mdone\033[m ]" fi } echo_failed(){ if $terminal && $LOGGING ; then - echo -e "\033[75G[ \033[1;31mfailed\033[m ]" + echo -e "\033[85G[ \033[1;31mfailed\033[m ]" fi } echo_skipped() { if $terminal && $LOGGING ; then - echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" + echo -e "\033[85G[ \033[90mskipped\033[m ]" + fi +} +echo_wait(){ + if $terminal ; then + echo -en "\033[85G[ \033[5m\033[1m...\033[m ]" fi } @@ -94,6 +100,11 @@ trim() { var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters echo -n "$var" } +blank_line() { + if $terminal ; then + echo "" + fi +} # ------------- @@ -160,19 +171,37 @@ traverse() { } +blank_line + for dir in $trash_dirs ; do - info "Delete files from trash directory \033[1m${dir}\033[m older than \033[1m${days}\033[m days .." - traverse "$dir" + #info "Delete files from trash directory \033[1m${dir}\033[m older than \033[1m${days}\033[m days .." + echononl " Delete files from trash directory \033[1m${dir}\033[m older than \033[1m${days}\033[m days .." + if [[ -d "$dir" ]]; then + echo_wait + traverse "$dir" + echo_done + else + echo_skipped + fi done # - Delete empty sub-directories # - if $terminal ; then + echo "" echo -e "\033[32m\033[1m-----\033[m" + echo "" fi for dir in $trash_dirs ; do - info "Cleanup trash directory \033[1m${dir}\033[m from empty directories .." - find $dir -depth -mindepth 1 -type d -empty -delete + #info "Cleanup trash directory \033[1m${dir}\033[m from empty directories .." + echononl " Cleanup trash directory \033[1m${dir}\033[m from empty directories .." + if [[ -d "$dir" ]]; then + echo_wait + find $dir -depth -mindepth 1 -type d -empty -delete + echo_done + else + echo_skipped + fi done clean_up 0