You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.5 KiB

# -*- mode: shell-script -*-
WORDPRESS_DIR="/opt/apps/wordpress"
WORDPRESS_CODE="$SERVICE_DATASTORE$WORDPRESS_DIR"
# WORDPRESS_RELEASE=6.6.2
# WORDPRESS_URL=https://github.com/WordPress/WordPress/archive/refs/tags/"${WORDPRESS_RELEASE}".tar.gz
WPCLI_RELEASE=2.11.0
WPCLI_URL=https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_RELEASE}/wp-cli-${WPCLI_RELEASE}.phar
WPCLI_DOCKER_IMAGE="wpcli:$WPCLI_RELEASE"
wp-cli:run() {
if ! docker_has_image "$WPCLI_DOCKER_IMAGE"; then
echo '
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&
chmod +x wp-cli.phar &&
mv wp-cli.phar /usr/local/bin/wp
' | DEBUG=1 dupd -t "$WPCLI_DOCKER_IMAGE" "$DOCKER_BASE_IMAGE" || {
err "Couldn't build $WPCLI_DOCKER_IMAGE."
return 1
}
info "Successfully built $WPCLI_DOCKER_IMAGE."
fi
docker run --rm \
-v "$WORDPRESS_CODE:$WORDPRESS_DIR" \
-w "$WORDPRESS_DIR" \
-u www-data \
--entrypoint wp \
"$WPCLI_DOCKER_IMAGE" "$@"
}
wordpress:init() {
mkdir -p "$WORDPRESS_CODE" || {
err "Couldn't create $WORDPRESS_CODE."
return 1
}
dir_is_empty "$WORDPRESS_CODE" || return 0
uid=$(docker_get_uid "$SERVICE_NAME" "www-data")
chown "$uid" "$WORDPRESS_CODE" || {
err "Couldn't change owner of $WORDPRESS_CODE to $uid."
return 1
}
cd "$WORDPRESS_CODE" || return 1
wp-cli:run core download
}