Skip to content

Commit a1ca80a

Browse files
committed
Fix Minor Code Adjustments
1 parent cd98d49 commit a1ca80a

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

aws-ssh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
#
1010

1111
scriptname="aws-ssh"
12-
scriptbuildnum="0.9.2"
13-
scriptbuilddate="2017-03-13"
12+
scriptbuildnum="0.9.3"
13+
scriptbuilddate="2017-03-20"
1414

1515
############################################################
1616
### PRE-EXECUTION
1717

1818
# TURN ON COLOR IF POSSIBLE, SET THEME
1919
if test -t 1; then # check if stdout is a terminal
2020
ncolors=$(tput colors) # see if it supports colors
21-
if test -n "$ncolors" && test $ncolors -ge 8; then
21+
if test -n "$ncolors" && test "$ncolors" -ge 8; then
2222
# Set Colors
2323
bold="$(tput bold)"
2424
underline="$(tput smul)"
@@ -59,8 +59,8 @@ display_help_text() {
5959
echo -e "${CLRtitle}USAGE: ${CLRnormal}${scriptname} ${CLRtitle2}instance-name [-n] [-u login-user] [-d] [-V] [-h]${CLRnormal}\n"
6060
echo -e "${CLRtitle}\tOPTIONS:${CLRnormal}"
6161
echo -e "${CLRtitle2} instance-name\t${CLRnormal}: (REQUIRED) name tag assigned to the EC2 instance"
62-
echo -e "${CLRtitle2} -n\t${CLRnormal}: Don't use PEM key while connecting ${CLRsuccess}*${CLRnormal}"
6362
echo -e "${CLRtitle2} -u login-user\t${CLRnormal}: (optional) manually specify a login-username for ssh"
63+
echo -e "${CLRtitle2} -n\t${CLRnormal}: Don't use PEM key while connecting ${CLRsuccess}*${CLRnormal}"
6464
echo -e "${CLRtitle2} -d\t${CLRnormal}: debug mode"
6565
echo -e "${CLRtitle2} -V\t${CLRnormal}: display version info"
6666
echo -e "${CLRtitle2} -h\t${CLRnormal}: display help info"
@@ -74,7 +74,7 @@ DetermineLoginUser() {
7474
# Calculate the LoginUsername by determining the image running on the instance
7575

7676
# Get AMI-ID for Instance Specified by Name
77-
ImageAMI=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${InstanceName}" --query 'Reservations[*].Instances[].[ImageId]' --output text)
77+
ImageAMI=($(aws ec2 describe-instances --filters "Name=tag:Name,Values=${InstanceName}" --query 'Reservations[*].Instances[].[ImageId]' --output text))
7878
# Get AMI description for AMI-ID which contains image type info
7979
ImageDescription=$(aws ec2 describe-images --image-ids "${ImageAMI}" --query 'Images[*].{Name:Name}' --output text)
8080
case $ImageDescription in
@@ -124,7 +124,7 @@ if [ -z "$InstanceAddy" ]; then
124124
exit 1
125125
fi
126126

127-
if [ -z $UserLoginName ]; then
127+
if [ -z "$UserLoginName" ]; then
128128
DetermineLoginUser
129129
else
130130
[[ "$debugmode" ]] && echo -e "LoginUser set by user: ${CLRtitle}$UserLoginName${CLRnormal}\n"
@@ -134,7 +134,7 @@ fi
134134
if [[ "$nopem" ]]; then
135135
[[ ! "$debugmode" ]] && echo -e "${CLRheading2}No PEM mode${CLRnormal} - connecting without PEM key\n"
136136
[[ "$debugmode" ]] && echo -e "${CLRheading2}No PEM mode${CLRnormal} Connect string: ${CLRtitle}ssh ${LoginUser}@${InstanceAddy}${CLRnormal}\n"
137-
ssh ${LoginUser}@${InstanceAddy}
137+
ssh "${LoginUser}@${InstanceAddy}"
138138
exit 0
139139
else
140140
[[ "$debugmode" ]] && echo -e "Connect string: ${CLRtitle}ssh -i ${HOME}/.aws/${InstanceKey}.pem ${LoginUser}@${InstanceAddy}${CLRnormal}\n"

aws-start

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# https://github.com/robertpeteuil/Easy-EC2
77
#
88
# Author: Robert Peteuil @RobertPeteuil
9-
# Version: 0.9.1, 2017-03-13
9+
# Version: 0.9.2, 2017-03-20
1010

1111

1212
if [ -z "$1" ] || [ "$1" = "-h" ]; then
@@ -19,10 +19,10 @@ fi
1919

2020
InstanceName="$1"
2121

22-
InstanceId=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${InstanceName}" "Name=instance-state-name,Values=stopped" --query 'Reservations[*].Instances[].[InstanceId]' --output text)
22+
InstanceId=($(aws ec2 describe-instances --filters "Name=tag:Name,Values=${InstanceName}" "Name=instance-state-name,Values=stopped" --query 'Reservations[*].Instances[].[InstanceId]' --output text))
2323

2424
if [ -n "$InstanceId" ]; then
25-
aws ec2 start-instances --instance-ids $InstanceId --output text
25+
aws ec2 start-instances --instance-ids "$InstanceId" --output text
2626
else
2727
echo -e "Instance: ${InstanceName} not found stopped - possibly already offline?"
2828
exit 1

aws-stop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ fi
1919

2020
InstanceName="$1"
2121

22-
InstanceId=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${InstanceName}" "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[].[InstanceId]' --output text)
22+
InstanceId=($(aws ec2 describe-instances --filters "Name=tag:Name,Values=${InstanceName}" "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[].[InstanceId]' --output text))
2323

2424
if [ -n "$InstanceId" ]; then
25-
aws ec2 stop-instances --instance-ids $InstanceId --output text
25+
aws ec2 stop-instances --instance-ids "$InstanceId" --output text
2626
else
2727
echo -e "Instance: ${InstanceName} not found runnning - possibly already offline?"
2828
exit 1

0 commit comments

Comments
 (0)