Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
inc-meta/utilities/contacts-from-sf.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

executable file
49 lines (39 sloc)
1.5 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script processes a Salesforce report which lists all contacts with UK federation | |
# contact roles, their corresponding Jisc Organisation ID and Organisation Name. | |
# | |
# Expects a CSV file with the following format: | |
# "Contact: Email","Jisc Organisational ID","Role Name","Account Name" | |
# "person1@example.com","127","UK Federation Management Contact","Further College" | |
# "person2@example.com","12345","UK Federation Signatory","Unseen University" | |
# | |
# | |
# The output of the script is as follows; | |
# | |
# * A copy of the Salesforce report in $CSVDEST | |
# * A list of Management Contact email addresses in $MGMTDEST | |
# * A list of all contact email addresses in $CONTACTDEST | |
# | |
UKFDATA=../../ukf-data | |
CSVDEST=../../ukf-data/contacts/sf-contacts.csv | |
CONTACTDEST=../../ukf-data/contacts/sf-contacts.txt | |
MGMTDEST=../../ukf-data/contacts/sf-contacts-mc.txt | |
TMPFILE=$(mktemp) | |
export LC_COLLATE="C.UTF-8" | |
if [ -z "$1" ]; then | |
echo "ERROR: No file name supplied" | |
exit 1 | |
fi | |
if [ ! -f "$1" ]; then | |
echo "ERROR: file $1 does not exist" | |
exit 1 | |
fi | |
cat $1 | awk -F\, '{ print $1 }' | grep @ | sed -e 's/\"//g' | sort -u > $CONTACTDEST | |
grep "\,\"UK Federation Management Contact\"" $1 | awk -F\, '{ print $1 }' | grep @ | sed -e 's/\"//g' | sort -u > $MGMTDEST | |
SOURCEDATE=$(date --date="@$(stat $1 --printf=%Y | awk -F\. '{ print $1 }')" +"%d/%m/%Y %H:%M") | |
GITUSER=$(cd $UKFDATA && git config user.name) | |
cp $1 $TMPFILE | |
echo "\"Generated By: $GITUSER $SOURCEDATE\"" >> $TMPFILE | |
cp $TMPFILE $CSVDEST | |
rm $TMPFILE | |