1
0

start-webdav-ownCloud.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env bash
  2. #
  3. #!/bin/bash
  4. #
  5. # SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  6. # SPDX-FileCopyrightText: 2014-2015 ownCloud, Inc.
  7. # SPDX-License-Identifier: AGPL-3.0-only
  8. #
  9. # This script start a docker container to test the files_external tests
  10. # against. It will also change the files_external config to use the docker
  11. # container as testing environment. This is reverted in the stop step.
  12. #
  13. # If the environment variable RUN_DOCKER_MYSQL is set the Nextcloud will
  14. # be set up using MySQL instead of SQLite.
  15. #
  16. # Set environment variable DEBUG to print config file
  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 morrisjobke/owncloud docker image"
  24. docker pull morrisjobke/owncloud
  25. # retrieve current folder to place the config in the parent folder
  26. thisFolder=`echo $0 | sed 's#env/start-webdav-ownCloud\.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 -e ADMINLOGIN=test -e ADMINPWD=test morrisjobke/owncloud`
  40. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  41. echo -n "Waiting for Nextcloud initialization"
  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/owncloud/remote.php/webdav/',
  53. 'user'=>'test',
  54. 'password'=>'test',
  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/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  65. if [ -n "$databaseContainer" ]; then
  66. echo "Database container: $databaseContainer"
  67. echo $databaseContainer >> $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  68. fi
  69. if [ -n "$DEBUG" ]; then
  70. cat $thisFolder/config.webdav.php
  71. cat $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  72. fi