Skip to content

Commit

Permalink
feat: add exit on failure variable
Browse files Browse the repository at this point in the history
  • Loading branch information
vrenaville committed Apr 29, 2022
1 parent d9ccfc2 commit 3fd1df9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ Specify the address (ip preferred) of the *remote* endpoint. (Default:

Specify the `ssh` port the *remote* endpoint to connect. (Default: `22`)

#### EXITONFORWARDFAILURE

Specify if autossh must abord on forward failure, set to 'no' for debug. (Default: `yes`)


#### SSH_TUNNEL_PORT

Specify the port number on the *remote* endpoint which will serve as the
Expand Down
32 changes: 16 additions & 16 deletions rootfs/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ fi

# Add entry to /etc/passwd if we are running non-root
if [[ $(id -u) != "0" ]]; then
USER="autossh:x:$(id -u):$(id -g):autossh:/tmp:/bin/sh"
echo "[INFO ] Creating non-root-user = $USER"
echo "$USER" >> /etc/passwd
USER="autossh:x:$(id -u):$(id -g):autossh:/tmp:/bin/sh"
echo "[INFO ] Creating non-root-user = $USER"
echo "$USER" >>/etc/passwd
fi

if [ ! -z "${SSH_BIND_IP}" ] && [ "${SSH_MODE}" = "-R" ]; then
Expand All @@ -48,20 +48,20 @@ let "DEFAULT_PORT += 32768"
# Log to stdout
echo "[INFO ] Using $(autossh -V)"
echo "[INFO ] Tunneling ${SSH_BIND_IP:=127.0.0.1}:${SSH_TUNNEL_PORT:=${DEFAULT_PORT}}" \
" on ${SSH_REMOTE_USER:=root}@${SSH_REMOTE_HOST:=localhost}:${SSH_REMOTE_PORT}" \
" to ${SSH_TARGET_HOST=localhost}:${SSH_TARGET_PORT:=22}"
" on ${SSH_REMOTE_USER:=root}@${SSH_REMOTE_HOST:=localhost}:${SSH_REMOTE_PORT}" \
" to ${SSH_TARGET_HOST=localhost}:${SSH_TARGET_PORT:=22}"

COMMAND="autossh "\
"-M 0 "\
"-N "\
"-o StrictHostKeyChecking=${STRICT_HOSTS_KEY_CHECKING} ${KNOWN_HOSTS_ARG:=}"\
"-o ServerAliveInterval=${SSH_SERVER_ALIVE_INTERVAL:-10} "\
"-o ServerAliveCountMax=${SSH_SERVER_ALIVE_COUNT_MAX:-3} "\
"-o ExitOnForwardFailure=yes "\
"-t -t "\
"${SSH_MODE:=-R} ${SSH_BIND_IP}:${SSH_TUNNEL_PORT}:${SSH_TARGET_HOST}:${SSH_TARGET_PORT} "\
"-p ${SSH_REMOTE_PORT:=22} "\
"${SSH_REMOTE_USER}@${SSH_REMOTE_HOST}"
COMMAND="autossh " \
"-M 0 " \
"-N " \
"-o StrictHostKeyChecking=${STRICT_HOSTS_KEY_CHECKING} ${KNOWN_HOSTS_ARG:=}" \
"-o ServerAliveInterval=${SSH_SERVER_ALIVE_INTERVAL:-10} " \
"-o ServerAliveCountMax=${SSH_SERVER_ALIVE_COUNT_MAX:-3} " \
"-o ExitOnForwardFailure=${EXITONFORWARDFAILURE:=yes} " \
"-t -t " \
"${SSH_MODE:=-R} ${SSH_BIND_IP}:${SSH_TUNNEL_PORT}:${SSH_TARGET_HOST}:${SSH_TARGET_PORT} " \
"-p ${SSH_REMOTE_PORT:=22} " \
"${SSH_REMOTE_USER}@${SSH_REMOTE_HOST}"

echo "[INFO ] # ${COMMAND}"

Expand Down

0 comments on commit 3fd1df9

Please sign in to comment.