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

  1. # -*- mode: shell-script -*-
  2. WORDPRESS_DIR="/opt/apps/wordpress"
  3. WORDPRESS_CODE="$SERVICE_DATASTORE$WORDPRESS_DIR"
  4. # WORDPRESS_RELEASE=6.6.2
  5. # WORDPRESS_URL=https://github.com/WordPress/WordPress/archive/refs/tags/"${WORDPRESS_RELEASE}".tar.gz
  6. WPCLI_RELEASE=2.11.0
  7. WPCLI_URL=https://github.com/wp-cli/wp-cli/releases/download/v${WPCLI_RELEASE}/wp-cli-${WPCLI_RELEASE}.phar
  8. WPCLI_DOCKER_IMAGE="wpcli:$WPCLI_RELEASE"
  9. wp-cli:run() {
  10. if ! docker_has_image "$WPCLI_DOCKER_IMAGE"; then
  11. echo '
  12. curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&
  13. chmod +x wp-cli.phar &&
  14. mv wp-cli.phar /usr/local/bin/wp
  15. ' | DEBUG=1 dupd -t "$WPCLI_DOCKER_IMAGE" "$DOCKER_BASE_IMAGE" || {
  16. err "Couldn't build $WPCLI_DOCKER_IMAGE."
  17. return 1
  18. }
  19. info "Successfully built $WPCLI_DOCKER_IMAGE."
  20. fi
  21. docker run --rm \
  22. -v "$WORDPRESS_CODE:$WORDPRESS_DIR" \
  23. -w "$WORDPRESS_DIR" \
  24. -u www-data \
  25. --entrypoint wp \
  26. "$WPCLI_DOCKER_IMAGE" "$@"
  27. }
  28. wordpress:init() {
  29. mkdir -p "$WORDPRESS_CODE" || {
  30. err "Couldn't create $WORDPRESS_CODE."
  31. return 1
  32. }
  33. dir_is_empty "$WORDPRESS_CODE" || return 0
  34. uid=$(docker_get_uid "$SERVICE_NAME" "www-data")
  35. chown "$uid" "$WORDPRESS_CODE" || {
  36. err "Couldn't change owner of $WORDPRESS_CODE to $uid."
  37. return 1
  38. }
  39. cd "$WORDPRESS_CODE" || return 1
  40. wp-cli:run core download
  41. }