2025-08-19 16:40:43 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# this script generates the load-balancer
|
|
|
|
|
# config for the Caddy server.
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
2025-09-15 15:00:26 -07:00
|
|
|
. $1 # source the apps.config file with then env vars
|
2025-08-19 16:40:43 -07:00
|
|
|
|
2025-09-15 15:00:26 -07:00
|
|
|
host_admin_password_encoded=`echo "$HOST_ADMIN_PASSWORD" | docker run --rm -i caddy:2 caddy hash-password`
|
2025-08-31 15:57:26 -07:00
|
|
|
|
|
|
|
|
|
2025-08-19 16:40:43 -07:00
|
|
|
read -r -a APP_CONFIGS <<< "$APP_CONFIGS"
|
|
|
|
|
APP_CONFIGS+=('lb,root')
|
|
|
|
|
|
2026-07-03 10:14:03 -07:00
|
|
|
echo "ROOT_DOMAIN=\"${ROOT_DOMAIN}\""
|
2025-08-19 16:40:43 -07:00
|
|
|
|
|
|
|
|
for config_string in ${APP_CONFIGS[@]}; do
|
|
|
|
|
IFS=','
|
|
|
|
|
read -r -a config <<< "$config_string"
|
|
|
|
|
|
|
|
|
|
app=${config[0]}
|
|
|
|
|
subdomain=${config[1]}
|
|
|
|
|
|
2026-07-03 10:14:03 -07:00
|
|
|
echo "${app//-/_}_SUBDOMAIN=\"${subdomain}\""
|
2026-04-08 19:54:32 -07:00
|
|
|
done
|