Update start.sh to handle missing or empty APP_KEY
This commit is contained in:
parent
d9c60efc15
commit
3e1c883cb5
20
start.sh
20
start.sh
|
@ -1,7 +1,19 @@
|
|||
#!/bin/sh
|
||||
sleep 10
|
||||
if [ -z "$(grep '^APP_KEY=' /var/www/html/.env)" ]; then
|
||||
php artisan key:generate
|
||||
|
||||
# Check if .env file exists, if not create it from .env.example
|
||||
if [ ! -f /var/www/html/.env ]; then
|
||||
cp /var/www/html/.env.example /var/www/html/.env
|
||||
fi
|
||||
php artisan migrate --force
|
||||
php-fpm
|
||||
|
||||
# Check if APP_KEY is missing or empty
|
||||
if [ -z "$(grep '^APP_KEY=.\+' /var/www/html/.env)" ]; then
|
||||
echo "Generating APP_KEY..."
|
||||
php artisan key:generate || { echo "Failed to generate APP_KEY"; exit 1; }
|
||||
fi
|
||||
|
||||
# Run migrations
|
||||
php artisan migrate --force || { echo "Failed to run migrations"; exit 1; }
|
||||
|
||||
# Start PHP-FPM
|
||||
php-fpm || { echo "Failed to start PHP-FPM"; exit 1; }
|
||||
|
|
Loading…
Reference in New Issue