scripts=\
bores-me\
- card-access\
get-emails\
grep-owners\
ldapfinger\
- list-members\
list-of-lists-updater\
lists-lint\
mail-merge\
make-zcrypt-key\
- pag-screen\
- rt-resolve check-host\
+ rt-resolve\
rt-set\
sshroot\
update-officers\
all : install
$(common)/% : %
- cp $< $@
+ install -c -m 555 $< $@
$(foreach script,$(scripts),$(foreach arch,$(arches),$(archdir)/$(arch)/bin/$(script))) :
#$(archdir)/*/bin/* :
-All scripts in this directory are Copyright (C) 2008--2010 Alex Dehnert
+All scripts in this directory are Copyright (C) 2008--2012 Alex Dehnert
(and sometimes others)
bores-me - original
-card-access - original
-check-host - original
get-emails - original
grep-owners - original
krbroot - based on work by... nelhage?
ldapfinger - original
-list-members - original (... and equivalent to blanche -l...)
list-of-lists-updater - original
lists-lint - original
mail-merge - original
Makefile - original
make-zcrypt-key - original, with additions by Anders
-pag-screen - based on work by... broder?
rt-merge - original
rt-resolve - original
rt-set - original
+++ /dev/null
-#!/usr/bin/python
-
-import sys
-import os
-import csv
-import subprocess
-import ldap
-
-#columns = [ 'timestamp', 'first', 'last', 'email', 'constituency', 'year', 'major', 'cell', 'mitid', 'retreat', 'whynot', 'project', 'othermit', ]
-format = "%(first_with_initial)s;%(last_canonical)s;%(mitid)s"
-
-def dictize_line(header, line,):
- line_dict = {}
- for key, elem in zip(header, line, ):
- line_dict[key]=elem
- return line_dict
-
-
-
-def get_ldap_data(username, fields):
- con = ldap.open('ldap.mit.edu')
- con.simple_bind_s("", "")
- dn = "dc=mit,dc=edu"
- result = con.search_s('dc=mit,dc=edu', ldap.SCOPE_SUBTREE, 'uid=%s'%username, fields)
- if len(result) > 1: print "WARNING: More than one result returned for %s" % username
- if len(result) < 1: print "WARNING: Only one result returned for %s" % username
- ret = {}
- for key in result[0][1]:
- ret[key] = result[0][1][key][0]
- return ret
-
-def get_data_dict(line_dict):
- email = line_dict['email']
- username = email.lower().replace('@mit.edu', '')
- ldap = get_ldap_data(username, [ 'cn' , 'sn' , 'givenName' ])
- first = ldap['givenName'].replace(' ', '_').upper()
- last = ldap['sn'].replace(' ', '_').upper()
- mitid = line_dict['mitid']
- data_dict = { 'first_with_initial': first, 'last_canonical': last, 'mitid': mitid }
- return data_dict
-
-def format_line(data_dict):
- return format % data_dict
-
-
-def do_produce_card_info(db = sys.stdin):
- reader = csv.reader(db, )
- lines = []
-
- header = reader.next()
- line_dict = dictize_line(header, header, )
- data_dict = { 'first_with_initial': 'FIRST_M', 'last_canonical': 'LASTNAME', 'mitid': 'MIT ID' }
- lines.append(format_line(data_dict))
-
- for line in reader:
- line_dict = dictize_line(header, line)
- print line_dict
- lines.append(format_line(get_data_dict(line_dict)))
- print '\n'.join(lines)
-
-if __name__== '__main__':
- do_produce_card_info()
+++ /dev/null
-#!/bin/bash
-# Alex Dehnert
-
-for hostname in "$@"; do
- echo
- echo Now checking $hostname
- echo Stella:
- stella $hostname.mit.edu
- echo Aliases
- athrun ops qy ghal $hostname.mit.edu \*
-done
-
-echo
-echo For your copy/pasting convenience
-echo Please be careful that this makes sense with the output above
-echo
-echo At your convenience, please make $@.mit.edu an alias of scripts-vhosts.mit.edu.
-echo
-for hostname in "$@"; do
- echo stella scripts-vhosts -a $hostname
-done
echo ldapsearch -h ldap.mit.edu -b dc=mit,dc=edu uid=$user
ldapsearch -h ldap.mit.edu -b dc=mit,dc=edu uid=$user
done
+
+echo Try also athrun consult ldaps
+echo or ldapsearch -x -h ldap-too.mit.edu -b ou=moira,dc=mit,dc=edu uid=$user
+++ /dev/null
-#!/bin/bash
-# Alex Dehnert --- 2009-04-24
-# Print list members of a list
-# Takes a container mailing list on the commandline
-
-cont=$1
-cont=${cont:-ua-lists}
-
-blanche $cont | grep ^LIST | sed -e "s/^LIST://"
anti=${anti:-ua-foreign-lists}
nativepat=${nativepat:-ua}
+function prefix {
+ #echo "$@"
+ "$@"
+}
+
function add_lists
{
(
for list in $lists; do # for each list we already know about
# Add a list's sublists
for newlist in $(blanche $list | grep LIST | cut -d : -f 2); do
- blanche $prev -a $newlist;
+ prefix blanche $prev -a $newlist;
done;
# Add a list's owner and memacl
owner=$(athrun ops qy -s -f ace_name glin $list)
towner=$(athrun ops qy -s -f ace_type glin $list)
if [[ "$towner" == "LIST" ]]; then
- blanche $prev -a $owner
+ prefix blanche $prev -a $owner
fi
macl=$(athrun ops qy -s -f memace_name glin $list)
tmacl=$(athrun ops qy -s -f memace_type glin $list)
if [[ "$tmacl" == "LIST" ]]; then
- blanche $prev -a $macl
+ prefix blanche $prev -a $macl
fi
# Add stuff this owns
owned=$(athrun ops qy -s get_ace_use list $list | grep -v ^$prev\$ | grep LIST | cut -d " " -f 2)
for newlist in $owned; do
- blanche $prev -a $newlist;
+ prefix blanche $prev -a $newlist;
done;
done
) 2>&1 | grep -v "Record already exists" | grep -v "moira (query): No records in database match query"
--- /dev/null
+Using the "mail-merge" script
+
+The mail-merge script (if this file is ./mail-merge-help/README, it should be
+./mail-merge) is a simple tool for combining a CSV file of data with a Python
+template for an email, and sending it out.
+
+The first argument is an address to receive copies of all emails sent out (generally an archive address (gmail, discuss, ...) or some list of your organization (esp@, asa-admin@, etc.). This address will be BCC'd; if you want it to be visible to the recipients, make sure to mention it in your template.
+
+Your template should contain full SMTP headers and be suitable for passing to Python's % operator. In particular, this usually means that it should start with To:, Subject:, etc. lines, and fields should be substituted using "%(fieldname)s". Note that the values of the To:, CC:, etc. fields in your template are independent from who actually recieves the email --- you can include a CC: of, say, asa-exec@mit.edu and pass asa-admin@mit.edu as the first argument of the script, and asa-admin@mit.edu will receive the emails, but to the recipients it will (mostly) appear that asa-exec@mit.edu did instead. This may be useful to encourage reply-all to go to the right place without actually spamming everybody on the list.
+
+Your CSV should contain a header line with the names of your fields, followed by several data lines. As is (definitionally) the case with any CSV file, fields on a given line should be comma-separated. The field named "email" will be used as the recipient of the email. The rest of the fields have no defined meaning, but can be substituted into your template.
+
+I recommend creating both a "test" CSV file, containing just one row with your email address, and a real CSV file. Run the mail merge script repeatedly on the test CSV file until you're happy with the template, and then run it on the real file.
+
+Sample files are also available in this directory.
+
+Putting these all together, you'll probably want a command like:
+add adehnert # If on an Athena machine, to make the script available
+cd /mit/adehnert/Public/software/my-snippets/mail-merge-help # change to the directory with your data files
+mail-merge asa-admin@mit.edu missing-whatever.txt missing-whatever.test.csv # repeat until the message looks good
+mail-merge asa-admin@mit.edu missing-whatever.txt missing-whatever.csv # run just once
+
+The script will output the rows in the CSV file, as it parsed them, as it reads and processes them.
+
+The mail-merge command should work on any Athena machine (and most other machines with Python installed).
+
+Please feel free to contact me (adehnert@mit.edu) with any questions.
--- /dev/null
+"email","FNAME","LNAME",group_id
+"adehnert@mit.edu","Alex","Dehnert",1955
--- /dev/null
+To: %(FNAME)s %(LNAME)s <%(email)s>
+Subject: Missing whatever for %(FNAME)s %(LNAME)s
+From: asa-exec@mit.edu
+CC: asa-exec@mit.edu
+
+Hello %(FNAME)s %(LNAME)s,
+
+You have not yet filled out the whatever form. You are required to do this before 1/1/1970. You can do so at https://asa.mit.edu/whatever/%(group_id)s.
+
+Thanks,
+ASA Exec
+++ /dev/null
-#!/usr/bin/env pagsh
-
-screen=`which screen`
-
-# Check for pre-existing screens.
-screenlist=`$screen -list | grep owl`
-if [ "x$screenlist" != "x" ]; then
- echo "Found a pre-existing owl-screen session:"
- echo "$screenlist"
- echo "You probably want to reattach it instead."
- echo
- exit 1
-fi
-
-# Get AFS tokens for the screen session.
-# We are now in a new PAG (because of pagsh).
-# If you want to get tokens for other cells, list them in ~/.xlog
-aklog || echo "Failed to get new tokens"
-
-# Use separate kerberos tickets for screen. Even if we accidentally
-# (or intentionally) log out, screen and owl will still have tickets.
-NEWKRB5=/tmp/krb5cc_${USER}_screen
-
-# Copy the tickets we obtained on login to the screen tickets.
-KRB5CCNAME=`echo $KRB5CCNAME | sed 's/FILE://'`
-if [ "x$KRB5CCNAME" != "x" ]; then
- cp $KRB5CCNAME $NEWKRB5
-else
- echo "No tickets; not copying to new CC"
-fi
-
-# Now actually use the new tickets.
-KRB5CCNAME=FILE:$NEWKRB5; export KRB5CCNAME
-
-# Repeat for krb4 if appropriate.
-if [ "x$KRBTKFILE" != "x" ]; then
- NEWKRB4=/tmp/tkt_${USER}_screen
- KRBTKFILE=`echo $KRBTKFILE | sed 's/FILE://'`
- cp $KRBTKFILE $NEWKRB4
- KRBTKFILE=$NEWKRB4; export KRBTKFILE
-fi
-
-# Figure out which zephyr client to use. Defaults to barnowl.
-if [ "x$ZEPHYR_SCREEN_CLIENT" = "x" ]; then
- barnowl=`which barnowl`
- if [ ! -x "$barnowl" ]; then
- attach -n -q barnowl
- barnowl=`athdir /mit/barnowl`/barnowl
- fi
- ZEPHYR_SCREEN_CLIENT="$barnowl"
-fi
-
-# Renew tickets and tokens.
-contrenew=`which cont-renew-notify`
-if [ ! -x "$contrenew" ]; then
- zwrite $ATHENA_USER -d -m "$0: cont-renew doesn't exist on $(hostname)... Not doing renewals"
- contrenew=/bin/true
-fi
-nohup $contrenew < /dev/null > /dev/null 2> /dev/null &
-
-# Name the screen pag so we can reattach the right screen later.
-$screen -S pag