-
Notifications
You must be signed in to change notification settings - Fork 36
/
change-region.sh
executable file
·42 lines (37 loc) · 1.55 KB
/
change-region.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
#!/usr/bin/env bash
##############################################################
### _ _ _ ###
### __ _ __| |___ _ _ __| |_ _(_)__ _ ###
### / _` / _| / _ \ || / _` | '_| / _` | ###
### \__, \__|_\___/\_,_\__,_|_| |_\__, | ###
### |___/ |___/ ###
### ###
### change-region.sh ###
### ###
### invoking this script will recreate your instance ###
### group in a new GCP region. note that cross-region ###
### egress costs apply; it may be easier to just delete ###
### everything and start again! ###
### ###
##############################################################
# bash "what directory am i" dance
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# shellcheck source=./globals.sh
source "$DIR/globals.sh"
##############################################################
init_gcloudrig;
OLD_REGION="$REGION"
echo
echo "Current region: $REGION"
gcloudrig_select_region
if [ "$REGION" != "$OLD_REGION" ] ; then
init_common
gcloudrig_delete_instance_group
gcloudrig_create_instance_group
fi