#!/bin/sh
# Erstellt .env aus Docker Environment Variables
# Numerisches Prefix 10- = frueh ausfuehren

ENV_FILE="/var/www/html/.env"

if [ ! -f "$ENV_FILE" ]; then
    cat > "$ENV_FILE" << EOF
WP_ENV=${WP_ENV:-production}
WP_HOME=${WP_HOME}
WP_SITEURL=${WP_SITEURL}
DB_NAME=${DB_NAME}
DB_USER=${DB_USER}
DB_PASSWORD=${DB_PASSWORD}
DB_HOST=${DB_HOST}
WP_REDIS_HOST=${WP_REDIS_HOST:-redis}
AUTH_KEY=${AUTH_KEY}
SECURE_AUTH_KEY=${SECURE_AUTH_KEY}
LOGGED_IN_KEY=${LOGGED_IN_KEY}
NONCE_KEY=${NONCE_KEY}
AUTH_SALT=${AUTH_SALT}
SECURE_AUTH_SALT=${SECURE_AUTH_SALT}
LOGGED_IN_SALT=${LOGGED_IN_SALT}
NONCE_SALT=${NONCE_SALT}
EOF
    echo "[entrypoint] .env created"
fi
