From 1454526e655009c66866e7754129823be4bf9633 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 3 Nov 2016 11:38:23 -0400 Subject: [PATCH] gam-setup.bat file to automate Windows setup part of #309 --- src/gam-setup.bat | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/gam-setup.bat diff --git a/src/gam-setup.bat b/src/gam-setup.bat new file mode 100644 index 00000000..9a52f300 --- /dev/null +++ b/src/gam-setup.bat @@ -0,0 +1,72 @@ +@echo( +@set /p adminemail= "Please enter your G Suite admin email address: " + +:createproject +@echo( +@set /p yn= "Are you ready to set up a Google API project for GAM? [y or n] " +@if /I "%yn%"=="n" ( +@ echo( +@ echo You can create an API project later by running: +@ echo( +@ echo gam create project +@ goto alldone + ) +@if /I not "%yn%"=="y" ( +@ echo( +@ echo Please answer y or n. +@ goto createproject + ) +@gam create project %adminemail% +@if not ERRORLEVEL 1 goto projectdone +@echo( +@echo Projection creation failed. Trying again. Say n to skip projection creation. +@goto createproject +:projectdone + +:adminauth +@echo( +@set /p yn= "Are you ready to authorize GAM to perform G Suite management operations as your admin account? [y or n] " +@if /I "%yn%"=="n" ( +@ echo( +@ echo You can authorize an admin later by running: +@ echo( +@ echo gam oauth create %adminemail% +@ goto admindone + ) +@if /I not "%yn%"=="y" ( +@ echo( +@ echo Please answer y or n. +@ goto adminauth + ) +@gam oauth create %adminemail% +@if not ERRORLEVEL 1 goto admindone +@echo( +@echo Admin authorization failed. Trying again. Say n to skip admin authorization. +@goto adminauth +:admindone + +:saauth +@echo( +@set /p yn= "Are you ready to authorize GAM to manage G Suite user data and settings? [y or n] " +@if /I "%yn%"=="n" ( +@ echo( +@ echo You can authorize a service account later by running: +@ echo( +@ echo gam user %adminemail% check serviceaccount +@ goto sadone + ) +@if /I not "%yn%"=="y" ( +@ echo( +@ echo Please answer y or n. +@ goto saauth + ) +@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 +@if not ERRORLEVEL 1 goto sadone +@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. +@goto saauth +:sadone + +echo GAM installation and setup complete! +:alldone \ No newline at end of file