Allow customizing ssh port for the default client

Closes #1942
This commit is contained in:
Jose Diaz-Gonzalez
2016-03-02 22:01:52 -05:00
parent fb45f221b7
commit a765789c4d
2 changed files with 8 additions and 4 deletions

View File

@@ -41,6 +41,8 @@ if [[ -z $DOKKU_HOST ]]; then
fi
fi
export DOKKU_PORT=${DOKKU_PORT:=22}
if [[ ! -z $DOKKU_HOST ]]; then
_dokku() {
appname=""
@@ -72,10 +74,10 @@ if [[ ! -z $DOKKU_HOST ]]; then
if [[ -z "$2" ]]; then
appname=$(random_name)
counter=0
while ssh "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do
while ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps 2>/dev/null| grep -q "$appname"; do
if [[ $counter -ge 100 ]]; then
echo "Error: could not reasonably generate a new app name. try cleaning up some apps..."
ssh "dokku@$DOKKU_HOST" apps
ssh -p "$DOKKU_PORT" "dokku@$DOKKU_HOST" apps
exit 1
else
appname=$(random_name)
@@ -98,7 +100,7 @@ if [[ ! -z $DOKKU_HOST ]]; then
if [[ -z "$donotshift" ]]; then
# shellcheck disable=SC2029
ssh -o LogLevel=QUIET -t "dokku@$DOKKU_HOST" "$@"
ssh -o LogLevel=QUIET -p "$DOKKU_PORT" -t "dokku@$DOKKU_HOST" "$@"
exit $?
fi
@@ -125,7 +127,7 @@ if [[ ! -z $DOKKU_HOST ]]; then
fi
fi
# shellcheck disable=SC2086,SC2029
ssh -o LogLevel=QUIET -t "dokku@$DOKKU_HOST" $long_args "$verb" "$appname" "${args[@]}"
ssh -o LogLevel=QUIET -p "$DOKKU_PORT" -t "dokku@$DOKKU_HOST" $long_args "$verb" "$appname" "${args[@]}"
}
if [[ "$0" == "dokku" ]] || [[ "$0" == *dokku_client.sh ]] || [[ "$0" == $(which dokku) ]]; then

View File

@@ -33,6 +33,8 @@ alias dokku 'bash $HOME/.dokku/contrib/dokku_client.sh'
Configure the `DOKKU_HOST` environment variable or run `dokku` from a repository with a git remote named dokku pointed at your dokku host in order to use the script as normal.
You can also configure a `DOKKU_PORT` environment variable if you are running ssh on a non-standard port. This defaults to `22`.
## (nodejs) dokku-toolbelt
Dokku-toolbelt is a node-based cli wrapper that proxies requests to the dokku command running on remote hosts. You can install it via the following shell command (assuming you have nodejs and npm installed):