start-webdav-ownCloud.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 ownCloud 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. # TODO find a way to determine the successful initialization inside the docker container
  40. echo "Waiting 30 seconds for ownCloud initialization ... "
  41. sleep 30
  42. # get mapped port on host for internal port 80 - output is IP:PORT - we need to extract the port with 'cut'
  43. port=`docker port $container 80 | cut -f 2 -d :`
  44. cat > $thisFolder/config.webdav.php <<DELIM
  45. <?php
  46. return array(
  47. 'run'=>true,
  48. 'host'=>'localhost:$port/owncloud/remote.php/webdav/',
  49. 'user'=>'test',
  50. 'password'=>'test',
  51. 'root'=>'',
  52. // wait delay in seconds after write operations
  53. // (only in tests)
  54. // set to higher value for lighttpd webdav
  55. 'wait'=> 0
  56. );
  57. DELIM
  58. echo "ownCloud container: $container"
  59. # 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)
  60. echo $container >> $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  61. if [ -n "$databaseContainer" ]; then
  62. echo "Database container: $databaseContainer"
  63. echo $databaseContainer >> $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  64. fi
  65. if [ -n "$DEBUG" ]; then
  66. cat $thisFolder/config.webdav.php
  67. cat $thisFolder/dockerContainerOwnCloud.$EXECUTOR_NUMBER.webdav
  68. fi