2019-08-16 11:38:26 -05:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -e
|
|
|
|
|
2021-12-07 12:14:56 -06:00
|
|
|
# If SHELL_VERBOSITY was not explicitly provided, run commands in quite mode (-q)
|
|
|
|
[ $SHELL_VERBOSITY ] && flags="" || flags="-q"
|
|
|
|
|
2019-08-16 11:38:26 -05:00
|
|
|
cd /etc/shlink
|
|
|
|
|
|
|
|
echo "Creating fresh database if needed..."
|
2021-12-07 12:14:56 -06:00
|
|
|
php bin/cli db:create -n ${flags}
|
2019-08-16 11:38:26 -05:00
|
|
|
|
|
|
|
echo "Updating database..."
|
2021-12-07 12:14:56 -06:00
|
|
|
php bin/cli db:migrate -n ${flags}
|
2019-08-16 11:38:26 -05:00
|
|
|
|
|
|
|
echo "Generating proxies..."
|
2021-12-07 12:14:56 -06:00
|
|
|
php vendor/doctrine/orm/bin/doctrine.php orm:generate-proxies -n ${flags}
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2020-04-06 13:52:33 -05:00
|
|
|
echo "Clearing entities cache..."
|
2021-12-07 12:14:56 -06:00
|
|
|
php vendor/doctrine/orm/bin/doctrine.php orm:clear-cache:metadata -n ${flags}
|
2020-04-06 13:52:33 -05:00
|
|
|
|
2021-04-08 07:32:19 -05:00
|
|
|
# Try to download GeoLite2 db file only if the license key env var was defined
|
|
|
|
if [ ! -z "${GEOLITE_LICENSE_KEY}" ]; then
|
|
|
|
echo "Downloading GeoLite2 db file..."
|
2021-12-07 12:14:56 -06:00
|
|
|
php bin/cli visit:download-db -n ${flags}
|
2021-04-08 07:32:19 -05:00
|
|
|
fi
|
|
|
|
|
2021-05-26 08:45:24 -05:00
|
|
|
# Periodicaly run visit:locate every hour
|
|
|
|
# https://shlink.io/documentation/long-running-tasks/#locate-visits
|
2021-05-30 10:41:40 -05:00
|
|
|
# set env var "ENABLE_PERIODIC_VISIT_LOCATE=true" to enable
|
2021-05-26 08:45:24 -05:00
|
|
|
if [ $ENABLE_PERIODIC_VISIT_LOCATE ]; then
|
2021-08-01 01:55:39 -05:00
|
|
|
echo "Configuring periodic visit locate..."
|
2021-05-30 10:41:00 -05:00
|
|
|
echo "0 * * * * php /etc/shlink/bin/cli visit:locate -q" > /etc/crontabs/root
|
2021-05-26 08:45:24 -05:00
|
|
|
/usr/sbin/crond &
|
|
|
|
fi
|
|
|
|
|
2021-12-05 03:08:10 -06:00
|
|
|
# When restarting the container, openswoole might think it is already in execution
|
2019-08-16 11:38:26 -05:00
|
|
|
# This forces the app to be started every second until the exit code is 0
|
2021-01-14 13:19:38 -06:00
|
|
|
until php vendor/bin/laminas mezzio:swoole:start; do sleep 1 ; done
|