wordpress/rootfs/etc/cont-init.d/20-install-plugins

33 lines
894 B
Plaintext
Raw Normal View History

2021-02-09 21:27:12 +01:00
#!/usr/bin/with-contenv bash
set -e
2021-02-09 21:57:12 +01:00
PLUGIN_LIST="${WORDPRESS_PLUGIN_LIST:-}"
WP_CONTENT_PATH="/var/www/${WEB_ROOT}/wp-content"
2021-02-09 21:27:12 +01:00
echo "> Automated WordPress Plugin Installer"
if [ -z "${PLUGIN_LIST}" ]; then
echo "> No plugins defined. Skipping installation."
exit 0
fi
echo "> About to install defined plugins"
2021-02-15 01:16:24 +01:00
for PLUGIN_EXPR in ${PLUGIN_LIST}; do
IFS=':' read -ra PLUGIN <<<"${PLUGIN_EXPR}"
2021-02-09 21:27:12 +01:00
WP_PLUGIN_INSTALL_ARGS="${PLUGIN[0]}"
if [ -n "${PLUGIN[1]}" ]; then
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
2021-02-09 21:27:12 +01:00
echo "> Installing plugin '${PLUGIN[0]}' version '${PLUGIN[1]}'"
wp plugin install ${WP_PLUGIN_INSTALL_ARGS}
done