classify-users: determine type of Athena accounts
[user/alex/software/my-snippets.git] / diff-memberships
1 #!/bin/bash
2
3 qy="athrun ops qy"
4
5 datadir=${1:-$HOME/Private/listdiff}
6 if ! [[ -d "$datadir" ]]; then
7     echo "Please create and initialize the data directory"
8     echo "($datadir)"
9     echo "and rerun this script."
10     exit 1
11 fi
12 cd "$datadir"
13
14 queries=( "gaus" "glom" )
15 subjectname="$USER"
16
17 while true; do
18     printf "\n\n"
19     date
20
21     for query in ${queries[@]}; do
22         for mod in "" "r"; do
23             hmod=$mod
24             if [ -z "$mod" ]; then hmod="nr"; fi
25             $qy $query ${mod}user "$subjectname" -s | sort > $query-user-$hmod.txt
26             $qy $query ${mod}kerberos "$subjectname@ATHENA.MIT.EDU" -s | sort > $query-kerb-$hmod.txt
27         done
28     done
29
30     stat="$(git diff --stat)"
31
32     for file in *.txt; do
33         result="$(git diff "$file")"
34         if [ -n "$result" ]; then
35             zwrite -c "$subjectname-lists" -i "$file" "$subjectname" -m "$result"
36         fi
37     done
38
39     git commit -a -m "$(printf "Regular list update: %s\n\n%s" "$(date)" "$stat")"
40
41     sleep 5m
42 done