Add check for sa-gen.conf , create if it does not exist

This commit is contained in:
88lex 2023-05-08 09:59:53 +08:00
parent 8dfdb0ab63
commit c6b13f9b53
2 changed files with 12 additions and 2 deletions

View file

@ -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

9
sa-gen
View file

@ -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