start-ftp-morrisjobke.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env bash
  2. #
  3. # SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
  4. # SPDX-License-Identifier: AGPL-3.0-only
  5. #
  6. # This script start a docker container to test the files_external tests
  7. # against. It will also change the files_external config to use the docker
  8. # container as testing environment. This is reverted in the stop step.W
  9. #
  10. # Set environment variable DEBUG to print config file
  11. #
  12. if ! command -v docker >/dev/null 2>&1; then
  13. echo "No docker executable found - skipped docker setup"
  14. exit 0;
  15. fi
  16. echo "Docker executable found - setup docker"
  17. echo "Fetch recent morrisjobke/docker-proftpd docker image"
  18. docker pull morrisjobke/docker-proftpd
  19. # retrieve current folder to place the config in the parent folder
  20. thisFolder=`echo $0 | sed 's#env/start-ftp-morrisjobke\.sh##'`
  21. if [ -z "$thisFolder" ]; then
  22. thisFolder="."
  23. fi;
  24. user=test
  25. password=12345
  26. container=`docker run -d -e USERNAME=$user -e PASSWORD=$password morrisjobke/docker-proftpd`
  27. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  28. cat > $thisFolder/config.ftp.php <<DELIM
  29. <?php
  30. return array(
  31. 'run'=>true,
  32. 'host'=>'$host',
  33. 'user'=>'$user',
  34. 'password'=>'$password',
  35. 'root'=>'',
  36. );
  37. DELIM
  38. echo "ftp container: $container"
  39. # 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)
  40. echo $container >> $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
  41. echo -n "Waiting for ftp initialization"
  42. if ! "$thisFolder"/env/wait-for-connection ${host} 21 60; then
  43. echo "[ERROR] Waited 60 seconds, no response" >&2
  44. exit 1
  45. fi
  46. sleep 1
  47. if [ -n "$DEBUG" ]; then
  48. cat $thisFolder/config.ftp.php
  49. cat $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
  50. fi