blob: d095f0d8dc12aaf4083ce9a02e772fa503160768 (
plain)
- #!/bin/sh
- set -e
- exit1() (
- echo >&2 "ERROR: $1"
- exit 1
- )
- warn() (
- echo >&2 "WARNING: $1"
- )
- maybestaleuser() {
- warn "Skipping possibly non-stale account for user $user"
- }
- untouchedinbox() {
- set -e
- h="$1"; shift
- [ -d "$home/Maildir" ]
- find "$home/Maildir/new" -maxdepth 0 -type d -mtime +365 | grep -q .
- find "$home/Maildir/cur" -maxdepth 0 -type d -mtime +365 | grep -q .
- }
- untouchednewmail() {
- set -e
- h="$1"; shift
- [ -d "$home/Maildir" ]
- find "$home/Maildir/new" -type f -mtime +365 | grep -q
- }
- for user in $@; do
- home=$(getent passwd "$user" | cut -d: -f6)
- [ -n "$home" ] || exit1 "Failed resolving homedir for user $user"
- if [ -e "$home/.forward" ]; then
- maybestaleuser "$user"
- continue
- fi
- if untouchedinbox "$home" || untouchednewmail "$home"; then
- localrmaccount "$user"
- continue
- fi
- maybestaleuser "$user"
- done
|