summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2016-02-10 17:21:24 +0100
committerDominique Martinet <dominique.martinet@cea.fr>2016-06-10 23:59:07 +0200
commitc6ecafb710966d0b9caaef6980660cd55be02dfa (patch)
tree5c451c033a5d479d4df047dea22e6b55d805ee4b
parent4209c9cc0d2b38a297b68dbec627182278fd1f80 (diff)
Revert "vncviewer simple way..."
This reverts commit a4b33a3130bb50bad6e9d794c727f553b164720e.
-rwxr-xr-xkvm-wrapper.sh16
1 files changed, 15 insertions, 1 deletions
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 3d0fc17..dbc4b22 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -1383,7 +1383,21 @@ function kvm_vncviewer_vm ()
[[ -z "$PORT" ]] && fail_exit "Error: couldn't find vnc port used"
if test_nodename "$KVM_CLUSTER_NODE"; then
- vncviewer $KVM_CLUSTER_NODE:$PORT
+ while
+ LOCALPORT=$((RANDOM%1000+4000))
+ ss -nplt \( sport = :$LOCALPORT \) | grep -q $LOCALPORT
+ do :; done
+
+ SSH_OPTS="-L $LOCALPORT:localhost:$PORT -N" run_remote "$KVM_CLUSTER_NODE" &
+ SSHPID=$!
+
+ trap "kill $SSHPID" EXIT
+ while ! ss -nplt \( sport = :$LOCALPORT \) | grep -q $LOCALPORT; do
+ sleep 0.1
+ done
+ vncviewer localhost:$LOCALPORT || fail_exit "Error: couldn't start vncviewer"
+
+ kill $SSHPID
else
vncviewer localhost:$PORT
fi