mirror of
https://github.com/N0rthernL1ghts/wordpress.git
synced 2024-11-23 15:22:29 +01:00
Refactor to new S6 format
This commit is contained in:
parent
63832d68b4
commit
4cb7286fc4
|
@ -20,19 +20,19 @@ checkInstalled() {
|
|||
PLUGIN_SLUG="${PLUGIN[0]}"
|
||||
|
||||
if wp-plugin check "${PLUGIN_SLUG}"; then
|
||||
echo "> Plugin '${PLUGIN_SLUG}' installed"
|
||||
echo "Plugin '${PLUGIN_SLUG}' installed"
|
||||
continue
|
||||
fi
|
||||
|
||||
((FAILED_COUNT = FAILED_COUNT + 1))
|
||||
echo "> Warning: Plugin '${PLUGIN_SLUG}' failed to install"
|
||||
echo "Warning: Plugin '${PLUGIN_SLUG}' failed to install"
|
||||
done
|
||||
|
||||
if [ "${FAILED_COUNT}" = "0" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "> Total of ${FAILED_COUNT} plugins failed to install"
|
||||
echo "Total of ${FAILED_COUNT} plugins failed to install"
|
||||
return 1
|
||||
}
|
||||
|
||||
|
@ -42,13 +42,13 @@ function taskInstallPlugins() {
|
|||
|
||||
CONCURRENCY_LIMIT="${WP_PLUGINS_INSTALL_CONCURRENCY:-5}"
|
||||
|
||||
echo "> Automated WordPress Plugins Installer"
|
||||
echo "Automated WordPress Plugins Installer"
|
||||
if [ -z "${PLUGIN_LIST}" ]; then
|
||||
echo "> No plugins defined. Skipping installation."
|
||||
echo "No plugins defined. Skipping installation."
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "> About to install defined plugins"
|
||||
echo "About to install defined plugins"
|
||||
for PLUGIN_EXPR in ${PLUGIN_LIST}; do
|
||||
|
||||
# Split plugin name and version
|
||||
|
@ -58,15 +58,15 @@ function taskInstallPlugins() {
|
|||
PLUGIN_VERSION="${PLUGIN[1]:-}"
|
||||
|
||||
if wp-plugin check "${PLUGIN_SLUG}"; then
|
||||
echo "> Plugin '${PLUGIN_SLUG}' already installed and will be skipped."
|
||||
echo "Plugin '${PLUGIN_SLUG}' already installed and will be skipped."
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -n "${PLUGIN_VERSION}" ]; then
|
||||
echo "> Installing plugin '${PLUGIN_SLUG}' version '${PLUGIN_VERSION}'"
|
||||
echo "Installing plugin '${PLUGIN_SLUG}' version '${PLUGIN_VERSION}'"
|
||||
installPlugin "${PLUGIN_SLUG}" "${PLUGIN_VERSION}" &
|
||||
else
|
||||
echo "> Installing plugin '${PLUGIN_SLUG}'"
|
||||
echo "Installing plugin '${PLUGIN_SLUG}'"
|
||||
installPlugin "${PLUGIN_SLUG}" &
|
||||
fi
|
||||
|
||||
|
@ -77,28 +77,30 @@ function taskInstallPlugins() {
|
|||
done
|
||||
done
|
||||
|
||||
echo "> Waiting for all tasks to finish..."
|
||||
echo "Waiting for all tasks to finish..."
|
||||
wait
|
||||
|
||||
# Plugins are installed concurrently, so we need to verify if installed, separately
|
||||
echo "> About to verify install of defined plugins"
|
||||
echo "About to verify install of defined plugins"
|
||||
|
||||
if ! checkInstalled; then
|
||||
echo "> Some plugins failed to install"
|
||||
echo "Some plugins failed to install"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "> All plugins installed successfully"
|
||||
echo "All plugins installed successfully"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Main function
|
||||
# init-install-resources main
|
||||
main() {
|
||||
exec > >(while read line; do echo "[init-install-resources] ${line}"; done) 2>&1
|
||||
|
||||
PLUGIN_LIST="${WORDPRESS_PLUGIN_LIST:-}"
|
||||
WP_CONTENT_PATH="/var/www/html/wp-content"
|
||||
WP_PLUGINS_PATH="${WP_CONTENT_PATH}/plugins"
|
||||
|
||||
echo "> Automated WordPress Resources Installer"
|
||||
echo "Automated WordPress Resources Installer"
|
||||
|
||||
export WP_CONTENT_PATH
|
||||
|
||||
|
@ -108,10 +110,9 @@ main() {
|
|||
taskInstallPlugins "${@}" &
|
||||
|
||||
sleep 1
|
||||
echo "> Waiting for all tasks to complete"
|
||||
echo "Waiting for all tasks to complete"
|
||||
wait
|
||||
return 0
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
exit $?
|
|
@ -0,0 +1 @@
|
|||
oneshot
|
1
rootfs/etc/s6-overlay/s6-rc.d/init-install-resources/up
Normal file
1
rootfs/etc/s6-overlay/s6-rc.d/init-install-resources/up
Normal file
|
@ -0,0 +1 @@
|
|||
/etc/s6-overlay/s6-rc.d/init-install-resources/run
|
|
@ -8,11 +8,11 @@ trap scriptExitHandler EXIT
|
|||
function scriptExitHandler() {
|
||||
LAST_EXIT_CODE=$?
|
||||
if [ "${LAST_EXIT_CODE}" = "0" ]; then
|
||||
echo "> Script finished successfully"
|
||||
echo "Script finished successfully"
|
||||
exit "${LAST_EXIT_CODE}"
|
||||
fi
|
||||
|
||||
echo "> Script finished with an error"
|
||||
echo "Script finished with an error"
|
||||
exit "${LAST_EXIT_CODE}"
|
||||
}
|
||||
|
||||
|
@ -20,38 +20,40 @@ function reportUnhealthy() {
|
|||
echo "${1:?REASON is required}" >"/tmp/.wp-unhealthy"
|
||||
}
|
||||
|
||||
# Main function
|
||||
# init-verify-wordpress main
|
||||
function main() {
|
||||
|
||||
exec > >(while read line; do echo "[init-verify-wordpress] ${line}"; done) 2>&1
|
||||
|
||||
# Removes trailing zero if found
|
||||
# This is required due to inconsistencies between WodPress docker image versioning and wp-cli core download
|
||||
# If patch version is 0, it is not considered by wp-cli.
|
||||
WP_VERSION=$(echo "${WP_VERSION:?}" | sed --expression='s/.0$//g')
|
||||
|
||||
echo "> Verifying 'WordPress ${WP_VERSION}' installation..."
|
||||
echo "Verifying 'WordPress ${WP_VERSION}' installation..."
|
||||
WP_INSTALLED_VERSION="$(wp core version)"
|
||||
|
||||
set -e
|
||||
|
||||
rm -f "/tmp/.wp-unhealthy"
|
||||
if [ -z "${WP_INSTALLED_VERSION}" ]; then
|
||||
echo "> ERROR! WordPress installation does not seem to be present or valid. Continuing anyway..."
|
||||
echo "Error: WordPress installation does not seem to be present or valid. Continuing anyway..."
|
||||
|
||||
reportUnhealthy "WP_NOT_PRESENT"
|
||||
return 0
|
||||
elif [ "${WP_INSTALLED_VERSION}" != "${WP_VERSION}" ]; then
|
||||
echo "> WARNING! WordPress version mismatch"
|
||||
echo " Expected version: ${WP_VERSION}"
|
||||
echo " Detected version: ${WP_INSTALLED_VERSION}"
|
||||
echo "> Seems like WordPress installation got updated outside image scope"
|
||||
echo " - This is dangerous as changes will not persist when container is recreated which might lead to inconsistencies between installation and the database."
|
||||
echo " - You should assume that recreating the container will render the website inoperable."
|
||||
echo " - Please make sure that you're running image: nlss/wordpress:${WP_VERSION}"
|
||||
echo "WARNING! WordPress version mismatch"
|
||||
echo " Expected version: ${WP_VERSION}"
|
||||
echo " Detected version: ${WP_INSTALLED_VERSION}"
|
||||
echo "Seems like WordPress installation got updated outside image scope"
|
||||
echo " - This is dangerous as changes will not persist when container is recreated which might lead to inconsistencies between installation and the database."
|
||||
echo " - You should assume that recreating the container will render the website inoperable."
|
||||
echo " - Please make sure that you're running image: nlss/wordpress:${WP_VERSION}"
|
||||
reportUnhealthy "WP_VERSION_MISMATCH"
|
||||
return 0
|
||||
else
|
||||
echo "> Identified 'WordPress ${WP_VERSION}'"
|
||||
echo "Identified 'WordPress ${WP_VERSION}'"
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
exit $?
|
1
rootfs/etc/s6-overlay/s6-rc.d/init-verify-wordpress/type
Normal file
1
rootfs/etc/s6-overlay/s6-rc.d/init-verify-wordpress/type
Normal file
|
@ -0,0 +1 @@
|
|||
oneshot
|
1
rootfs/etc/s6-overlay/s6-rc.d/init-verify-wordpress/up
Normal file
1
rootfs/etc/s6-overlay/s6-rc.d/init-verify-wordpress/up
Normal file
|
@ -0,0 +1 @@
|
|||
/etc/s6-overlay/s6-rc.d/init-verify-wordpress/run
|
Loading…
Reference in New Issue
Block a user