-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsshaws.bash
70 lines (57 loc) · 1.66 KB
/
sshaws.bash
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#====================================================================
function sshawsUsage() {
echo
echo " $0 -c <cmd> [ OPTIONAL: -i <inst> ]"
echo " cmd: command [ <start|stop|connect|describe|status> | DEFAULT: connect ]"
echo " inst: instance [ <dev|prod> | DEFAULT: dev ]"
echo
return
}
#====================================================================
#====================================================================
function sshaws() {
# empty input options array to purge stale args from prev sessions
OPTIND=""
inst=""
cmd=""
av_inst=""
av_cmd=""
pv_inst="dev"
pv_cmd="connect"
while getopts "i:c:h" opt
do
case $opt in
i ) av_inst=$OPTARG;;
c ) av_cmd=$OPTARG;
if [[ $av_cmd == "stat" || $av_cmd == "status" ]]; then
av_cmd="describe"
elif [[ $av_cmd == "conn" ]]; then
av_cmd="connect"
fi;;
h) sshawsUsage;
return;;
* ) sshawsUsage;
return;;
esac
done
inst=${av_inst:-$pv_inst}
cmd=${av_cmd:-$pv_cmd}
# confirm if instance stoppage
if [ $cmd == "stop" ]; then
read -p "Are you sure? Confirm $cmd for $inst instance (Y/y): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborting..."
return
fi
fi
case $cmd in
"connect" ) pv_cmd_v="Connecting to ";;
"start" ) pv_cmd_v="Starting ";;
"stop" ) pv_cmd_v="Stopping ";;
* ) pv_cmd_v="Checking status for ";;
esac
echo $pv_cmd_v instance: $inst ...
perl -w /path/to/awsConn.pl --argv inst=$inst --argv cmd=$cmd
}
#====================================================================