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

75 lines
2.2 KiB
Bash
Raw Normal View History

2018-05-18 02:53:17 +00:00
#!/bin/ash
2018-05-18 13:11:33 +00:00
cd /app
2018-11-10 23:57:49 +00:00
mkdir -p /var/log/panel/logs/ /var/log/supervisord/ /var/log/nginx/ /var/log/php7/ \
2020-11-14 21:10:11 +00:00
&& chmod 777 /var/log/panel/logs/ \
&& ln -s /var/log/panel/logs/ /app/storage/logs/
2018-11-10 23:57:49 +00:00
2018-08-04 23:21:51 +00:00
## check for .env file and generate app keys if missing
if [ -f /app/var/.env ]; then
2018-11-10 23:57:49 +00:00
echo "external vars exist."
2020-04-12 01:01:42 +00:00
rm -rf /app/.env
2018-08-04 23:21:51 +00:00
ln -s /app/var/.env /app/
else
2018-11-10 23:57:49 +00:00
echo "external vars don't exist."
2020-04-12 01:01:42 +00:00
rm -rf /app/.env
2018-08-14 03:33:15 +00:00
touch /app/var/.env
## manually generate a key because key generate --force fails
2020-11-06 13:23:05 +00:00
if [ -z $APP_KEY ]; then
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
else
echo -e "APP_KEY exists in environment, using that."
echo -e "APP_KEY=$APP_KEY" > /app/var/.env
fi
2018-08-14 03:33:15 +00:00
ln -s /app/var/.env /app/
2018-08-04 23:21:51 +00:00
fi
2018-05-18 02:53:17 +00:00
2018-11-10 23:57:49 +00:00
echo "Checking if https is required."
if [ -f /etc/nginx/conf.d/default.conf ]; then
echo "Using nginx config already in place."
2020-04-12 01:01:42 +00:00
if [ $LE_EMAIL ]; then
echo "Checking for cert update"
certbot certonly -d $(echo $APP_URL | sed 's~http[s]*://~~g') --standalone -m $LE_EMAIL --agree-tos -n
else
echo "No letsencrypt email is set"
fi
2018-11-10 23:57:49 +00:00
else
echo "Checking if letsencrypt email is set."
if [ -z $LE_EMAIL ]; then
2020-04-12 01:01:42 +00:00
echo "No letsencrypt email is set using http config."
cp docker/default.conf /etc/nginx/conf.d/default.conf
2018-11-10 23:57:49 +00:00
else
echo "writing ssl config"
cp docker/default_ssl.conf /etc/nginx/conf.d/default.conf
2018-11-10 23:57:49 +00:00
echo "updating ssl config for domain"
sed -i "s|<domain>|$(echo $APP_URL | sed 's~http[s]*://~~g')|g" /etc/nginx/conf.d/default.conf
echo "generating certs"
certbot certonly -d $(echo $APP_URL | sed 's~http[s]*://~~g') --standalone -m $LE_EMAIL --agree-tos -n
fi
fi
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
do
echo "Waiting for database connection..."
2020-11-14 21:58:51 +00:00
# wait for 1 seconds before check again
sleep 1
2018-05-18 02:53:17 +00:00
done
2018-08-04 23:21:51 +00:00
## make sure the db is set up
2018-11-10 23:57:49 +00:00
echo -e "Migrating and Seeding D.B"
2020-11-14 21:10:11 +00:00
php artisan migrate --seed --force
2018-05-18 12:55:12 +00:00
## start cronjobs for the queue
2018-11-10 23:57:49 +00:00
echo -e "Starting cron jobs."
crond -L /var/log/crond -l 5
2018-05-18 12:55:12 +00:00
2018-11-10 23:57:49 +00:00
echo -e "Starting supervisord."
exec "$@"