-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-chapter-emails.sh
86 lines (68 loc) · 2.33 KB
/
create-chapter-emails.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# This script requires authorized gam scope, achieved by executing the install script
# Path to GAM executable
# Should be this if you installed it correctly
GAM_EXC_PATH="/root/bin/gam7/gam"
suff=@studytutors.de
# Gets the recovery email adress (circular dependency, order is arbitrary)
getRecovName() {
case $1 in
schueler)
echo "studierende";
;;
info)
echo "schueler";
;;
studierende)
echo "info";
;;
esac
}
#####################
## Read user input ##
#####################
echo -n "Please enter a city name (lowercase): "
read cityName
echo -n "Now creating accounts (info, studenten, schueler) for $cityName. Confirm? (Y/N)"
read consent
#######################
## Validate to start ##
#######################
# Terminate if the answer is not "Y"
if [ ! "y" == "${consent,,}" ];
then
echo "Option not valid"
exit 1;
fi
#########################################
## Create the mapping and city strings ##
#########################################
# Set lower- and uppercase city names
city=$(echo "$cityName" | tr "[:upper:]" "[:lower:]")
City=$(echo "$city" | sed 's/[^ _-]*/\u&/g')
# Set the mapping
# emailprefix <-> name in google workspace
declare -A divisions=([schueler]=Schüler [studierende]=Studierende [info]=Kommunikation)
###########################################
## Create Users for each divison in the ##
## new city as well as first-time setup ##
## e.g. signatures, profile picture, ... ##
###########################################
for div in "${!divisions[@]}";
do
# Create the account
$GAM_EXC_PATH create user $div.$city \
firstname ${divisions[$div]} \
lastname $City \
password Abcdef1234 \
changepassword on \
org /Standorte \
recoveryemail "$(getRecovName $div)".$city$suff
# Set profile picture & signature
$GAM_EXC_PATH user $div.$city update photo $(readlink -f "../gmail/images/sbs-owls.png")
$GAM_EXC_PATH update group $div add member $div.$city
$GAM_EXC_PATH user $div.$city signature file $(readlink -f "../gmail/signatures/chapters.html") html replace firstName ${divisions[$div]} replace lastName $City
done
# Division info needs special treatment
$GAM_EXC_PATH update group kommunikation add member info.$city
$GAM_EXC_PATH update group info remove member info.$city