-
Notifications
You must be signed in to change notification settings - Fork 0
/
addmlasso.sh
executable file
·52 lines (43 loc) · 1.36 KB
/
addmlasso.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
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: <login asso> (<bounce|tous|both> [les adresses a creer])"
exit 1
fi
#both is the default value
acreer="both"
if [ $# -ge 2 ]; then
acreer=$2
fi
if [ ! "$acreer" = "bounce" -a ! "$acreer" = "tous" -a ! "$acreer" = "both" ]; then
echo "Usage: <login asso> (<bounce|tous|both> [les adresses a creer])"
exit 1
fi
echo "Création pour $1 des listes $acreer ..."
#If file exists, abort, otherwise create it (we don't wanna orceride any file)
file="./sympatmpcrealist.xml"
if [ -e $file ]; then
echo "A filed named sympatmpcrealist.xml already exists, aborting ..."
exit 1
fi
touch "$file"
writeList() {
echo "<?xml version=\"1.0\" ?>" > $file
echo "<list>" >> $file
echo " <listname>$1-$2</listname>" >> $file
echo " <type>$3</type>" >> $file
echo " <subject>$1</subject>" >> $file
echo " <status>open</status>" >> $file
echo " <topic>$3</topic>" >> $file
echo " <owner>" >> $file
echo " <email>$1@assos.utc.fr</email>" >> $file
echo " </owner>" >> $file
echo "</list>" >> $file
/usr/local/sbin/sympa.pl --create_list --input_file=$PWD/sympatmpcrealist.xml
rm $file
}
if [ "$acreer" = "bounce" -o "$acreer" = "both" ]; then
writeList "$1" "bounce" "redirections"
fi
if [ "$acreer" = "tous" -o "$acreer" = "both" ]; then
writeList "$1" "tous" "assostous"
fi