28 lines
860 B
Bash
28 lines
860 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
APP_DIR=/var/www/html/wms-app
|
|
CONFIG=$APP_DIR/app/config.php
|
|
|
|
# Generate app/config.php from template on first run only.
|
|
# Restrict envsubst to known placeholders so it never touches the app's own
|
|
# $variable syntax (envsubst blanks out any $NAME it doesn't recognize).
|
|
if [ ! -f "$CONFIG" ]; then
|
|
echo "[entrypoint] generating app/config.php"
|
|
envsubst '${DB_ROOT_PASSWORD} ${PUBLIC_HOST} ${EMIT_SECRET} ${SMTP_USERNAME} ${SMTP_PASSWORD}' \
|
|
< /usr/local/etc/wms/config.php.template > "$CONFIG"
|
|
fi
|
|
|
|
mkdir -p "$APP_DIR/app/uploads"
|
|
chown -R www-data:www-data "$APP_DIR/app/uploads"
|
|
|
|
echo "[entrypoint] waiting for database at db:3306"
|
|
until mysqladmin ping -h db -u root -p"$DB_ROOT_PASSWORD" --silent 2>/dev/null; do
|
|
sleep 2
|
|
done
|
|
|
|
echo "[entrypoint] running setup.php (idempotent schema sync)"
|
|
php "$APP_DIR/setup.php" || true
|
|
|
|
exec "$@"
|