diff options
-rwxr-xr-x | xvnc | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -5,16 +5,22 @@ | |||
5 | # Restrict connections to the port opened by ssh in xvncviewer@ to the | 5 | # Restrict connections to the port opened by ssh in xvncviewer@ to the |
6 | # corresponding ssh-x11vnc@ service. | 6 | # corresponding ssh-x11vnc@ service. |
7 | 7 | ||
8 | xvncviewer=xtightvncviewer | ||
9 | |||
8 | remote_display=0 | 10 | remote_display=0 |
11 | if [ "$REMOTE_DISPLAY" ] | ||
12 | then | ||
13 | remote_display=$REMOTE_DISPLAY | ||
14 | fi | ||
9 | reverse_connection() | 15 | reverse_connection() |
10 | { | 16 | { |
11 | display=${DISPLAY#:} | 17 | display=${DISPLAY#:} |
12 | display=${display%.*} | 18 | display=${display%.*} |
13 | remote_port=$((58000 + remote_display)) | 19 | remote_port=$((58000)) |
14 | 20 | ||
15 | local_port=$((59000 + display)) | 21 | local_port=$((59000 + display)) |
16 | fuser -vk $local_port/tcp | 22 | fuser -vk $local_port/tcp |
17 | xvncviewer -listen $((local_port - 5500)) & | 23 | $xvncviewer -listen $((local_port - 5500)) & |
18 | pid=$! | 24 | pid=$! |
19 | ( | 25 | ( |
20 | remote_display_arg=${remote_display:+ -display :$remote_display} | 26 | remote_display_arg=${remote_display:+ -display :$remote_display} |
@@ -28,7 +34,7 @@ reverse_connection() | |||
28 | direct_connection() | 34 | direct_connection() |
29 | { | 35 | { |
30 | export VNC_VIA_CMD=": '%G'; ssh -f -L %L:%H:%R $* -- x11vnc -localhost -q -display $remote_display" | 36 | export VNC_VIA_CMD=": '%G'; ssh -f -L %L:%H:%R $* -- x11vnc -localhost -q -display $remote_display" |
31 | xvncviewer -via remote localhost | 37 | $xvncviewer -via remote localhost |
32 | } | 38 | } |
33 | 39 | ||
34 | if [ $# = 0 ] | 40 | if [ $# = 0 ] |