Merge pull request #1787 from acelaya-forks/feature/shlink-init-command

Feature/shlink init command
This commit is contained in:
Alejandro Celaya 2023-05-21 14:44:08 +02:00 committed by GitHub
commit ac0ff8fb94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 19 deletions

View file

@ -18,6 +18,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
The CLI command includes a warning and requires the user to confirm before proceeding.
* [#1753](https://github.com/shlinkio/shlink/issues/1753) Add a new `vendor/bin/shlink-installer init` command that can be used to automate Shlink installations.
This command can create the initial database, update it, create proxies, clean cache, download initial GeoLite db files, etc
The official docker image also uses it on its entry point script.
* [#1656](https://github.com/shlinkio/shlink/issues/1656) Add support for openswoole 22
* [#1784](https://github.com/shlinkio/shlink/issues/1784) Add new docker tag where the container runs as a non-root user.

View file

@ -49,7 +49,7 @@
"shlinkio/shlink-config": "^2.4",
"shlinkio/shlink-event-dispatcher": "dev-main#8c677ae as 3.0",
"shlinkio/shlink-importer": "dev-main#6b63b12 as 5.1",
"shlinkio/shlink-installer": "dev-develop#0e015f8 as 8.4",
"shlinkio/shlink-installer": "dev-develop#9b7a090 as 8.4",
"shlinkio/shlink-ip-geolocation": "^3.2",
"shlinkio/shlink-json": "^1.0",
"spiral/roadrunner": "^2023.1",

View file

@ -1,29 +1,17 @@
#!/usr/bin/env sh
set -e
# If SHELL_VERBOSITY was not explicitly provided, run commands in quite mode (-q)
[ $SHELL_VERBOSITY ] && flags="" || flags="-q"
cd /etc/shlink
echo "Creating fresh database if needed..."
php bin/cli db:create -n ${flags}
flags="--clear-db-cache"
echo "Updating database..."
php bin/cli db:migrate -n ${flags}
echo "Generating proxies..."
php bin/doctrine orm:generate-proxies -n ${flags}
echo "Clearing entities cache..."
php bin/doctrine orm:clear-cache:metadata -n ${flags}
# Try to download GeoLite2 db file only if the license key env var was defined and skipping was not explicitly set
if [ ! -z "${GEOLITE_LICENSE_KEY}" ] && [ "${SKIP_INITIAL_GEOLITE_DOWNLOAD}" != "true" ]; then
echo "Downloading GeoLite2 db file..."
php bin/cli visit:download-db -n ${flags}
# Skip downloading GeoLite2 db file if the license key env var was not defined or skipping was explicitly set
if [ -z "${GEOLITE_LICENSE_KEY}" ] || [ "${SKIP_INITIAL_GEOLITE_DOWNLOAD}" == "true" ]; then
flags="${flags} --skip-download-geolite"
fi
php vendor/bin/shlink-installer init ${flags}
# Periodically run visit:locate every hour, if ENABLE_PERIODIC_VISIT_LOCATE=true was provided and running as root
if [ "${ENABLE_PERIODIC_VISIT_LOCATE}" = "true" ] && [ "${SHLINK_USER_ID}" = "root" ]; then
echo "Configuring periodic visit location..."