mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-08-03 22:52:13 +00:00
Fixes InvoiceShelf/docker#64 — recurring invoices and scheduled tasks running on the wrong timezone. Two bugs compounded so that no supported value had any effect: config/app.php had no timezone key at all, so Laravel's own fallback won — and that fallback is a literal 'UTC' string, not an env() lookup (vendor/laravel/framework/config/app.php). APP_TIMEZONE has therefore been inert since the config was slimmed, despite being shipped in .env.example. inject.sh wrote a bare TIMEZONE key into .env, which nothing reads, so setting the documented container variable also did nothing. It now writes APP_TIMEZONE, and accepts either name so existing compose files keep working without edits. Verified against a built image: TIMEZONE=Europe/Berlin now yields APP_TIMEZONE=Europe/Berlin in .env and config('app.timezone') == Europe/Berlin, where before both spellings left it on UTC.
87 lines
2.7 KiB
Bash
87 lines
2.7 KiB
Bash
#!/bin/bash
|
|
function replace_or_insert() {
|
|
# Voodoo magic: https://superuser.com/a/976712
|
|
grep -q "^${1}=" /var/www/html/.env && sed "s|^${1}=.*|${1}=${2}|" -i /var/www/html/.env || sed "$ a\\${1}=${2}" -i /var/www/html/.env
|
|
}
|
|
|
|
replace_or_insert "CONTAINERIZED" "true"
|
|
|
|
if [ "$APP_NAME" != '' ]; then
|
|
replace_or_insert "APP_NAME" "$APP_NAME"
|
|
fi
|
|
if [ "$APP_ENV" != '' ]; then
|
|
replace_or_insert "APP_ENV" "$APP_ENV"
|
|
fi
|
|
if [ "$APP_KEY" != '' ]; then
|
|
replace_or_insert "APP_KEY" "$APP_KEY"
|
|
fi
|
|
if [ "$APP_DEBUG" != '' ]; then
|
|
replace_or_insert "APP_DEBUG" "$APP_DEBUG"
|
|
fi
|
|
if [ "$APP_URL" != '' ]; then
|
|
replace_or_insert "APP_URL" "$APP_URL"
|
|
fi
|
|
if [ "$ASSET_URL" != '' ]; then
|
|
replace_or_insert "ASSET_URL" "$ASSET_URL"
|
|
fi
|
|
if [ "$APP_DIR" != '' ]; then
|
|
replace_or_insert "APP_DIR" "$APP_DIR"
|
|
fi
|
|
if [ "$DB_CONNECTION" != '' ]; then
|
|
replace_or_insert "DB_CONNECTION" "$DB_CONNECTION"
|
|
fi
|
|
if [ "$DB_HOST" != '' ]; then
|
|
replace_or_insert "DB_HOST" "$DB_HOST"
|
|
fi
|
|
if [ "$DB_PORT" != '' ]; then
|
|
replace_or_insert "DB_PORT" "$DB_PORT"
|
|
fi
|
|
if [ "$DB_DATABASE" != '' ]; then
|
|
replace_or_insert "DB_DATABASE" "$DB_DATABASE"
|
|
fi
|
|
if [ "$DB_USERNAME" != '' ]; then
|
|
replace_or_insert "DB_USERNAME" "$DB_USERNAME"
|
|
fi
|
|
if [ "$DB_PASSWORD" != '' ]; then
|
|
replace_or_insert "DB_PASSWORD" "$DB_PASSWORD"
|
|
elif [ "$DB_PASSWORD_FILE" != '' ]; then
|
|
value=$(<$DB_PASSWORD_FILE)
|
|
replace_or_insert "DB_PASSWORD" "$value"
|
|
fi
|
|
# Laravel reads APP_TIMEZONE. This previously wrote a bare TIMEZONE key, which
|
|
# nothing consumed, so setting the variable silently did nothing. Accept both
|
|
# names so existing compose files keep working.
|
|
if [ "$APP_TIMEZONE" != '' ]; then
|
|
replace_or_insert "APP_TIMEZONE" "$APP_TIMEZONE"
|
|
elif [ "$TIMEZONE" != '' ]; then
|
|
replace_or_insert "APP_TIMEZONE" "$TIMEZONE"
|
|
fi
|
|
if [ "$CACHE_STORE" != '' ]; then
|
|
replace_or_insert "CACHE_STORE" "$CACHE_STORE"
|
|
fi
|
|
if [ "$CACHE_DRIVER" != '' ]; then
|
|
replace_or_insert "CACHE_STORE" "$CACHE_DRIVER" # deprecated (will be removed later)
|
|
fi
|
|
if [ "$SESSION_DRIVER" != '' ]; then
|
|
replace_or_insert "SESSION_DRIVER" "$SESSION_DRIVER"
|
|
fi
|
|
if [ "$SESSION_LIFETIME" != '' ]; then
|
|
replace_or_insert "SESSION_LIFETIME" "$SESSION_LIFETIME"
|
|
fi
|
|
if [ "$QUEUE_CONNECTION" != '' ]; then
|
|
replace_or_insert "QUEUE_CONNECTION" "$QUEUE_CONNECTION"
|
|
fi
|
|
if [ "$BROADCAST_CONNECTION" != '' ]; then
|
|
replace_or_insert "BROADCAST_CONNECTION" "$BROADCAST_CONNECTION"
|
|
fi
|
|
if [ "$TRUSTED_PROXIES" != '' ]; then
|
|
replace_or_insert "TRUSTED_PROXIES" "$TRUSTED_PROXIES"
|
|
fi
|
|
if [ "$SANCTUM_STATEFUL_DOMAINS" != '' ]; then
|
|
replace_or_insert "SANCTUM_STATEFUL_DOMAINS" "$SANCTUM_STATEFUL_DOMAINS"
|
|
fi
|
|
if [ "$SESSION_DOMAIN" != '' ]; then
|
|
replace_or_insert "SESSION_DOMAIN" "$SESSION_DOMAIN"
|
|
fi
|
|
|