From d5d9129cb88bc700a3a8f3759fc5d9768a18951f Mon Sep 17 00:00:00 2001 From: Daniel Del Rio Figueira Date: Fri, 7 May 2021 12:28:38 +0200 Subject: [PATCH] Changed: add new subscription file machinery --- debian/bin/docker-entrypoint.sh.rootless | 38 +++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/debian/bin/docker-entrypoint.sh.rootless b/debian/bin/docker-entrypoint.sh.rootless index 7a6ced1..330948e 100755 --- a/debian/bin/docker-entrypoint.sh.rootless +++ b/debian/bin/docker-entrypoint.sh.rootless @@ -70,6 +70,40 @@ gen_ssl_cert() { -keyout $ssl_key -out $ssl_cert } +get_subscription_file() { + if [ "${PASSBOLT_FLAVOUR}" == 'ce' ]; then + return 1 + fi + + # Look for subscription key on possible paths + for path in "${subscription_key_file_paths[@]}"; + do + if [ -f "${path}" ]; then + SUBSCRIPTION_FILE="${path}" + return 0 + fi + done + + return 1 +} + +import_subscription() { + if get_subscription_file; then + echo "Subscription file found: $SUBSCRIPTION_FILE" + su -c "/usr/share/php/passbolt/bin/cake passbolt subscription_import --file $SUBSCRIPTION_FILE" -s /bin/bash www-data + fi +} + +install_command() { + echo "Installing passbolt" + /usr/share/php/passbolt/bin/cake passbolt install --no-admin +} + +migrate_command() { + echo "Running migrations" + /usr/share/php/passbolt/bin/cake passbolt migrate +} + install() { if [ ! -f "$passbolt_config/app.php" ]; then cp $passbolt_config/app.default.php $passbolt_config/app.php @@ -80,7 +114,9 @@ install() { export PASSBOLT_GPG_SERVER_KEY_FINGERPRINT=$gpg_auto_fingerprint fi - /usr/share/php/passbolt/bin/cake passbolt install --no-admin || /usr/share/php/passbolt/bin/cake passbolt migrate && echo "Enjoy! ☮" + import_subscription || true + + install_command || migrate_command && echo "Enjoy! ☮" } create_deprecation_message() {