-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxfs_install.sh
49 lines (42 loc) · 1.31 KB
/
xfs_install.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
#!/bin/bash
zone=$2
ig_nm=$3
cluster_nm=$2"/"$3
dt=`date +"%Y%m%d%H"`
FILE1=xfs_update_result_$dt.log
if [ -f $FILE1 ];
then
mv $FILE1 $FILE1.bak
fi
if [ "$1" == "" ]
then
echo "=============================================="
echo "Syntax> ./xfs_install.sh cloud_type zone(gce only) instance_group_name(gce only) "
echo "Example> ./xfs_install.sh aws "
echo "Example> ./xfs_install.sh gce asia-east1-b cassandra-example-qk21wfd"
echo "=============================================="
else
if [ "$1" == "aws" ]
then
set -f; IFS=$'\n'
acmd=(`kubectl get nodes | awk 'NR > 1 {print "kubectl describe nodes "$1" | grep Addresses " }'`)
for each in "${acmd[@]}"
do
result=$(eval "$each")
ip=$(echo $result | cut -d',' -f3)
ssh -i ~/.ssh/kube_aws_rsa admin@$ip 'bash -s' < ./xfs.sh >> ./xfs_update_result_$dt.log
echo "done!"
done
elif [ "$1" == "gce" ]
then
set -f; IFS=$'\n'
gcmd=(`gcloud compute instance-groups list-instances $cluster_nm | awk -v var=$zone 'NR > 1 {print "gcloud compute ssh "var"/"$1 " '\''bash -s'\'' < ./xfs.sh"}'`)
for each in "${gcmd[@]}"
do
eval "$each" >> ./xfs_update_result_$dt.log
echo "done!"
done
else
echo "you should input the cloud type (gce or aws)"
fi
fi