forked from cloud-gov/cg-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-ops-admin.sh
executable file
·45 lines (39 loc) · 1017 Bytes
/
make-ops-admin.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
#!/bin/bash
set -e
if [ "$#" -lt 1 ]; then
echo
echo "Usage:"
echo " $ ./make-ops-admin.sh [-r] <EMAIL_ADDRESS>"
echo
echo " Options:"
echo " -r : Remove the user instead of add"
echo
exit 1;
fi
EMAIL=$BASH_ARGV
REMOVE=false
while getopts ":r" opt; do
case $opt in
r)
REMOVE=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1;
;;
esac
done
if ! hash uaac 2>/dev/null; then
gem install cf-uaac
fi
if $REMOVE; then
echo -n "Removing user ${EMAIL}... "
uaac member delete concourse.admin "${EMAIL}" || true
uaac member delete concourse.apps "${EMAIL}" || true
uaac user delete "${EMAIL}"
else
echo -n "Adding user ${EMAIL}... "
uaac curl -XPOST /Users -H"If-Match:*" -H"Accept:application/json" -H"Content-Type:application/json" -d\{\"userName\":\""${EMAIL}"\",\"emails\":[\{\"value\":\""${EMAIL}"\"\}],\"active\":true,\"verified\":true,\"origin\":\"gsa\"\}
uaac member add concourse.admin "${EMAIL}" || true
fi
echo "DONE"