start-ftp-morrisjobke.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.W
  8. #
  9. # Set environment variable DEBUG to print config file
  10. #
  11. # @author Morris Jobke
  12. # @copyright 2015 Morris Jobke <hey@morrisjobke.de>
  13. #
  14. if ! command -v docker >/dev/null 2>&1; then
  15. echo "No docker executable found - skipped docker setup"
  16. exit 0;
  17. fi
  18. echo "Docker executable found - setup docker"
  19. echo "Fetch recent morrisjobke/docker-proftpd docker image"
  20. docker pull morrisjobke/docker-proftpd
  21. # retrieve current folder to place the config in the parent folder
  22. thisFolder=`echo $0 | sed 's#env/start-ftp-morrisjobke\.sh##'`
  23. if [ -z "$thisFolder" ]; then
  24. thisFolder="."
  25. fi;
  26. user=test
  27. password=12345
  28. container=`docker run -d -e USERNAME=$user -e PASSWORD=$password morrisjobke/docker-proftpd`
  29. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  30. cat > $thisFolder/config.ftp.php <<DELIM
  31. <?php
  32. return array(
  33. 'run'=>true,
  34. 'host'=>'$host',
  35. 'user'=>'$user',
  36. 'password'=>'$password',
  37. 'root'=>'',
  38. );
  39. DELIM
  40. echo "ftp container: $container"
  41. # 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)
  42. echo $container >> $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
  43. echo -n "Waiting for ftp initialization"
  44. if ! "$thisFolder"/env/wait-for-connection ${host} 21 60; then
  45. echo "[ERROR] Waited 60 seconds, no response" >&2
  46. exit 1
  47. fi
  48. sleep 1
  49. if [ -n "$DEBUG" ]; then
  50. cat $thisFolder/config.ftp.php
  51. cat $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
  52. fi