30 lines
866 B
Bash
30 lines
866 B
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
set -a
|
||
|
|
|
||
|
|
# read environment variables from .env file
|
||
|
|
# for value of APP_DOMAIN_NAME
|
||
|
|
|
||
|
|
. .env
|
||
|
|
|
||
|
|
if [ -z "$APP_DOMAIN_NAME" ]; then
|
||
|
|
echo "Error: APP_DOMAIN_NAME environment variable is not set. Please set it in the .env file."
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Get the directory where the script is located
|
||
|
|
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||
|
|
cd "$SCRIPT_DIR" || { echo "Failed to change directory to $SCRIPT_DIR"; exit 1; }
|
||
|
|
# Define the template file path and output file path
|
||
|
|
TEMPLATE_FILE="../../k3s/forgejo/ingress.yaml.template"
|
||
|
|
OUTPUT_FILE="../../k3s/forgejo/ingress.yaml"
|
||
|
|
|
||
|
|
|
||
|
|
# Use envsubst to substitute the APP_DOMAIN_NAME variable into the template
|
||
|
|
envsubst < "$TEMPLATE_FILE" > "$OUTPUT_FILE"
|
||
|
|
if [ $? -ne 0 ]; then
|
||
|
|
echo "Error: Failed to substitute variables in the template."
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "Ingress configuration has been created at $OUTPUT_FILE"
|