Verified Commit fe18a95b authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Set update options in entrypoint

parent a4cd6c90
Loading
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -122,6 +122,21 @@ cause an error):
[script_debug]:
  https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/#script_debug

### ENABLE_MAJOR_UPDATES

**Type**: boolean|"enabled"|"disabled"\
**Required**: no\
**Default**: no

By default maintenance and security updates are always installed automatically while 
a container is live.  When this option is `yes`, `true` or `on`, the site will *also* 
automatically install major updates when they are released.

Note that major updates can include breaking changes and there is no guarantee the site will 
continue to operate without issues after an upgrade if this is enabled.  It is recommended 
this option is left disabled, and major upgrades are installed through deploying newer 
images.

### HOME_URL

**Type**: string\
+20 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ declare -r WORK_DIR=${PWD}

declare DB_HOST DB_NAME DB_USER DB_PASS
declare HOME_URL SITE_URL
declare ENABLE_MAJOR_UPDATES=disabled
declare -a THEMES=( ${THEMES-} )
declare -a PLUGINS=( ${PLUGINS-} )
declare -a LANGUAGES=( ${LANGUAGES-} )
@@ -52,6 +53,21 @@ timestamp()
	echo "[$(date --utc +'%Y-%m-%dT%H:%M:%S%z')] $*"
}

get_state()
(
	shopt -u nocasematch
	declare -n opt=$1
	local answers=${2-true/false}
	local enabled=${answers%%/*} disabled=${answers#*/}
	case ${opt? Option $1 must not be unset} in
		$enabled|true|on|yes|y) echo $enabled ;;
		$disabled|false|off|no|n) echo $disabled ;;
		*) timestamp "Unrecognised value for $1, please chose one of " \
				"'$enabled' or '$disabled'"
			exit 2 ;;
	esac
)

create_config()
{
	[[ -f wp-config.php ]] && unlink wp-config.php
@@ -79,6 +95,10 @@ create_config()

	wp config set WP_SITEURL "${site_url%/}"
	wp config set WP_HOME "${home_url%/}"

	wp option update auto_update_core_minor enabled
	wp option update auto_update_core_major \
		$(get_state ENABLE_MAJOR_UPDATES enabled/disabled)
}

setup_database() {