-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultilaunch.sh
More file actions
executable file
·65 lines (52 loc) · 2.02 KB
/
multilaunch.sh
File metadata and controls
executable file
·65 lines (52 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# some default values
PURPOSETAG=other
NUM_HOSTS=1
EXPIREON=2023-12-31
source config.sh
export AWS_PAGER=""
echo "Spinning up $NUM_HOSTS AWS instance(s) for SimRunner"
aws ec2 run-instances --image-id $IMAGE --count $NUM_HOSTS --instance-type $INSTTYPE --key-name $KEYNAME \
--security-group-ids $SECGROUP --block-device-mappings '[{"DeviceName": "/dev/xvda", "Ebs": {"DeleteOnTermination": true, "VolumeSize": 16, "VolumeType": "gp3"}}]' \
--tag-specification "ResourceType=instance,Tags=[{Key=Name, Value=\"$NAMETAG\"},{Key=owner, Value=\"$OWNERTAG\"}, {Key=expire-on,Value=\"$EXPIREON\"}, {Key=purpose,Value=\"$PURPOSETAG\"}]"
#sleep 20
sleep 10
res=$(aws ec2 describe-instances --filters "Name=tag:owner,Values=$OWNERTAG" "Name=tag:Name,Values=$NAMETAG" "Name=instance-state-name,Values=running")
for inst in $(echo $res | jq -c -r ".Reservations[].Instances[]");
do
INSTANCEID=$(echo $inst | jq -r '.InstanceId')
PUBDNS=$(echo $inst | jq -r '.PublicDnsName')
PUBIP=$(echo $inst | jq -r '.PublicIpAddress')
until test $PUBDNS != "null"
do
sleep 1
printf "."
inst=$(aws ec2 describe-instances --instance-ids $INSTANCEID | jq -r ".Reservations[].Instances[0]")
PUBDNS=$(echo $inst | jq -r '.PublicDnsName')
PUBIP=$(echo $inst | jq -r '.PublicIpAddress')
done
echo "Public DNS is $PUBDNS; waiting for ssh"
nc -z $PUBDNS 22
until test $? -eq 0
do
sleep 1
printf "."
nc -z $PUBDNS 22
done
ssh -i $KEYPATH -oStrictHostKeyChecking=no ec2-user@$PUBDNS <<EOF
sudo dnf install -y docker
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker ec2-user
newgrp docker
EOF
done
res=$(aws ec2 describe-instances --filters "Name=tag:owner,Values=$OWNERTAG" "Name=tag:Name,Values=$NAMETAG" "Name=instance-state-name,Values=running")
echo "Public DNS names:"
echo $res | jq -r ".Reservations[].Instances[].PublicDnsName"
echo ""
echo "Public IP addresses:"
echo $res | jq -r ".Reservations[].Instances[].PublicIpAddress"
if [ -n "$1" ]; then
./copy_workload.sh $1
fi
./atlas_add_ips.sh