From b8abeecd3251d69facd7430f49c5b47012ab7e9f Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Sat, 17 Jun 2023 19:52:19 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20:=20v=C3=A9rifier=20que=20le=20pont=20S?= =?UTF-8?q?SH=20n'existe=20pas=20d=C3=A9j=C3=A0=20dans=20vncsconnect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/vncsconnect | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/vncsconnect b/bin/vncsconnect index a7dcbe4..e6f2a33 100755 --- a/bin/vncsconnect +++ b/bin/vncsconnect @@ -3,6 +3,11 @@ # Variables declare -a ssh_args +# Fonction +ssh_bridge_already_exists() { + [ -n "$(lsof -nP -i TCP -s TCP:LISTEN | awk '($1 == "ssh" && $9 ~ /.*:'"${1}"'/) { print }')" ] +} + # Sélectionner le viewer adapté à la session if [ -n "$WAYLAND_DISPLAY" ]; then vncviewer=wlvncc @@ -32,8 +37,11 @@ if [ -n "$separator" ]; then fi # Exécution -set -e -ssh-fwd "${ssh_args[@]}" -- "$@" +if ! ssh_bridge_already_exists; then + ssh-fwd "${ssh_args[@]}" -- "$@" || exit +else + echo "Le pont SSH existe déjà !" +fi exec "$vncviewer" \ "${args[@]}"