forked from cloud-gov/cg-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-pages-admin.sh
executable file
·51 lines (45 loc) · 952 Bytes
/
make-pages-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
46
47
48
49
50
51
#!/bin/bash
set -e
if [ "$#" -lt 1 ]; then
echo
echo "Usage:"
echo " $ ./make-pages-admin.sh [-r] <EMAIL_ADDRESS>"
echo
echo " Options:"
echo " -r : Remove the user instead of add"
echo
echo " Be sure to run ./cg-scripts/uaa/login.sh prior to executing this script"
echo
exit 1;
fi
USER=$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
declare -a admin_groups=("pages.admin" "scim.read")
if $REMOVE; then
for group in ${admin_groups[@]}
do
echo -n "Removing user from group ${group}... "
uaac member delete "${group}" "${USER}" || true
done
else
for group in ${admin_groups[@]}
do
echo -n "Adding user to group ${group}... "
uaac member add "${group}" "${USER}" || true
done
fi
echo "DONE"