summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2021-09-28 16:27:15 +0200
committerJonas Smedegaard <dr@jones.dk>2021-09-28 16:27:15 +0200
commit3d6dabbf2dbf0d145b101e2eb8d6fac53246caf5 (patch)
tree0135e93806dfa1e06fe346eae2bd41ddfec25e37
parent598d5307bbe5cf20f45780cd8ef1fb40c9694fe9 (diff)
be verbose about actual removals
-rwxr-xr-xlocalrmaccount1
-rwxr-xr-xlocalrmstaleaccounts12
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