ssvnc 7.89 KB
Newer Older
runge's avatar
runge committed
1 2
#!/bin/sh
#
3
# Copyright (c) 2006-2009 by Karl J. Runge <runge@karlrunge.com>
runge's avatar
runge committed
4
#
5
# ssvnc:
runge's avatar
runge committed
6
#
runge's avatar
runge committed
7
#    A wrapper for ssvnc_cmd using a tcl/tk gui.
runge's avatar
runge committed
8
#
runge's avatar
runge committed
9
# See ssvnc_cmd for details.
runge's avatar
runge committed
10
#
11 12 13 14 15 16 17 18 19
if [ "X$1" = "X-help" -o "X$1" = "X-h" ]; then
	cat << END
ssvnc - a GUI wrapper for SSL and SSH VNC connections.

SYNOPSIS
       ssvnc
       ssvnc [host][:display]
       ssvnc [saved-profile-name]
       ssvnc [options] [host-or-profile]
20
       ssvnc -cmd [ssvnc_cmd-args]
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
       ssvnc --help

DESCRIPTION
       ssvnc  is  a tcl/tk gui wrapper that runs on Unix, MacOSX, and Windows.
       It sets up an SSL or SSH tunnel to  the  remote  VNC  Server  and  then
       launches  the  VNC  viewer (either the one provided or another one that
       you have specified) to use that encrypted tunnel to connect to the  VNC
       Server.   The  use  of  Proxies and Gateways to make the connections is
       implemented.

OPTIONS
       -help, -h   Print this help.

       --help Starts  up  the  GUI  as though the 'Help' button was pressed to
              show the main Help panel.

