-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect.sh
executable file
·53 lines (43 loc) · 1.09 KB
/
connect.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
#!/bin/bash
STAGE=dev
domain() {
case $1 in
prod) echo auroradb.unee-t.com
;;
*) echo auroradb.$1.unee-t.com
;;
esac
}
show_help() {
cat << EOF
Usage: ${0##*/} [-p]
By default, deploy to dev environment on AWS account 812644853088
-p PRODUCTION 192458993663
-d DEMO 915001051872
EOF
}
while getopts "pd" opt
do
case $opt in
p)
echo "PRODUCTION" >&2
STAGE=prod
;;
d)
echo "DEMO" >&2
STAGE=demo
;;
*)
show_help >&2
exit 1
;;
esac
done
AWS_PROFILE=uneet-$STAGE
shift "$((OPTIND-1))" # Discard the options and sentinel --
echo Connecting to ${STAGE^^} $(domain $STAGE)
MYSQL_PASSWORD=$(aws --profile $AWS_PROFILE ssm get-parameters --names MYSQL_ROOT_PASSWORD --with-decryption --query Parameters[0].Value --output text)
MYSQL_USER=$(aws --profile $AWS_PROFILE ssm get-parameters --names MYSQL_USER --with-decryption --query Parameters[0].Value --output text)
echo $STAGE
echo mysql -s -h $(domain $STAGE) -P 3306 -u root --password=$MYSQL_PASSWORD bugzilla
mysql -s -h $(domain $STAGE) -P 3306 -u root --password=$MYSQL_PASSWORD bugzilla