From c6b13f9b5372f6d03d26b879694b13d5f3868392 Mon Sep 17 00:00:00 2001 From: 88lex Date: Mon, 8 May 2023 09:59:53 +0800 Subject: [PATCH] Add check for sa-gen.conf , create if it does not exist --- README.md | 5 +++-- sa-gen | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 074d42e..dc4c6ec 100755 --- a/README.md +++ b/README.md @@ -3,8 +3,9 @@ May 2023 NOTE: `sa-gen` has been updated to - Create a Google Group if it does not already exist (set in sa-gen.conf) - Automatically add service account emails to the specified Google Group - - Install gcloud sdk (if you need) with the `install_gcloud` script - - Use sa-gen.conf to specify variables (You must rename or copy sa-gen-default.conf to sa-gen.conf, then edit it) + - Install gcloud sdk with the `install_gcloud` script + - Edit sa-gen.conf to specify group name, group email, etc. + - If no sa-gen.conf exists then running sa-gen Creates a default sa-gen.conf, then stops. Edit with nano/vim - Generate a random alphanumeric SUFFIX for your projects (Google needs a unique project name) - SUFFIX may also be set manually in `sa-gen.conf` if you like - Prior versions of sa-gen still run, and have been put in the /old directory diff --git a/sa-gen b/sa-gen index 092dc61..0e88339 100755 --- a/sa-gen +++ b/sa-gen @@ -1,5 +1,13 @@ #!/bin/bash -v +function check_config() { + if [ ! -f sa-gen.conf ]; then + cp sa-gen-default.conf sa-gen.conf + echo -e "\nCreated sa-gen.conf with default settings.\nEdit using nano or vim to specify a group name and email.\n" + exit + fi +} + # Display gcloud sdk organization and active admin project and enable admin APIs function check_prereqs() { gcloud organizations list @@ -42,6 +50,7 @@ function create_service_accounts() { } function main() { + check_config check_prereqs source sa-gen.conf create_projects