From ada888dcd5a2ffd3401ae4c165b689fcad789350 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 21 Nov 2020 19:45:09 -0500 Subject: [PATCH] add ssh/scp/rsync wrapper scripts, with bubble port pre-set --- bin/brsync | 27 +++++++++++++++++++++++++++ bin/bscp | 16 ++++++++++++++++ bin/bssh | 16 ++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100755 bin/brsync create mode 100755 bin/bscp create mode 100755 bin/bssh diff --git a/bin/brsync b/bin/brsync new file mode 100755 index 00000000..5c0aa917 --- /dev/null +++ b/bin/brsync @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ +# +# Wrap rsync with options to use port 1202, the standard Bubble SSH port. +# If your rsync command already contains a `-e` or `--rsh` option, this wrapper will not work. +# +# Environment variables: +# +# BUBBLE_SSH_PORT : If set, this port will be used instead of 1202 +# + +if [[ -z "${BUBBLE_SSH_PORT}" ]] ; then + BUBBLE_SSH_PORT="1202" +fi + +function die() { + echo 1>&2 "${1}" + exit 1 +} + + +if [[ $(echo "${@}" | grep -c -- "-e ") -gt 0 || $(echo "${@}" | grep -c -- "--rsh") -gt 0 ]] ; then + die "$0 does not work correctly when -e or --rsh is used, since it sets its own: ${@}" +fi + +rsync -e ''"$(which ssh)"' -p '"${BUBBLE_SSH_PORT}"'' "${@}" diff --git a/bin/bscp b/bin/bscp new file mode 100755 index 00000000..3d78707b --- /dev/null +++ b/bin/bscp @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ +# +# Wrap scp with options to use port 1202, the standard Bubble SSH port +# +# Environment variables: +# +# BUBBLE_SSH_PORT : If set, this port will be used instead of 1202 +# + +if [[ -z "${BUBBLE_SSH_PORT}" ]] ; then + BUBBLE_SSH_PORT="1202" +fi + +scp -P ${BUBBLE_SSH_PORT} "${@}" diff --git a/bin/bssh b/bin/bssh new file mode 100755 index 00000000..1e34e065 --- /dev/null +++ b/bin/bssh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ +# +# Wrap ssh with options to use port 1202, the standard Bubble SSH port. +# +# Environment variables: +# +# BUBBLE_SSH_PORT : If set, this port will be used instead of 1202 +# + +if [[ -z "${BUBBLE_SSH_PORT}" ]] ; then + BUBBLE_SSH_PORT="1202" +fi + +ssh -p ${BUBBLE_SSH_PORT} "${@}"