Co-authored-by: jon brookes <marshyon@gmail.com> Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/20
37 lines
944 B
Bash
37 lines
944 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
# Ensure APP_KEY is set and persisted
|
|
PERSISTED_KEY="/var/www/storage/.app_key"
|
|
|
|
if [ -z "$APP_KEY" ]; then
|
|
if [ -f "$PERSISTED_KEY" ]; then
|
|
echo "Using persisted APP_KEY from: $PERSISTED_KEY"
|
|
export APP_KEY=$(cat "$PERSISTED_KEY")
|
|
else
|
|
# Generate key, strip "base64:", and save
|
|
NEW_KEY=$(php artisan key:generate --show --no-interaction)
|
|
echo "Generated new APP_KEY to: $PERSISTED_KEY"
|
|
echo "$NEW_KEY" > "$PERSISTED_KEY"
|
|
export APP_KEY="$NEW_KEY"
|
|
fi
|
|
fi
|
|
|
|
# check to see if /var/www/database/database.sqlite exists
|
|
# if not, run migrations
|
|
if [ ! -f /var/www/database/database.sqlite ]; then
|
|
php artisan migrate --force
|
|
fi
|
|
|
|
# check to see if /var/www/public/storage exists
|
|
# if not, run storage:link
|
|
if [ ! -d /var/www/public/storage ]; then
|
|
php artisan storage:link
|
|
fi
|
|
|
|
php artisan config:clear
|
|
npm run build
|
|
|
|
# Start supervisord directly
|
|
exec "$@"
|
|
|