misc_pterodactyl-panel/.dev/docker/entrypoint.sh

46 lines
1,016 B
Bash
Raw Normal View History

2018-05-18 02:53:17 +00:00
#!/bin/ash
2018-08-04 23:21:51 +00:00
## Ensure we are in /app
2018-05-18 13:11:33 +00:00
cd /app
2018-08-04 23:21:51 +00:00
## check for .env file and generate app keys if missing
if [ -f /app/var/.env ]; then
echo "external vars exist"
rm /app/.env
2018-08-14 03:33:15 +00:00
2018-08-04 23:21:51 +00:00
ln -s /app/var/.env /app/
else
echo "external vars don't exist"
2018-08-14 03:33:15 +00:00
rm /app/.env
touch /app/var/.env
## manually generate a key because key generate --force fails
echo -e "Generating key"
APP_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo -e "Generated app key: $APP_KEY"
echo -e "APP_KEY=$APP_KEY" > /app/var/.env
ln -s /app/var/.env /app/
2018-08-04 23:21:51 +00:00
fi
2018-05-18 02:53:17 +00:00
2018-08-04 23:21:51 +00:00
## check for DB up before starting the panel
echo "Checking database status."
2018-05-18 02:53:17 +00:00
until nc -z -v -w30 $DB_HOST 3306
2018-08-04 23:21:51 +00:00
2018-05-18 02:53:17 +00:00
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
2018-08-04 23:21:51 +00:00
## make sure the db is set up
echo -e "Migrating and Seeding DB"
php artisan migrate --force
php artisan db:seed --force
2018-05-18 12:55:12 +00:00
## start cronjobs for the queue
echo -e "Starting cron jobs"
crond
2018-05-18 12:55:12 +00:00
echo -e "Starting supervisord"
exec "$@"