start-sftp-atmoz.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 atmoz/sftp docker image"
  20. docker pull atmoz/sftp
  21. # retrieve current folder to place the config in the parent folder
  22. thisFolder=`echo $0 | sed 's#env/start-sftp-atmoz\.sh##'`
  23. if [ -z "$thisFolder" ]; then
  24. thisFolder="."
  25. fi;
  26. user=test
  27. password=12345
  28. container=`docker run -d atmoz/sftp $user:$password:1001`
  29. host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4`
  30. cat > $thisFolder/config.sftp.php <<DELIM
  31. <?php
  32. return array(
  33. 'run'=>true,
  34. 'host'=>'$host',
  35. 'user'=>'$user',
  36. 'password'=>'$password',
  37. 'root'=>'upload',
  38. );
  39. DELIM
  40. echo "sftp 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/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
  43. if [ -n "$DEBUG" ]; then
  44. cat $thisFolder/config.sftp.php
  45. cat $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
  46. fi
  47. # TODO find a way to determine the successful initialization inside the docker container
  48. echo "Waiting 5 seconds for sftp initialization ... "
  49. sleep 5
  50. # create folder "upload" with correct permissions
  51. docker exec $container bash -c "mkdir /home/$user/upload && chown $user:users /home/$user/upload"