2015-06-02 13:35:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# ownCloud
|
|
|
|
#
|
|
|
|
# This script start a docker container to test the files_external tests
|
|
|
|
# against. It will also change the files_external config to use the docker
|
|
|
|
# container as testing environment. This is reverted in the stop step.
|
|
|
|
#
|
2017-04-12 04:16:27 +00:00
|
|
|
# If the environment variable RUN_DOCKER_MYSQL is set the Nextcloud will
|
2015-06-02 13:35:45 +00:00
|
|
|
# be set up using MySQL instead of SQLite.
|
|
|
|
#
|
|
|
|
# Set environment variable DEBUG to print config file
|
|
|
|
#
|
|
|
|
# @author Morris Jobke
|
|
|
|
# @copyright 2014 Morris Jobke <hey@morrisjobke.de>
|
2016-05-03 10:19:16 +00:00
|
|
|
# @copyright 2016 Vincent Petry <pvince81@owncloud.com>
|
2015-06-02 13:35:45 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
if ! command -v docker >/dev/null 2>&1; then
|
|
|
|
echo "No docker executable found - skipped docker setup"
|
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Docker executable found - setup docker"
|
|
|
|
|
|
|
|
echo "Fetch recent morrisjobke/webdav docker image"
|
|
|
|
docker pull morrisjobke/webdav
|
|
|
|
|
|
|
|
# retrieve current folder to place the config in the parent folder
|
|
|
|
thisFolder=`echo $0 | sed 's#env/start-webdav-apache\.sh##'`
|
|
|
|
|
|
|
|
if [ -z "$thisFolder" ]; then
|
|
|
|
thisFolder="."
|
|
|
|
fi;
|
|
|
|
|
2016-05-03 10:19:16 +00:00
|
|
|
if [ -n "$RUN_DOCKER_MYSQL" ]; then
|
|
|
|
echo "Fetch recent mysql docker image"
|
|
|
|
docker pull mysql
|
2015-06-02 13:35:45 +00:00
|
|
|
|
2016-05-03 10:19:16 +00:00
|
|
|
echo "Setup MySQL ..."
|
|
|
|
# user/password will be read by ENV variables in owncloud container (they are generated by docker)
|
|
|
|
databaseContainer=`docker run -e MYSQL_ROOT_PASSWORD=mysupersecretpassword -d mysql`
|
|
|
|
containerName=`docker inspect $databaseContainer | grep Name | grep _ | cut -d \" -f 4 | cut -d / -f 2`
|
2015-06-02 13:35:45 +00:00
|
|
|
|
2016-05-03 10:19:16 +00:00
|
|
|
parameter="--link $containerName:db"
|
|
|
|
fi
|
|
|
|
|
|
|
|
container=`docker run -P $parameter -d -e USERNAME=test -e PASSWORD=test morrisjobke/webdav`
|
|
|
|
host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
|
|
|
|
|
|
|
|
echo -n "Waiting for Apache initialization on ${host}:${port}"
|
|
|
|
if ! "$thisFolder"/env/wait-for-connection ${host} 80 60; then
|
|
|
|
echo "[ERROR] Waited 60 seconds, no response" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# wait at least 5 more seconds - sometimes the webserver still needs some additional time
|
|
|
|
sleep 5
|
2015-06-02 13:35:45 +00:00
|
|
|
|
|
|
|
cat > $thisFolder/config.webdav.php <<DELIM
|
|
|
|
<?php
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'run'=>true,
|
2016-05-03 10:19:16 +00:00
|
|
|
'host'=>'${host}:80/webdav/',
|
2015-06-02 13:35:45 +00:00
|
|
|
'user'=>'test',
|
|
|
|
'password'=>'test',
|
|
|
|
'root'=>'',
|
|
|
|
// wait delay in seconds after write operations
|
|
|
|
// (only in tests)
|
|
|
|
// set to higher value for lighttpd webdav
|
|
|
|
'wait'=> 0
|
|
|
|
);
|
|
|
|
|
|
|
|
DELIM
|
|
|
|
|
2017-04-12 04:16:27 +00:00
|
|
|
echo "Nextcloud container: $container"
|
2015-06-02 13:35:45 +00:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
echo $container >> $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav
|
|
|
|
|
|
|
|
if [ -n "$databaseContainer" ]; then
|
|
|
|
echo "Database container: $databaseContainer"
|
|
|
|
echo $databaseContainer >> $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$DEBUG" ]; then
|
|
|
|
cat $thisFolder/config.webdav.php
|
|
|
|
cat $thisFolder/dockerContainerWebdav.$EXECUTOR_NUMBER.webdav
|
|
|
|
fi
|