-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailman_sync.sh
63 lines (57 loc) · 1.16 KB
/
mailman_sync.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/sh
usage() {
cat << EOF
This script will synchronise mailman subscibers with nominated Drupal groups.
OPTIONS:
-h Show this message
-u The mapping url (REQUIRED)
-k Secret key (REQUIRED
-n Dry run
-c Additional arguments to pass to curl
-v Verbose
EOF
}
while getopts "u:c:k:hvn" OPTION; do
case $OPTION in
h)
usage
exit 1
;;
u)
MAP=$OPTARG
;;
c)
CURL_ARGS=$OPTARG
;;
k)
KEY=$OPTARG
;;
n)
DRYRUN="-n"
;;
v)
VERBOSE=1
;;
*)
usage
exit
;;
esac
done
if [ -n "$MAP" ] && [ -n "$KEY" ]; then
curl $CURL_ARGS --fail --silent --show-error "$MAP?mailman_key=$KEY" | while read mapping; do
set $mapping
# Check all arguments are present
if [ -z "$1" ] || [ -x "$2" ]; then
echo "Incorrect arguments supplied: $mapping"
echo "Bailing all further synchronizations."
exit 1
fi
if [ "$VERBOSE" = 1 ]; then
echo "Synchronizing group $1"
fi
curl $CURL_ARGS --fail --silent --show-error "$2""?mailman_key=$KEY" | ifne /usr/lib/mailman/bin/sync_members $DRYRUN -f - $1
done
else
usage
fi