From: Alex Dehnert Date: Fri, 27 Sep 2013 21:56:51 +0000 (-0400) Subject: diff-memberships: cleanup to make it more useable X-Git-Url: https://www.dehnerts.com/gitweb/?a=commitdiff_plain;ds=sidebyside;h=f72ee1398ba15a33922105e20505919f1f212c72;p=user%2Falex%2Fsoftware%2Fmy-snippets.git diff-memberships: cleanup to make it more useable Use an absolute path to the data directory, not a relative one; loop inside the script, not outside; etc.. --- diff --git a/diff-memberships b/diff-memberships index 92016f2..0b1d10a 100755 --- a/diff-memberships +++ b/diff-memberships @@ -2,27 +2,41 @@ qy="athrun ops qy" -#queries="get_ace_use get_lists_of_member" +datadir=${1:-$HOME/Private/listdiff} +if ! [[ -d "$datadir" ]]; then + echo "Please create and initialize the data directory" + echo "($datadir)" + echo "and rerun this script." + exit 1 +fi +cd "$datadir" + queries=( "gaus" "glom" ) subjectname="$USER" -for query in ${queries[@]}; do - for mod in "" "r"; do - hmod=$mod - if [ -z "$mod" ]; then hmod="nr"; fi - $qy $query ${mod}user "$subjectname" -s | sort > data/$query-user-$hmod.txt - $qy $query ${mod}kerberos "$subjectname@ATHENA.MIT.EDU" -s | sort > data/$query-kerb-$hmod.txt + +while true; do + printf "\n\n" + date + + for query in ${queries[@]}; do + for mod in "" "r"; do + hmod=$mod + if [ -z "$mod" ]; then hmod="nr"; fi + $qy $query ${mod}user "$subjectname" -s | sort > $query-user-$hmod.txt + $qy $query ${mod}kerberos "$subjectname@ATHENA.MIT.EDU" -s | sort > $query-kerb-$hmod.txt + done done -done -cd "$(dirname "$0")/data/" + stat="$(git diff --stat)" -stat="$(git diff --stat)" + for file in *.txt; do + result="$(git diff "$file")" + if [ -n "$result" ]; then + zwrite -c "$subjectname-lists" -i "$file" "$subjectname" -m "$result" + fi + done -for file in *.txt; do - result="$(git diff "$file")" - if [ -n "$result" ]; then - zwrite -c "$subjectname-lists" -i "$file" "$subjectname" -m "$result" - fi -done + git commit -a -m "$(printf "Regular list update: %s\n\n%s" "$(date)" "$stat")" -git commit -a -m "$(printf "Regular list update: %s\n\n%s" "$(date)" "$stat")" + sleep 5m +done