-
Notifications
You must be signed in to change notification settings - Fork 8
/
mail_TAs.sh
38 lines (32 loc) · 1.01 KB
/
mail_TAs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
MYDIR="${0%/*}"
if [ ! -f $MYDIR/config.sh ]; then
echo "Expecting configuration in config.sh. Refer to the template file config_template.sh"
exit 1
fi
# This will input/source the contents of the config.sh file, which
# will not be tracked by git.
. $MYDIR/config.sh
for ta in "${!email[@]}"; do
if [ ! -d "$ta" ]; then
echo "$ta doesn't exist. Run verdeel.sh first."
exit
fi
done
for cmd in 7za mutt; do
if ! command -v $cmd >/dev/null 2>&1; then
echo "Who am I? Why am I here? Am I on lilo? $cmd is missing!" >& 2
exit 1
fi
done
for ta in "${!email[@]}"
do
if [ "${email[$ta]}" ]; then
echo Mailing "$ta"
pkt="$ta-${zip%.zip}.7z"
7za a -ms=on -mx=9 "$pkt" "$ta" > /dev/null
#echo "" | mailx -n -s "${SUBJECT} ${zip%.zip}" -a "$pkt" "${email[$ta]}"
echo "" | mutt -s "${SUBJECT}: ${zip%.zip}" -a "$pkt" -- "${email[$ta]}"
rm -f "$pkt"
fi
done