-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnUser.ieee
executable file
·47 lines (47 loc) · 1.83 KB
/
nUser.ieee
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
#!/bin/bash
INPUT=~/gam-data/userlist.csv
OLDIFS=$IFS
IFS=,
timestamp=$(date +%Y-%m-%d@%I:%M%p)
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read userName firstName lastName orgName groupName
do
orgPrefix="/STAFF"
emailSuffix="@ieee.org"
groupSuffix="[email protected]"
aliasSuffix="@gapps.ieee.org"
tUser="$userName$emailSuffix"
tOrg="/STAFF/$orgName"
secondAlias="$(echo "$userName" | sed 's/\./-/g')"
sAlias="$secondAlias$emailSuffix"
tGroup="$groupName$groupSuffix"
tAlias="$userName$aliasSuffix"
if [ -z "$1" ]
then
echo -e "\e[91m\e[7mALERT:\e[0m To be used only for Computer.org Staff"
echo -e "to process changes use \e[91m./nUser.computer doit\e[0m"
echo -e "---[ \e[93m\e[1mPREVIEW of Changes \e[0m]--- "
echo -e "\e[1mCreate User: \e[0m$tUser"
echo -e "\e[1mAdd Alias: \e[0m$tAlias"
echo -e "\e[1mSecond Alias: \e[0m$sAlias"
echo -e "\e[1mOrganization: \e[0m$tOrg"
echo -e "\e[1mGroup: \e[0m$tGroup"
echo -e "\e[36mAdd Vault License\e[0m"
echo -e "---[ \e[93m\e[1mPREVIEW END \e[0m]--"
echo
else
if [ "${1^^}" == "DOIT" ]
then
echo -e "---[ \e[93m\e[1mCreating User \e[36m$tUser \e[0m]---\e[32m"
~/bin/gam/gam create user $tUser firstname $firstName lastname $lastName org $tOrg
echo "* $timestamp * $tUser - created ($tOrg)" >> ~/gam-data/gam-data.log
~/bin/gam/gam create alias $tAlias user $tUser
~/bin/gam/gam create alias $sAlias user $tUser
echo "* $timestamp * $tUser - added alias of $tAlias" >> ~/gam-data/gam-data.log
~/bin/gam/gam update group $tGroup add member $tUser
echo "* $timestamp * $tUser - added to group $tGroup" >> ~/gam-data/gam-data.log
echo -e "\e[0m---[ \e[93m\e[1m Creation Complete for \e[36m$tUser \e[0m]---"
fi
fi
done < $INPUT
IFS=$OLDIFS