2019-08-16 11:38:26 -05:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd /etc/shlink
|
|
|
|
|
2023-07-05 02:58:51 -05:00
|
|
|
flags="--no-interaction --clear-db-cache"
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2023-05-21 07:30:20 -05:00
|
|
|
# Skip downloading GeoLite2 db file if the license key env var was not defined or skipping was explicitly set
|
2023-07-05 02:58:51 -05:00
|
|
|
if [ -z "${GEOLITE_LICENSE_KEY}" ] || [ "${SKIP_INITIAL_GEOLITE_DOWNLOAD}" = "true" ]; then
|
2023-05-21 07:30:20 -05:00
|
|
|
flags="${flags} --skip-download-geolite"
|
2021-04-08 07:32:19 -05:00
|
|
|
fi
|
|
|
|
|
2023-05-21 07:30:20 -05:00
|
|
|
php vendor/bin/shlink-installer init ${flags}
|
|
|
|
|
2023-05-19 12:38:36 -05:00
|
|
|
# Periodically run visit:locate every hour, if ENABLE_PERIODIC_VISIT_LOCATE=true was provided and running as root
|
2023-05-23 03:55:49 -05:00
|
|
|
# ENABLE_PERIODIC_VISIT_LOCATE is deprecated. Remove cron support in Shlink 4.0.0
|
2023-05-19 12:38:36 -05:00
|
|
|
if [ "${ENABLE_PERIODIC_VISIT_LOCATE}" = "true" ] && [ "${SHLINK_USER_ID}" = "root" ]; then
|
2022-01-03 11:48:08 -06:00
|
|
|
echo "Configuring periodic visit location..."
|
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
|
|
|
|
|
2023-07-05 02:58:51 -05:00
|
|
|
if [ "$SHLINK_RUNTIME" = 'openswoole' ]; then
|
2023-06-03 02:08:07 -05:00
|
|
|
# Openswoole is deprecated. Remove in Shlink 4.0.0
|
2022-08-27 06:01:38 -05:00
|
|
|
# When restarting the container, openswoole might think it is already in execution
|
|
|
|
# This forces the app to be started every second until the exit code is 0
|
|
|
|
until php vendor/bin/laminas mezzio:swoole:start; do sleep 1 ; done
|
2023-07-05 02:58:51 -05:00
|
|
|
elif [ "$SHLINK_RUNTIME" = 'rr' ]; then
|
2022-08-27 06:01:38 -05:00
|
|
|
./bin/rr serve -c config/roadrunner/.rr.yml
|
|
|
|
fi
|