1
0

start-webdav-apache.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. #
  3. # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
  4. # SPDX-FileCopyrightText: 2015 ownCloud, Inc.
  5. # SPDX-License-Identifier: AGPL-3.0-only
  6. #
  7. # This script start a docker container to test the files_external tests
  8. # against. It will also change the files_external config to use the docker
  9. # container as testing environment. This is reverted in the stop step.
  10. #
  11. # If the environment variable RUN_DOCKER_MYSQL is set the Nextcloud will
  12. # be set up using MySQL instead of SQLite.
  13. #
  14. # Set environment variable DEBUG to print config file
  15. #
  16. if ! command -v docker >/dev/null 2>&1; then
  17. echo "No docker executable found - skipped docker setup"
  18. exit 0;
  19. fi
  20. echo "Docker executable found - setup docker"
  21. echo "Fetch recent webdav docker image"
  22. docker pull ghcr.io/nextcloud/continuous-integration-webdav-apache:latest
  23. # retrieve current folder to place the config in the parent folder
  24. thisFolder=`echo $0 | sed 's#env/start-webdav-apache\.sh##'`
  25. if [ -z "$thisFolder" ]; then
  26. thisFolder="."
  27. fi;
  28. if [ -n "$RUN_DOCKER_MYSQL" ]; then
  29. echo "Fetch recent mysql docker image"
  30. docker pull mysql
  31. echo "Setup MySQL ..."
  32. # user/password will be read by ENV variables in owncloud container (they are generated by docker)
  33. databaseContainer=`docker run -e MYSQL_ROOT_PASSWORD=mysupersecretpassword -d mysql`
  34. containerName=`docker inspect $databaseContainer | grep Name | grep _ | cut -d \" -f 4 | cut -d / -f 2`
  35. parameter="--link $containerName:db"
  36. fi
  37. container=`docker run -P $parameter -d --rm ghcr.io/nextcloud/continuous-integration-webdav-apache:latest`
  38. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  39. echo -n "Waiting for Apache initialization on ${host}:${port}"
  40. if ! "$thisFolder"/env/wait-for-connection ${host} 80 60; then
  41. echo "[ERROR] Waited 60 seconds, no response" >&2
  42. exit 1
  43. fi
  44. # wait at least 5 more seconds - sometimes the webserver still needs some additional time
  45. sleep 5
  46. cat > $thisFolder/config.webdav.php <<DELIM
  47. <?php
  48. return array(
  49. 'run'=>true,
  50. 'host'=>'${host}:80/webdav/',
  51. 'user'=>'test',
  52. 'password'=>'pass',
  53. 'root'=>'',
  54. // wait delay in seconds after write operations
  55. // (only in tests)
  56. // set to higher value for lighttpd webdav
  57. 'wait'=> 0
  58. );
  59. DELIM
  60. echo "Nextcloud container: $container"
  61. # put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host)
  62. echo $container >> $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav
  63. if [ -n "$databaseContainer" ]; then
  64. echo "Database container: $databaseContainer"
  65. echo $databaseContainer >> $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav
  66. fi
  67. if [ -n "$DEBUG" ]; then
  68. cat $thisFolder/config.webdav.php
  69. cat $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav
  70. fi