From e9c35c6bd2eb3c1a8ade1078639bf4f9524f1e72 Mon Sep 17 00:00:00 2001 From: xZero707 Date: Mon, 15 Feb 2021 01:14:42 +0100 Subject: [PATCH] Optimize plugin installer performance Implement manual plugin existence check. WP-CLI is quite slow and processing large list of plugins delays container boot too much --- rootfs/etc/cont-init.d/20-install-plugins | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rootfs/etc/cont-init.d/20-install-plugins b/rootfs/etc/cont-init.d/20-install-plugins index 16082e2..067e68c 100755 --- a/rootfs/etc/cont-init.d/20-install-plugins +++ b/rootfs/etc/cont-init.d/20-install-plugins @@ -2,6 +2,7 @@ set -e PLUGIN_LIST="${WORDPRESS_PLUGIN_LIST:-}" +WP_CONTENT_PATH="/var/www/${WEB_ROOT}/wp-content" echo "> Automated WordPress Plugin Installer" @@ -20,6 +21,13 @@ for PLUGIN_NAME in ${PLUGIN_LIST}; do WP_PLUGIN_INSTALL_ARGS="${WP_PLUGIN_INSTALL_ARGS} --version=${PLUGIN[1]}" fi + PLUGIN_PATH="${WP_CONTENT_PATH}/plugins/${PLUGIN[0]}" + + if [ -d "${PLUGIN_PATH}" ] || [ -f "${PLUGIN_PATH}.php" ]; then + echo "> Plugin '${PLUGIN[0]}' already installed and will be skipped." + continue + fi + echo "> Installing plugin '${PLUGIN[0]}' version '${PLUGIN[1]}'" wp plugin install ${WP_PLUGIN_INSTALL_ARGS} done \ No newline at end of file