forked from dimbor-ru/freenx-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nxviewer_helper
executable file
·45 lines (38 loc) · 1.43 KB
/
nxviewer_helper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
#
# nxviewer_helper - Small helper for external vncviewer program as needed by NX 3.0.0 backend.
#
# Copyright (c) 2007 by Fabian Franz <[email protected]>
#
# License: GPL, v2
#
# SVN: $Id $
#
[ -z "$COMMAND_VNCVIEWER" ] && COMMAND_VNCVIEWER="vncviewer"
[ -z "$COMMAND_VNCPASSWD" ] && COMMAND_VNCPASSWD="$PATH_BIN/nxpasswd"
[ -z "$COMMAND_X11VNC" ] && COMMAND_X11VNC="x11vnc"
mkdir -p "$NXSESSION_DIRECTORY/scripts/"
echo "$agent_password" | \
$COMMAND_VNCPASSWD "$NXSESSION_DIRECTORY/scripts/.passwd" doit
# Start x11vnc
if [ -n "$shadowdisplay" ]; then
(
# Get correct xauthority file from environment
export XAUTHORITY="$SHADOW_XAUTHORITY"
viewonly=""
[ "$ENABLE_INTERACTIVE_SESSION_SHADOWING" != "1" ] && \
viewonly="-viewonly"
DISPLAY="$shadowhost:$shadowdisplay" $COMMAND_X11VNC -localhost $viewonly -timeout 120 -once -rfbauth "$NXSESSION_DIRECTORY/scripts/.passwd" >"$NXSESSION_DIRECTORY/scripts/.vnc_port" &
)
sleep 2
agent_port=$(cat "$NXSESSION_DIRECTORY/scripts/.vnc_port" | egrep "^PORT=" | cut -d'=' -f 2)
[ -z "agent_port" ] && agent_port="0"
# note the :: is not a mistake, but rather a hint for
# nxviewer to use this as a port and not
# interpret it as a display.
agent_server="127.0.0.1::$agent_port"
rm -f "$NXSESSION_DIRECTORY/scripts/.vnc_port"
fi
# Start the vncviewer
exec $COMMAND_VNCVIEWER -passwd "$NXSESSION_DIRECTORY/scripts/.passwd" \
-fullscreen $AGENT_EXTRA_OPTIONS_RFB "$agent_server"