-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws_update_pool_services.sh
61 lines (57 loc) · 1.67 KB
/
aws_update_pool_services.sh
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
#!/bin/bash
chmod 600 /home/cloudshell-user/functionland-pool.pem
# Define your regions
regions=(
us-east-2
us-west-1
af-south-1
ap-east-1
ap-south-1
ap-south-2
ap-northeast-2
ap-southeast-1
ap-southeast-2
ap-northeast-1
ca-central-1
eu-central-1
eu-west-1
eu-west-2
eu-south-1
eu-west-3
eu-north-1
eu-central-2
eu-south-2
me-central-1
il-central-1
sa-east-1
)
# Function to process region
process_region() {
local region=$1
echo "Processing region: $region"
# Retrieve the public IP of the instance
instance_ip=$(aws ec2 describe-instances --region $region --query 'Reservations[].Instances[?State.Name==`running`].PublicIpAddress' --output text)
if [ -n "$instance_ip" ]; then
echo "Instance IP: $instance_ip"
# Define and call zip_and_upload function via SSH
ssh_command="source ~/.bashrc; export PATH=\$PATH:/usr/local/go/bin; export PATH=\$PATH:/home/ubuntu/.cargo/bin; function update() {
cd /home/ubuntu/automatic-poolnode-creation-script
sudo git pull
cd ..
sleep 1
bash /home/ubuntu/automatic-poolnode-creation-script/update_pools.sh
}
update"
# SSH Command (This part needs to be run from a system where SSH is possible)
ssh -o StrictHostKeyChecking=no -i /home/cloudshell-user/functionland-pool.pem ubuntu@$instance_ip "$ssh_command"
else
echo "Failed to retrieve the instance IP address."
fi
}
# Initial loop through each region
for region in "${regions[@]}"; do
process_region "$region"
sleep 10
done
# Write instance details to file
echo "Finished"