start-smb-silvershell.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 silvershell/samba docker image"
  20. docker pull silvershell/samba
  21. # retrieve current folder to place the config in the parent folder
  22. thisFolder=`echo $0 | sed 's#env/start-smb-silvershell\.sh##'`
  23. if [ -z "$thisFolder" ]; then
  24. thisFolder="."
  25. fi;
  26. container=`docker run -d -e SMB_USER=test -e SMB_PWD=test silvershell/samba`
  27. host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
  28. cat > $thisFolder/config.smb.php <<DELIM
  29. <?php
  30. return array(
  31. 'run'=>true,
  32. 'host'=>'$host',
  33. 'user'=>'test',
  34. 'password'=>'test',
  35. 'root'=>'',
  36. 'share'=>'public',
  37. );
  38. DELIM
  39. echo "samba container: $container"
  40. # 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)
  41. echo $container >> $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
  42. echo -n "Waiting for samba initialization"
  43. if ! "$thisFolder"/env/wait-for-connection ${host} 445 60; then
  44. echo "[ERROR] Waited 60 seconds, no response" >&2
  45. exit 1
  46. fi
  47. sleep 1
  48. if [ -n "$DEBUG" ]; then
  49. cat $thisFolder/config.smb.php
  50. cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
  51. fi