mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
44 lines
1.5 KiB
Bash
Executable File
44 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
KEYNAME="$1"
|
|
indent() { sed "s/^/ /"; }
|
|
echo "-----> Booting EC2 instance..."
|
|
start=$(ec2-run-instances -k $1 ami-f3d1bb9a 2>/dev/null)
|
|
if [[ $? > 0 ]]; then
|
|
echo "$start"
|
|
exit
|
|
fi
|
|
INSTANCE=$(echo "$start" | awk '/^INSTANCE/ {print $2}')
|
|
terminate() {
|
|
echo "-----> Terminating $INSTANCE..."
|
|
ec2-terminate-instances $INSTANCE &>/dev/null && echo " Shutting down"
|
|
}
|
|
[[ $NOCLEANUP ]] || trap "terminate" EXIT
|
|
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..."
|
|
while [[ ! $(echo | nc $PUBLIC_IP 22) ]]; do
|
|
sleep 5
|
|
echo " Waiting..."
|
|
done
|
|
echo "-----> Connecting and running boostrap script..."
|
|
cat ../bootstrap.sh | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "HOSTNAME=$PUBLIC_IP sudo bash" 2>&1 | indent
|
|
echo "-----> Installing SSH public keys..."
|
|
ssh-add -L | ssh -o "StrictHostKeyChecking=no" ubuntu@$PUBLIC_IP "sudo gitreceive upload-key test" > /dev/null
|
|
ssh-add -L | 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
|
|
done |