Skip to content

Commit

Permalink
Update cloudssh-tmux script
Browse files Browse the repository at this point in the history
  • Loading branch information
ezh committed Dec 17, 2019
1 parent 8e91dd9 commit d801260
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions example/cloudssh-tmux
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
# cloudselect arguments -- ssh arguments

function jumphost() {
OUTPUT=$(echo $1 | base64 --decode)
JUMPHOST=$(echo $OUTPUT | jq -r '.jumphost // ""')
test -z "$JUMPHOST" && return
OUTPUT=$(echo $1 | base64 --decode)
JUMPHOST=$(echo $OUTPUT | jq -r '.jumphost // ""')
test -z "$JUMPHOST" && return

HOST=$(echo $OUTPUT | jq -r '.jumphost.host')
KEY="-i"$(echo $OUTPUT | jq -r '.jumphost.key // ""')
USER=$(echo $OUTPUT | jq -r '.jumphost.user // ""')"@"
HOST=$(echo $OUTPUT | jq -r '.jumphost.host')
KEY="-i"$(echo $OUTPUT | jq -r '.jumphost.key // ""')
USER=$(echo $OUTPUT | jq -r '.jumphost.user // ""')"@"

test "$KEY" == "-i" && KEY=""
test "$USER" == "@" && USER=""
echo ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $OPTION_SSH $KEY $USER$HOST
test "$KEY" == "-i" && KEY=""
test "$USER" == "@" && USER=""
echo ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $OPTION_SSH $KEY $USER$HOST
}


CLOUDSELECT_ARGS=$#
if [ $CLOUDSELECT_ARGS -eq 0 ]; then
cloudselect
exit
fi
for (( i=1; i <= "$#"; i++ )); do
if [ "${!i}" == "--" ]; then
CLOUDSELECT_ARGS=$(($i-1))
Expand All @@ -33,7 +36,7 @@ if [ $? -ne 0 ];then
fi

CLOUD=$(echo $OUTPUT | jq -r '.instances[] | @base64')
TMUX_LAYOUT="tiled"
TMUX_LAYOUT=${TMUX_LAYOUT:-tiled}
TMUX_SESSION_NAME="assh-"$(date +%s)
WAIT_FOR_INPUT='read -n 1 -s -r -p "Press any key to continue"'
WINDOW=0
Expand Down

0 comments on commit d801260

Please sign in to comment.