2021-02-05 15:13:20 +01:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
enable_server() {
|
|
|
|
for name in "$@"; do
|
|
|
|
src_dir="/etc/nginx/sites-available"
|
|
|
|
dst_dir="/etc/nginx/sites-enabled"
|
|
|
|
mkdir -p "$dst_dir"
|
|
|
|
envsubst '${DOMAIN_NAME}' < "$src_dir/$name.conf" > "$dst_dir/$name.conf"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
enable_ssh_server() {
|
|
|
|
for name in "$@"; do
|
|
|
|
src_dir="/etc/nginx/ssh-available"
|
|
|
|
dst_dir="/etc/nginx/ssh-enabled"
|
|
|
|
mkdir -p "$dst_dir"
|
|
|
|
envsubst '${DOMAIN_NAME}' < "$src_dir/$name.conf" > "$dst_dir/$name.conf"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
sub_env_vars="$(cat /environment_variables.txt)"
|
|
|
|
|
|
|
|
echo "Enabling servers"
|
|
|
|
(
|
|
|
|
pushd "/etc/nginx/sites-available" || exit $?
|
2021-02-05 15:45:17 +01:00
|
|
|
mkdir "../sites-enabled" || exit $?
|
2021-02-05 15:13:20 +01:00
|
|
|
for f in *.conf; do
|
|
|
|
envsubst "$sub_env_vars" < "$f" > "../sites-enabled/$f"
|
|
|
|
done
|
|
|
|
)
|
|
|
|
|
|
|
|
echo "Starting nginx"
|
|
|
|
exec nginx -g 'daemon off;' -c /etc/nginx/nginx.conf
|