Files
dokku/tests/run_ec2

46 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -eo pipefail
2013-06-30 08:29:40 -05:00
KEYNAME="$1"
indent() { sed "s/^/ /"; }
2013-06-10 15:19:48 -07:00
echo "-----> Booting EC2 instance..."
start=$(ec2-run-instances -k $1 ami-f3d1bb9a 2>&1 )
2014-12-13 18:56:31 -08:00
if [[ $? -gt 0 ]]; then
echo "$start" | indent
exit 3
fi
INSTANCE=$(echo "$start" | awk '/^INSTANCE/ {print $2}')
2013-06-10 15:19:48 -07:00
terminate() {
echo "-----> Terminating $INSTANCE..."
ec2-terminate-instances $INSTANCE &>/dev/null && echo " Shutting down"
}
[[ $NOCLEANUP ]] || trap "terminate" EXIT
2013-06-10 15:19:48 -07:00
sleep 30
status=""
while [[ "$status" != "running" ]]; do
info=$(ec2-describe-instances 2>/dev/null | grep $INSTANCE)
status=$(echo "$info" | cut -f 6 | grep run)
echo " Waiting..."
sleep 5
if [[ $status == "running" ]]; then
echo "-----> $INSTANCE has succesfully booted!"
break
fi
done
PUBLIC_IP=$(echo "$info" | awk '{print $14}')
echo "-----> Waiting for SSH at $PUBLIC_IP..."
2013-06-23 01:07:21 -07:00
while [[ ! $(echo | nc $PUBLIC_IP 22) ]]; do
sleep 5
echo " Waiting..."
done
set -e
2013-07-02 21:53:54 +02:00
echo "-----> Connecting and running bootstrap script..."
2014-12-13 18:56:31 -08:00
ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=\$PUBLIC_IP sudo bash" < ../bootstrap.sh 2>&1 | indent
echo "-----> Installing SSH public keys..."
2014-12-13 18:56:31 -08:00
PUBLIC_KEY=$(< ~/.ssh/id_rsa.pub)
echo $PUBLIC_KEY | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "sudo sshcommand acl-add dokku test" > /dev/null
for app_path in apps/*; do
app=$(basename $app_path)
echo "-----> Running test deploy of $app..."
./test_deploy $app_path $PUBLIC_IP
2013-07-02 21:53:54 +02:00
done