prompt for regular user to test service account.

This commit is contained in:
Jay Lee
2016-11-04 11:39:20 -04:00
parent ff3a8644ec
commit 082c34b453
2 changed files with 11 additions and 3 deletions

View File

@ -12,6 +12,7 @@ OPTIONS:
-o OS we are running (linux, macos). Default is to detect your OS with "uname -s". -o OS we are running (linux, macos). Default is to detect your OS with "uname -s".
-p Profile update (true, false). Should script add gam command to environment. Default is true. -p Profile update (true, false). Should script add gam command to environment. Default is true.
-u Admin user email address to use with GAM. Default is to prompt. -u Admin user email address to use with GAM. Default is to prompt.
-r Regular user email address. Used to test service account access to user data. Default is to prompt.
-v Version to install (latest, prerelease, draft, 3.8, etc). Default is latest. -v Version to install (latest, prerelease, draft, 3.8, etc). Default is latest.
EOF EOF
} }
@ -22,7 +23,8 @@ gamos=$(uname -s)
update_profile=true update_profile=true
gamversion="latest" gamversion="latest"
adminuser="" adminuser=""
while getopts "hd:a:o:p:u:v:" OPTION regularuser=""
while getopts "hd:a:o:p:u:r:v:" OPTION
do do
case $OPTION in case $OPTION in
h) usage; exit;; h) usage; exit;;
@ -31,6 +33,7 @@ do
o) gamos=$OPTARG;; o) gamos=$OPTARG;;
p) update_profile=$OPTARG;; p) update_profile=$OPTARG;;
u) adminuser=$OPTARG;; u) adminuser=$OPTARG;;
r) regularuser=$OPTARG;;
v) gamversion=$OPTARG;; v) gamversion=$OPTARG;;
?) usage; exit;; ?) usage; exit;;
esac esac
@ -236,6 +239,9 @@ while $project_created; do
read -p "Are you ready to authorize GAM to manage G Suite user data and settings? (yes or no) " yn read -p "Are you ready to authorize GAM to manage G Suite user data and settings? (yes or no) " yn
case $yn in case $yn in
[Yy]*) [Yy]*)
if [ "$regularuser" == "" ]; then
read -p "Please enter the email address of a regular G Suite user: " regularuser
fi
echo_yellow "Great! Checking service account scopes.This will fail the first time. Follow the steps to authorize and retry. It can take a few minutes for scopes to PASS after they've been authorized in the admin console." echo_yellow "Great! Checking service account scopes.This will fail the first time. Follow the steps to authorize and retry. It can take a few minutes for scopes to PASS after they've been authorized in the admin console."
$target_dir/gam/gam user $adminuser check serviceaccount $target_dir/gam/gam user $adminuser check serviceaccount
rc=$? rc=$?

View File

@ -60,8 +60,10 @@
@ echo Please answer y or n. @ echo Please answer y or n.
@ goto saauth @ goto saauth
) )
@echo(
@set /p regularuser= "Please enter the email address of a regular G Suite user: "
@echo Great! Checking service account scopes. This will fail the first time. Follow the steps to authorize and retry. It can take a few minutes for scopes to PASS after they've been authorized in the admin console. @echo Great! Checking service account scopes. This will fail the first time. Follow the steps to authorize and retry. It can take a few minutes for scopes to PASS after they've been authorized in the admin console.
@gam user %adminemail% check serviceaccount @gam user %regularuser% check serviceaccount
@if not ERRORLEVEL 1 goto sadone @if not ERRORLEVEL 1 goto sadone
@echo( @echo(
@echo Service account authorization failed. Confirm you entered the scopes correctly in the admin console. It can take a few minutes for scopes to PASS after they are entered in the admin console so if you're sure you entered them correctly, go grab a coffee and then hit Y to try again. Say N to skip admin authorization. @echo Service account authorization failed. Confirm you entered the scopes correctly in the admin console. It can take a few minutes for scopes to PASS after they are entered in the admin console so if you're sure you entered them correctly, go grab a coffee and then hit Y to try again. Say N to skip admin authorization.
@ -69,4 +71,4 @@
:sadone :sadone
echo GAM installation and setup complete! echo GAM installation and setup complete!
:alldone :alldone