Skip to content
Permalink
main
Switch branches/tags

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?
Go to file
0 contributors

Users who have contributed to this file

executable file 49 lines (39 sloc) 1.5 KB
#!/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