2019-08-16 11:38:26 -05:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd /etc/shlink
|
|
|
|
|
2024-01-03 12:22:33 -06:00
|
|
|
# Create data directories if they do not exist. This allows data dir to be mounted as an empty dir if needed
|
|
|
|
mkdir -p data/cache data/locks data/log data/proxies
|
|
|
|
|
2023-07-05 02:58:51 -05:00
|
|
|
flags="--no-interaction --clear-db-cache"
|
2019-08-16 11:38:26 -05:00
|
|
|
|
2024-10-13 05:24:59 -05:00
|
|
|
# Read env vars through Shlink command, so that it applies the `_FILE` env var fallback logic
|
2024-10-14 01:55:09 -05:00
|
|
|
geolite_license_key=$(bin/cli env-var:read GEOLITE_LICENSE_KEY)
|
|
|
|
skip_initial_geolite_download=$(bin/cli env-var:read SKIP_INITIAL_GEOLITE_DOWNLOAD)
|
|
|
|
initial_api_key=$(bin/cli env-var:read INITIAL_API_KEY)
|
2024-10-13 05:24:59 -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
|
2024-10-14 01:55:09 -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-09-21 02:29:59 -05:00
|
|
|
# If INITIAL_API_KEY was provided, create an initial API key
|
2024-10-14 01:55:09 -05:00
|
|
|
if [ -n "${initial_api_key}" ]; then
|
|
|
|
flags="${flags} --initial-api-key=${initial_api_key}"
|
2023-09-21 02:29:59 -05:00
|
|
|
fi
|
2023-09-21 01:58:05 -05:00
|
|
|
|
2023-05-21 07:30:20 -05:00
|
|
|
php vendor/bin/shlink-installer init ${flags}
|
|
|
|
|
2024-02-12 13:29:40 -06:00
|
|
|
if [ "$SHLINK_RUNTIME" = 'rr' ]; then
|
2024-10-17 08:03:55 -05:00
|
|
|
# Run with `exec` so that signals are properly handled
|
|
|
|
exec ./bin/rr serve -c config/roadrunner/.rr.yml
|
2022-08-27 06:01:38 -05:00
|
|
|
fi
|