diff options
Diffstat (limited to 'dot/local')
-rwxr-xr-x | dot/local/bin/xvnc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/dot/local/bin/xvnc b/dot/local/bin/xvnc index 375d13a..7eba3f2 100755 --- a/dot/local/bin/xvnc +++ b/dot/local/bin/xvnc | |||
@@ -1,4 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | set -e | ||
3 | set -o pipefail | ||
2 | 4 | ||
3 | # x11vnc option '-noxrecord' added as workaround for crashing bug | 5 | # x11vnc option '-noxrecord' added as workaround for crashing bug |
4 | # See https://github.com/LibVNC/x11vnc/issues/61 | 6 | # See https://github.com/LibVNC/x11vnc/issues/61 |
@@ -44,25 +46,23 @@ share_display() | |||
44 | 46 | ||
45 | port=5500 | 47 | port=5500 |
46 | OUR_TMP=$(mktemp -d) || exit | 48 | OUR_TMP=$(mktemp -d) || exit |
47 | socket_file=$OUR_TMP/x11vnc.socket | 49 | local_socket_file=$OUR_TMP/x11vnc.socket |
50 | ssh_control=$OUR_TMP/ssh.socket | ||
48 | 51 | ||
49 | # killall x11vnc | 52 | x11vnc -noxrecord -q -nopw -ncache -ncache_cr -display "${local_display}" -unixsock "$local_socket_file" -rfbport 0 & |
50 | x11vnc -noxrecord -q -nopw -ncache -ncache_cr -display "${local_display}" -unixsock "$socket_file" & | ||
51 | X11VNC=$! | 53 | X11VNC=$! |
52 | trap atexit EXIT | 54 | trap atexit EXIT |
53 | 55 | ||
54 | # TODO: spin waiting for port 5500 | 56 | rando=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c15) && [ "$rando" ] |
55 | ssh -n \ | 57 | remote_socket_file=/tmp/xtigervncviewer.$rando.socket |
56 | ${remote_port:+ -p "$remote_port" } \ | 58 | |
57 | "$remote_host" \ | ||
58 | "fuser -vk $port/tcp && sleep 1" | ||
59 | ssh -n \ | 59 | ssh -n \ |
60 | -o ControlPath=none \ | 60 | -o ControlPath=none \ |
61 | -o ExitOnForwardFailure=yes \ | 61 | -o ExitOnForwardFailure=yes \ |
62 | -R "localhost:$port:$socket_file" \ | 62 | -R "$remote_socket_file:$local_socket_file" \ |
63 | ${remote_port:+ -p "$remote_port" } \ | 63 | ${remote_port:+ -p "$remote_port" } \ |
64 | "$remote_host" \ | 64 | "$remote_host" \ |
65 | "DISPLAY=${remote_display} xvncviewer localhost:$port" 2>&1 & | 65 | "${DEBUG:+ set -x; } trap 'rm -f $remote_socket_file' EXIT; DISPLAY=$remote_display xtigervncviewer $remote_socket_file" & |
66 | SSH=$! | 66 | SSH=$! |
67 | wait -n | 67 | wait -n |
68 | } | 68 | } |