Commit 5ff28d52 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Deactivate removed plugins before startup

This adds a new dependency to the image: jq

Closes #11
parent 6d65f52f
Loading
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -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)))
+7 −0
Original line number Diff line number Diff line
#!/bin/sh
# Copyright 2019-2021 Dominik Sekotill <dom.sekotill@kodo.org.uk>
#
# 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 \