37 38 39 40 41 42
       -cmd [ssvnc_cmd-args]
              Launch the ssvnc_cmd utility command directly (no GUI) with  the
              given  arguments  (for use when ssvnc_cmd is not in one's PATH.)
              If neither ssvnc_cmd nor ssvncviewer is in PATH, one can  launch
              the viewer directly via: ssvnc -cmd -viewer [viewer-args]

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
       -profiles
              List the saved SSVNC profiles you have created.  A profile is  a
              destination host with specific parameter settings.

       -list  Same as -profiles

       -ssh   Start  in  "SSH  Only Mode".  No SSL aspects are shown.  Same as
              running the command sshvnc

       -ts    Start in "Terminal Services  Mode".   This  is  like  "SSH  Only
              Mode", but simpler and assumes x11vnc is available on the remote
              side to start and manage X and VNC sessions.   Same  as  running
              the command tsvnc

       -tso   Same as -ts "Terminal Services Mode", however never let the user
              leave this mode (no button to switch modes is  provided.)   Same
              as SSVNC_TS_ALWAYS=1.

       -ssl   Force the full GUI Mode: both SSL and SSH.  This is the default.
              Same as -ss.

       -nv    Toggle the "Verify All Certs" button to be off at startup.

       -nvb   Never show the "Verify All Certs" button.  Same as SSVNC_NO_VER-
              IFY_ALL_BUTTON=1.

       -bigger
              Make  the  Profile  Selection  Dialog  window  bigger.   Same as
              SSVNC_BIGGER_DIALOG=1.

73
       -noenc Start  off  in  a  mode  where a 'No Encryption' check button is
74 75
              present.   You  can  toggle  the  mode  with  Ctrl-E.   Same  as
              SSVNC_DISABLE_ENCRYPTION_BUTTON=1.  Or  noenc=1  in  ~/.ssvncrc.
76 77 78
              Selecting no encryption is the same as  the  vnc://  and  Vnc://
              prefixes  described  below.  The -noenc mode is now the default,
              use -enc or noenc=0 for the opposite behavior.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107

       -killstunnel
              On Windows, automatically terminate the STUNNEL process when the
              viewer  exits instead of prompting you (same as killstunnel=1 in
              ssvnc_rc or toggle in Options menu)

       -nokillstunnel
              On Windows, disable -killstunnel mode.  Same as killstunnel=0 in
              ssvnc_rc or toggle in Options menu.  Note that -killstunnel mode
              is now the default.

       -mycert /path/to/mycert.pem
              Set the default "MyCert" to  be  /path/to/mycert.pem.   Same  as
              -cert.  If the file does not exist, ~/.vnc/certs is prefixed and
              tried. You can also set mycert=/path/to/mycert.pem in ~/.ssvncrc

       -cacert /path/to/cacert.crt
              Set the default "ServerCert" to be /path/to/cacert.crt.  Same as
              -ca.  If the file does not exist, ~/.vnc/certs is  prefixed  and
              tried. You can also set cacert=/path/to/cacert.crt in ~/.ssvncrc

       -crl /path/to/mycrl.pem
              Set   the   default   Certificate   Revocation   List   to    be
              /path/to/mycrl.pem.  If the file does not exist, ~/.vnc/certs is
              prefixed and tried.  You can also set crl=/path/to/mycrl.pem  in
              ~/.ssvncrc.
END
	exit 0
fi
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
if [ "X$1" = "X-ssh" ]; then
	if [ "X$2" = "X-help" -o "X$2" = "X-h" ]; then
		cat << END
sshvnc - a GUI wrapper for SSH VNC connections.

SYNOPSIS
       sshvnc
       sshvnc [host][:display]
       sshvnc [saved-profile-name]
       sshvnc [options] [host-or-profile]
       sshvnc --help

See 'ssvnc $2' and 'ssvnc --help' for more information.
END
		exit 0
	fi
fi

if [ "X$1" = "X-ts" -o "X$1" = "X-tso" ]; then
	if [ "X$2" = "X-help" -o "X$2" = "X-h" ]; then
		cat << END
tsvnc - a GUI wrapper for SSH VNC connections using x11vnc Terminal Services.

SYNOPSIS
       tsvnc
       tsvnc [host][:display]
       tsvnc [saved-profile-name]
       tsvnc [options] [host-or-profile]
       tsvnc --help

See 'ssvnc $2' and 'tsvnc --help' for more information.
END
		exit 0
	fi
fi

144

runge's avatar
runge committed
145 146 147 148 149 150 151 152 153 154
if [ "X$XTERM_PRINT" != "X" ]; then
	XTERM_PRINT=""
	cat > /dev/null
fi
if [ "X$1" = "X-bg" ]; then
	shift
	$0 "$@" &
	exit 0
fi

155

runge's avatar
runge committed
156
PATH=$PATH:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/openwin/bin:/usr/sfw/bin:/usr/local/bin
runge's avatar
runge committed
157 158
export PATH

runge's avatar
runge committed
159
if [ "X$FULLNAME" = "XKarl J. Runge" ]; then
160 161 162 163
	if [ "X$NOPOPUFIX" = "X" ]; then
		VNCVIEWER_POPUP_FIX=1
		export VNCVIEWER_POPUP_FIX
	fi
runge's avatar
runge committed
164 165 166
	PATH=`echo "$PATH" | sed -e 's,runge/bin/override,-------------,'`
fi

runge's avatar
runge committed
167 168
if [ "X$WISH" = "X" ]; then
	WISH=wish
169
	for try in wish8.4 wish wish8.3 wish8.5 wish8.6
runge's avatar
runge committed
170
	do
171
		if type $try > /dev/null 2>&1; then
runge's avatar
runge committed
172 173 174 175
			WISH=$try
			break
		fi
	done
176
	export WISH
runge's avatar
runge committed
177
fi
runge's avatar
runge committed
178

runge's avatar
runge committed
179 180 181 182 183

SSVNC_GUI_CMD="$0 $*"
export SSVNC_GUI_CMD
SSVNC_LAUNCH=$SSVNC_GUI_CMD
export SSVNC_LAUNCH
runge's avatar
runge committed
184 185 186 187 188

# work out os.arch platform string and check for binaries:
#
name=$UNAME
if [ "X$name" = "X" ]; then
189
	name=`uname -sm | sed -e 's/ /./g' -e 's,/.*,,' -e 's/Linux\.i.86/Linux.i686/'`
runge's avatar
runge committed
190 191
fi

192 193 194 195 196
dL="-L"
if uname -sr | egrep 'SunOS 5\.[5-8]' > /dev/null; then
	dL="-h"
fi

runge's avatar
runge committed
197 198 199
f="$0"
for t in 1 2 3 4 5
do
200
	if [ $dL "$f" ]; then
runge's avatar
runge committed
201 202 203 204 205 206 207 208 209 210 211 212
		f0="$f"
		f=`ls -l "$f" | sed -e 's/^.* -> //'`
		if echo "$f" | grep '^/' > /dev/null; then
			:
		else
			f="`dirname "$f0"`/$f"
		fi
	else
		break
	fi
done
dir=`dirname "$f"`
runge's avatar
runge committed
213
PATH="$dir:$PATH"
runge's avatar
runge committed
214

runge's avatar
runge committed
215 216 217
nearby=0
if [ -x "$dir/vncviewer" -a -x "$dir/stunnel" ]; then
	nearby=1
runge's avatar
runge committed
218
fi
219 220 221 222 223
if [ "X$name" = "X." ]; then
	:
	#type vncviewer
	#type stunnel
elif [ ! -d "$dir/$name" -a $nearby = 0 ]; then
runge's avatar
runge committed
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
	echo
	echo "Cannot find platform dir for your OS `uname -sm`:"
	echo
	echo "    $dir/$name" 
	echo
	PATH=$PATH:/usr/sbin:/usr/local/sbin:/dist/sbin

	quit=0
	if type vncviewer >/dev/null 2>/dev/null; then
		:
	else
		echo "vncviewer not found in PATH." 
		quit=1
	fi
	if type stunnel >/dev/null 2>/dev/null; then
		:
	else
		echo "stunnel not found in PATH."
		quit=1
	fi
	echo
	if [ "X$quit" = "X1" ]; then
		echo "You can set the \$UNAME env. var. to override the OS setting."
		echo "Or, if available, run the ./build.unix script to build it."
		echo "Or install external \"vncviewer\" and \"stunnel\" packages."
		exit 1
	fi
	echo "Using externel \"vncviewer\" and \"stunnel\" found in PATH."
else
runge's avatar
runge committed
253
	STUNNEL=stunnel
254 255
	#STUNNEL_EXTRA_OPTS=${STUNNEL_EXTRA_OPTS:-"maxconn = 1"}
	#export STUNNEL STUNNEL_EXTRA_OPTS
runge's avatar
runge committed
256 257 258 259
	SSVNC_VIEWER_INTERNAL=1
	export SSVNC_VIEWER_INTERNAL
fi

runge's avatar
runge committed
260 261 262 263 264 265 266 267 268 269 270 271

# Put our os.arch and other utils dirs at head of PATH to be sure to
# pick them up:
#
PATH="$dir:$dir/$name:$dir/util:$PATH"
if echo "$dir" | grep '^/' > /dev/null; then
	:
else
	dir=`pwd`/$dir
	PATH="$dir:$dir/$name:$dir/util:$PATH"
fi

runge's avatar
runge committed
272 273
SSVNC_BASEDIR="$dir"
export SSVNC_BASEDIR
274 275
SSVNC_BASEDIRNAME="$dir/$name"
export SSVNC_BASEDIRNAME
runge's avatar
runge committed
276

277 278 279 280 281
if [ -f "$dir/util/ultraftp.jar" ]; then
	SSVNC_ULTRA_FTP_JAR="$dir/util/ultraftp.jar"
	export SSVNC_ULTRA_FTP_JAR
fi

282
if [ "X$1" = "X-cmd" -o "X$1" = "X--cmd" ]; then
283 284 285
	shift
	exec ssvnc_cmd "$@"
elif [ "X$WISH" = "Xwish" ]; then
runge's avatar
runge committed
286 287 288 289
	exec ssvnc.tcl "$@"
else
	exec $WISH $dir/util/ssvnc.tcl "$@"
fi