From 3d6dabbf2dbf0d145b101e2eb8d6fac53246caf5 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 28 Sep 2021 16:27:15 +0200 Subject: be verbose about actual removals --- localrmaccount | 1 + localrmstaleaccounts | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/localrmaccount b/localrmaccount index 8424acd..f77167a 100755 --- a/localrmaccount +++ b/localrmaccount @@ -6,4 +6,5 @@ u="$1"; shift p=/var/backups/users-dropped/ getent passwd "$u" > "$p/$u.getent" getent group "$u" >> "$p/$u.getent" +[ -z "$2" ] || echo "$2" >> "$p/$u.getent" deluser --remove-home --backup --backup-to "$p" "$u" diff --git a/localrmstaleaccounts b/localrmstaleaccounts index c7ceaae..137dd61 100755 --- a/localrmstaleaccounts +++ b/localrmstaleaccounts @@ -53,7 +53,8 @@ info() { } remove_account() { - [ -n "$DRY_RUN" ] || localrmaccount "$1" + warn "$2" + [ -n "$DRY_RUN" ] || localrmaccount "$1" "$2" } for user in "$@"; do @@ -65,14 +66,11 @@ for user in "$@"; do elif [ ! -d "$home/Maildir" ]; then warn "Skipping user $user: Missing Maildir" elif find "$home/Maildir/new" -maxdepth 0 -type d -mtime +365 | grep -q .; then - info "Removing user $user: Maildir INBOX/new untouched for a year" - remove_account "$user" + remove_account "$user" "Removing user $user: Maildir INBOX/new untouched for a year" elif find "$home/Maildir/cur" -maxdepth 0 -type d -mtime +365 | grep -q .; then - info "Removing user $user: Maildir INBOX/cur untouched for a year" - remove_account "$user" + remove_account "$user" "Removing user $user: Maildir INBOX/cur untouched for a year" elif find "$home/Maildir/new" -type f -mtime +365 | grep -q .; then - info "Removing user $user: new mail in INBOX untouched for a year" - remove_account "$user" + remove_account "$user" "Removing user $user: new mail in INBOX untouched for a year" else info "Skipping user $user" fi -- cgit v1.2.3