-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnUser.it
executable file
·45 lines (45 loc) · 1.76 KB
/
nUser.it
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
#!/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"
tGroup="$groupName$groupSuffix"
tAlias="$userName$aliasSuffix"
if [ -z "$1" ]
then
echo -e "\e[91m\e[7mALERT:\e[0m To be used only for IEEE Staff"
echo -e "to process changes use \e[91m./nUser.ieee 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[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
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
~/bin/gam/gam user $tUser add license VAULT
echo "* $timestamp * $tUser - Vault license added" >> ~/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