start-smb-silvershell.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.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 $container | grep IPAddress | cut -d '"' -f 4`
  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. if [ -n "$DEBUG" ]; then
  43. cat $thisFolder/config.smb.php
  44. cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
  45. fi
  46. # TODO find a way to determine the successful initialization inside the docker container
  47. echo "Waiting 5 seconds for smbd initialization ... "
  48. sleep 5