dotfiles/bin/vncsconnect
2023-04-16 22:58:56 +02:00

37 lines
588 B
Bash
Executable file

#!/bin/bash
# Variables
declare -a make_ssh_bridge open_vnc_session
ssh_fwd=ssh-fwd
vncviewer=wlvncc
localhost=localhost
# Arguments
ssh_host="$1" ; shift
local_port="${1:-9900}" ; shift
distant_port="${1:-5900}"; shift
target="$1" ; shift
# Commands building
# Make SSH bridge
make_ssh_bridge+=(
"$ssh_fwd"
"$ssh_host"
"$local_port"
"$distant_port"
"$target"
)
# Open VNC session
open_vnc_session+=(
"$vncviewer"
"$@"
"${localhost}"
"${local_port}"
)
# Execution
set -xe
"${make_ssh_bridge[@]}"
"${open_vnc_session[@]}"