From 5ff28d523bb7666a528c31ea4a19a70210d2d394 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Sat, 8 May 2021 12:01:53 +0100 Subject: [PATCH] Deactivate removed plugins before startup This adds a new dependency to the image: jq Closes #11 --- scripts/entrypoint.sh | 16 ++++++++++++++++ scripts/install-deps.sh | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 6161a32..8ab4ad0 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -171,6 +171,8 @@ setup_components() { [[ $(wp theme list --status=active --format=count) -eq 0 ]] && wp theme activate $(wp theme list --field=name | head -n1) + deactivate_missing_plugins + setup_s3 return 0 @@ -221,6 +223,20 @@ collect_static() . static/ } +deactivate_missing_plugins() +{ + local plugin + wp option get active_plugins --format=json | + jq -r '.[]' | + while read plugin; do + test -e wp-content/plugins/$plugin && + echo $plugin || + echo >&2 "Deactivating removed plugin: $(dirname $plugin)" + done | + jq -R '[[.],[inputs]]|add' | + wp option update active_plugins --format=json +} + next_cron() { echo $(($(wp cron event list --field=time|sort|head -n1) - $(date +%s))) diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index e6b4d75..51d0f81 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -1,4 +1,10 @@ #!/bin/sh +# Copyright 2019-2021 Dominik Sekotill +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + set -eux # Install packaged dependencies @@ -6,6 +12,7 @@ apk update apk add \ bash \ imagemagick-libs \ + jq \ libgmpxx \ libjpeg \ libpng \ -- GitLab