real-run.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -Eeo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. image="$1"
  5. # Build a client image with cgi-fcgi for testing
  6. clientImage='librarytest/nextcloud-fpm-run:fcgi-client'
  7. docker build -t "$clientImage" - > /dev/null <<'EOF'
  8. FROM debian:buster-slim
  9. RUN set -x && apt-get update && apt-get install -y --no-install-recommends libfcgi-bin && rm -rf /var/lib/apt/lists/*
  10. ENTRYPOINT ["cgi-fcgi"]
  11. EOF
  12. # Create an instance of the container-under-test
  13. cid="$(docker run -d "$image")"
  14. trap "docker rm -vf $cid > /dev/null" EXIT
  15. #trap "docker logs $cid" ERR
  16. fcgi-request() {
  17. local method="$1"
  18. local url="$2"
  19. local queryString=
  20. if [[ "$url" == *\?* ]]; then
  21. queryString="${url#*\?}"
  22. url="${url%%\?*}"
  23. fi
  24. docker run --rm -i \
  25. --link "$cid":fpm \
  26. -e REQUEST_METHOD="$method" \
  27. -e SCRIPT_NAME="$url" \
  28. -e SCRIPT_FILENAME=/var/www/html/"${url#/}" \
  29. -e QUERY_STRING="$queryString" \
  30. "$clientImage" \
  31. -bind -connect fpm:9000
  32. }
  33. # Make sure that PHP-FPM is listening and ready
  34. . "$dir/../../retry.sh" --tries 30 'fcgi-request GET /index.php' > /dev/null 2>&1
  35. # Check that we can request / and that it contains the pattern "Install" somewhere
  36. # <input type="submit" class="primary" value="Install" data-finishing="Installing …">
  37. fcgi-request GET '/index.php' | grep -i '"Install"' > /dev/null
  38. # (https://github.com/nextcloud/server/blob/68b2463107774bed28ee9e77b44e7395d49dacee/core/templates/installation.php#L164)