-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshared.sh
37 lines (34 loc) · 840 Bytes
/
shared.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
#!/bin/bash
read_terraform_a_variable() {
terraform output -raw -state $this_dir/terraform-a/terraform.tfstate $1
}
read_terraform_b_variable() {
terraform output -raw -state $this_dir/terraform-b/terraform.tfstate $1
}
ssh_it() {
local host=$1
if ! ssh_it_out_and_err=$(ssh -o "StrictHostKeyChecking=no" root@$host 2>&1); then
cat <<< "$ssh_it_out_and_err"
return 1
fi
}
_WAIT_TIME=600
wait_for_command() {
# command="$1"
let "begin = $(date +'%s')"
local elapsed=0
local first_time=true
while (( $_WAIT_TIME > $elapsed )); do
if eval "$1"; then
[ $first_time = false ] && echo
return 0
fi
[ $first_time = true ] && echo -n retry for $_WAIT_TIME seconds: ''
first_time=false
sleep 10
let "elapsed = $(date +%s) - $begin"
echo -n $elapsed ''
done
echo
return 1
}