You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
820 B
Bash
41 lines
820 B
Bash
#!/bin/bash
|
|
|
|
# this script generates the shared values for the
|
|
# terraform config (domain & subdomain variables)
|
|
|
|
# it depends on apps.config which should define:
|
|
# ROOT_DOMAIN - the root domain for all apps
|
|
# APP_CONFIGS - app-subdomain pairs, configured via a comma, like:
|
|
# app1,subdomain1 app2,subdomain2 app3,subdomain3
|
|
# full example:
|
|
# ROOT_DOMAIN=nassella.cc
|
|
# APP_CONFIGS="app1,subdomain1 app2,subdomain2 app3,subdomain3"
|
|
|
|
set -e
|
|
|
|
. apps.config
|
|
|
|
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
|
|
APP_CONFIGS+=('lb,root')
|
|
|
|
echo "domain = \"$ROOT_DOMAIN\""
|
|
echo -n "subdomains = ["
|
|
|
|
separator=''
|
|
|
|
for config_string in ${APP_CONFIGS[@]}; do
|
|
IFS=','
|
|
read -r -a config <<< "$config_string"
|
|
|
|
subdomain=${config[1]}
|
|
|
|
echo -n "$separator"
|
|
echo -n "\"$subdomain\""
|
|
|
|
separator=', '
|
|
done
|
|
|
|
echo "]"
|
|
|
|
|