1- #! /bin/ash -e
1+ #! /bin/sh -eu
22# check for .env file or symlink and generate app keys if missing
33if [ -f /var/www/html/.env ]; then
44 echo " external vars exist."
1010 touch /pelican-data/.env
1111
1212 # manually generate a key because key generate --force fails
13- if [ -z ${APP_KEY} ]; then
14- echo -e " Generating key."
13+ if [ -z " ${APP_KEY:- } " ]; then
14+ echo " Generating key."
1515 APP_KEY=$( cat /dev/urandom | tr -dc ' a-zA-Z0-9' | fold -w 32 | head -n 1)
16- echo -e " Generated app key: $APP_KEY "
17- echo -e " APP_KEY=$APP_KEY " > /pelican-data/.env
16+ echo " Generated app key: $APP_KEY "
17+ printf ' %s\n ' " APP_KEY=$APP_KEY " > /pelican-data/.env
1818 else
19- echo -e " APP_KEY exists in environment, using that."
20- echo -e " APP_KEY=$APP_KEY " > /pelican-data/.env
19+ echo " APP_KEY exists in environment, using that."
20+ printf ' %s\n ' " APP_KEY=$APP_KEY " > /pelican-data/.env
2121 fi
2222
2323 # enable installer
24- echo -e " APP_INSTALLED=false" >> /pelican-data/.env
24+ printf ' %s\n ' " APP_INSTALLED=false" >> /pelican-data/.env
2525fi
2626
2727# create directories for volumes
2828mkdir -p /pelican-data/database /pelican-data/storage/avatars /pelican-data/storage/fonts /pelican-data/storage/icons /pelican-data/plugins /var/www/html/storage/logs/supervisord 2> /dev/null
2929
3030# if the app is installed then we need to run migrations on start. New installs will run migrations when you run the installer.
31- if [ " ${APP_INSTALLED} " == " true" ]; then
31+ if [ " ${APP_INSTALLED:- } " = " true " ] && [ " ${SKIP_MIGRATIONS :- } " ! = " true" ]; then
3232 # if the db is anything but sqlite wait until it's accepting connections
33- if [ " ${DB_CONNECTION} " != " sqlite" ]; then
33+ if [ " ${DB_CONNECTION:- } " != " sqlite" ]; then
3434 # check for DB up before starting the panel
3535 echo " Checking database status."
36- until nc -z -v -w30 $ DB_HOST $ DB_PORT
36+ until nc -z -v -w30 " ${ DB_HOST:- } " " ${ DB_PORT:- } "
3737 do
3838 echo " Waiting for database connection..."
3939 # wait for 1 seconds before check again
@@ -44,21 +44,31 @@ if [ "${APP_INSTALLED}" == "true" ]; then
4444 php artisan migrate --force
4545fi
4646
47- echo -e " Optimizing Filament"
47+ echo " Optimizing Filament"
4848php artisan filament:optimize
4949
5050# default to caddy not starting
5151export SUPERVISORD_CADDY=false
52+ export SUPERVISORD_QUEUE=true
53+ export SUPERVISORD_SCHEDULER=true
5254export PARSED_APP_URL=${APP_URL}
5355
56+ # allow running the queue worker and scheduler in separate containers later
57+ if [ " ${SKIP_QUEUE:- } " = " true" ]; then
58+ export SUPERVISORD_QUEUE=false
59+ fi
60+ if [ " ${SKIP_SCHEDULER:- } " = " true" ]; then
61+ export SUPERVISORD_SCHEDULER=false
62+ fi
63+
5464# checking if app url is using https
5565if echo " ${APP_URL} " | grep -qE ' ^https://' ; then
5666 echo " https domain found setting email var"
5767 export PARSED_LE_EMAIL=" email ${LE_EMAIL} "
5868fi
5969
6070# when running behind a proxy
61- if [ " ${BEHIND_PROXY} " = = " true" ]; then
71+ if [ " ${BEHIND_PROXY:- } " = " true" ]; then
6272 echo " running behind proxy"
6373 echo " listening on port 80 internally"
6474 export PARSED_LE_EMAIL=" "
@@ -68,19 +78,19 @@ if [ "${BEHIND_PROXY}" == "true" ]; then
6878fi
6979
7080# disable caddy if SKIP_CADDY is set
71- if [ " ${SKIP_CADDY:- } " == " true" ]; then
72- echo " Starting PHP-FPM only "
81+ if [ " ${SKIP_CADDY:- } " = " true" ]; then
82+ echo " Starting app services without web server "
7383else
74- echo " Starting PHP-FPM and Caddy "
84+ echo " Starting app services "
7585 # enable caddy
7686 export SUPERVISORD_CADDY=true
7787
7888 # handle trusted proxies for caddy when variable has data
79- if [ ! -z ${TRUSTED_PROXIES} ]; then
89+ if [ -n " ${TRUSTED_PROXIES:- } " ]; then
8090 export CADDY_TRUSTED_PROXIES=$( echo " trusted_proxies static ${TRUSTED_PROXIES} " | sed ' s/,/ /g' )
8191 export CADDY_STRICT_PROXIES=" trusted_proxies_strict"
8292 fi
8393fi
8494
8595echo " Starting Supervisord"
86- exec " $@ "
96+ exec " $@ "
0 commit comments