start-webdav-apache.sh 2.8 KB

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