Last active
July 27, 2017 10:59
-
-
Save ricktap/4df5a564f189d0aaba357436aee38717 to your computer and use it in GitHub Desktop.
Docker test runner, taken from phusin/baseimage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
function abort() | |
{ | |
echo "$@" | |
exit 1 | |
} | |
function cleanup() | |
{ | |
echo " --> Stopping container" | |
docker stop $ID >/dev/null | |
docker rm $ID >/dev/null | |
} | |
PWD=`pwd` | |
echo " --> Starting insecure container" | |
ID=`docker run -d -v $PWD/test:/test $NAME:$VERSION /sbin/my_init --enable-insecure-key` | |
sleep 1 | |
echo " --> Obtaining IP" | |
IP=`docker inspect -f "{{ .NetworkSettings.IPAddress }}" "$ID"` | |
if [[ "$IP" = "" ]]; then | |
abort "Unable to obtain container IP" | |
fi | |
trap cleanup EXIT | |
echo " --> Enabling SSH in the container" | |
docker exec -t -i $ID /etc/my_init.d/00_regen_ssh_host_keys.sh -f | |
docker exec -t -i $ID rm /etc/service/sshd/down | |
docker exec -t -i $ID sv start /etc/service/sshd | |
sleep 1 | |
echo " --> Logging into container and running tests" | |
cp image/services/sshd/keys/insecure_key /tmp/insecure_key | |
chmod 600 /tmp/insecure_key | |
sleep 1 # Give container some more time to start up. | |
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /tmp/insecure_key root@$IP \ | |
/bin/bash /test/test.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment