]>
git.proxmox.com Git - mirror_novnc.git/blob - utils/launch.sh
8 echo "Usage: ${NAME} [--listen PORT] [--vnc VNC_HOST:PORT] [--cert CERT]"
10 echo "Starts the WebSockets proxy and a mini-webserver and "
11 echo "provides a cut-and-paste URL to go to."
13 echo " --listen PORT Port for proxy/webserver to listen on"
15 echo " --vnc VNC_HOST:PORT VNC server host:port proxy target"
16 echo " Default: localhost:5900"
17 echo " --cert CERT Path to combined cert/key file"
18 echo " Default: self.pem"
19 echo " --web WEB Path to web files (e.g. vnc.html)"
25 HERE
="$(cd "$
(dirname "$0")" && pwd)"
27 VNC_DEST
="localhost:5900"
38 trap - TERM QUIT INT EXIT
39 trap "true" CHLD
# Ignore cleanup messages
41 if [ -n "${proxy_pid}" ]; then
42 echo "Terminating WebSockets proxy (${proxy_pid})"
49 # Arguments that only apply to chrooter itself
51 param
=$1; shift; OPTARG
=$1
53 --listen) PORT
="${OPTARG}"; shift ;;
54 --vnc) VNC_DEST
="${OPTARG}"; shift ;;
55 --cert) CERT
="${OPTARG}"; shift ;;
56 --web) WEB
="${OPTARG}"; shift ;;
58 -*) usage
"Unknown chrooter option: ${param}" ;;
64 which netstat
>/dev
/null
2>&1 \
65 || die
"Must have netstat installed"
67 netstat
-ltn |
grep -qs "${PORT} .*LISTEN" \
68 && die
"Port ${PORT} in use. Try --listen PORT"
70 trap "cleanup" TERM QUIT INT EXIT
73 if [ -n "${WEB}" ]; then
74 if [ ! -e "${WEB}/vnc.html" ]; then
75 die
"Could not find ${WEB}/vnc.html"
77 elif [ -e "$(pwd)/vnc.html" ]; then
79 elif [ -e "${HERE}/../vnc.html" ]; then
81 elif [ -e "${HERE}/vnc.html" ]; then
83 elif [ -e "${HERE}/../share/novnc/vnc.html" ]; then
84 WEB
=${HERE}/..
/share
/novnc
/
86 die
"Could not find vnc.html"
90 if [ -n "${CERT}" ]; then
91 if [ ! -e "${CERT}" ]; then
92 die
"Could not find ${CERT}"
94 elif [ -e "$(pwd)/self.pem" ]; then
95 CERT
="$(pwd)/self.pem"
96 elif [ -e "${HERE}/../self.pem" ]; then
97 CERT
="${HERE}/../self.pem"
98 elif [ -e "${HERE}/self.pem" ]; then
99 CERT
="${HERE}/self.pem"
101 echo "Warning: could not find self.pem"
104 echo "Starting webserver and WebSockets proxy on port ${PORT}"
105 ${HERE}/websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} &
108 if ! ps
-p ${proxy_pid} >/dev
/null
; then
110 echo "Failed to start WebSockets proxy"
114 echo -e "\n\nNavigate to this URL:\n"
115 echo -e " http://$(hostname):${PORT}/vnc.html?host=$(hostname)&port=${PORT}\n"
116 echo -e "Press Ctrl-C to exit\n\n"