forked from yabebalFantaye/aws_bash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiple_instances.sh
executable file
·50 lines (38 loc) · 1.41 KB
/
multiple_instances.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
curdir=`pwd`
#--------------------------------------------------------#
###--------Define necessary environment variables-----##
##------------------------------------------------------#
if [ $# -lt 2 ]; then
echo "Usage: bash multiple_instance.sh <path to params file> <action type 'create' or 'iplink'> [[key=value]]"
exit 0
fi
paramsfile=$1; shift
action=$1; shift
echo "Using paramsfile=$paramsfile for action=$action .."
#--- parse named arguments key=value
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
KEY_LENGTH=${#KEY}
VALUE="${ARGUMENT:$KEY_LENGTH+1}"
export "$KEY"="$VALUE"
done
istart=${istart:-1}
iend=${iend:-5}
echo "number of instances to create: $istart to $iend"
ec2script=${ec2script:-"ec2_compute.sh"}
ipscript=${ipscript:-"postup/update_r53_record.sh"}
#--------------------------------------------------------#
###--------execute the scripts with input arguments------#
##-------------------------------------------------------#
for ((ig=$istart; ig<=$iend; ig++)); do
if [ "$action" == "create" ]; then
echo "******creating instances for group=$ig********"
group=$ig bash $ec2script $paramsfile
elif [ "$action" == "iplink" ]; then
echo "*********updating r53 record with IP for group=$ig******"
group=$ig bash $ipscript $paramsfile
else
echo "*****unknown operation requested 1st argument=$1*****"
fi
done