start-webdav-ownCloud.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/env 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. #
  17. if ! command -v docker >/dev/null 2>&1; then
  18. echo "No docker executable found - skipped docker setup"
  19. exit 0;
  20. fi
  21. echo "Docker executable found - setup docker"
  22. echo "Fetch recent morrisjobke/owncloud docker image"
  23. docker pull morrisjobke/owncloud
  24. # retrieve current folder to place the config in the parent folder
  25. thisFolder=`echo $0 | sed 's#env/start-webdav-ownCloud\.sh##'`
  26. if [ -z "$thisFolder" ]; then
  27. thisFolder="."
  28. fi;
  29. if [ -n "$RUN_DOCKER_MYSQL" ]; then
  30. echo "Fetch recent mysql docker image"
  31. docker pull mysql
  32. echo "Setup MySQL ..."
  33. # user/password will be read by ENV variables in owncloud container (they are generated by docker)
  34. databaseContainer=`docker run -e MYSQL_ROOT_PASSWORD=mysupersecretpassword -d mysql`
  35. containerName=`docker inspect $databaseContainer | grep Name | grep _ | cut -d \" -f 4 | cut -d / -f 2`
  36. parameter="--link $containerName:db"
  37. fi
  38. container=`docker run -P $parameter -d -e ADMINLOGIN=test -e ADMINPWD=test morrisjobke/owncloud`
  39. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  40. echo -n "Waiting for Nextcloud initialization"
  41. if ! "$thisFolder"/env/wait-for-connection ${host} 80 60; then
  42. echo "[ERROR] Waited 60 seconds, no response" >&2
  43. exit 1
  44. fi
  45. # wait at least 5 more seconds - sometimes the webserver still needs some additional time
  46. sleep 5
  47. cat > $thisFolder/config.webdav.php <<DELIM
  48. <?php
  49. return array(
  50. 'run'=>true,
  51. 'host'=>'${host}:80/owncloud/remote.php/webdav/',
  52. 'user'=>'test',
  53. 'password'=>'test',
  54. 'root'=>'',
  55. // wait delay in seconds after write operations
  56. // (only in tests)
  57. // set to higher value for lighttpd webdav
  58. 'wait'=> 0
  59. );
  60. DELIM
  61. echo "Nextcloud container: $container"
  62. # 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)
  63. echo $container >> $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  64. if [ -n "$databaseContainer" ]; then
  65. echo "Database container: $databaseContainer"
  66. echo $databaseContainer >> $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  67. fi
  68. if [ -n "$DEBUG" ]; then
  69. cat $thisFolder/config.webdav.php
  70. cat $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  71. fi