aboutsummaryrefslogtreecommitdiff
path: root/scripts/mailing-list-member-retirement/find-inactive-members.sh
blob: b61da1fecf14031eb9bb41862dc556cc15612f71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

set -eu -o pipefail

#readonly LIST_NAME="$1"
#readonly SINCE="$2"

readonly MBOX="$1" # /var/lib/mailman/archives/private/fsi.mbox/fsi.mbox
readonly LIST_MEMBERS_FILE="$2" # list_members fsi > members.txt
readonly SINCE="$3"

readonly TMPDIR="$(mktemp -d --suffix=find-inactive-members)"
readonly ACTIVE_MEMBERS_FILE="active-members.txt"
readonly ALL_MEMBERS_FILE="all-members.txt"

./mailing-list-active-members -mbox "$MBOX" -since "$SINCE" 2> /dev/null \
  | sort -u > "$TMPDIR/$ACTIVE_MEMBERS_FILE"

sort "$LIST_MEMBERS_FILE" > "$TMPDIR/$ALL_MEMBERS_FILE"

echo "Inactive members:" >&2

diff "$TMPDIR/$ALL_MEMBERS_FILE" "$TMPDIR/$ACTIVE_MEMBERS_FILE" \
  | grep -E "^< " | sed "s/^< //"

rm "$TMPDIR/$ACTIVE_MEMBERS_FILE"
rm "$TMPDIR/$ALL_MEMBERS_FILE"
rmdir "$TMPDIR"