]>
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 a mini-webserver and the WebSockets proxy and"
11 echo "provides a cut and paste URL to go to."
13 echo " --listen PORT Port for webserver/proxy 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"
23 HERE
="$(cd "$
(dirname "$0")" && pwd)"
25 VNC_DEST
="localhost:5900"
35 trap - TERM QUIT INT EXIT
36 trap "true" CHLD
# Ignore cleanup messages
38 if [ -n "${proxy_pid}" ]; then
39 echo "Terminating WebSockets proxy (${proxy_pid})"
46 # Arguments that only apply to chrooter itself
48 param
=$1; shift; OPTARG
=$1
50 --listen) PORT
="${OPTARG}"; shift ;;
51 --vnc) VNC_DEST
="${OPTARG}"; shift ;;
52 --cert) CERT
="${OPTARG}"; shift ;;
54 -*) usage
"Unknown chrooter option: ${param}" ;;
60 which netstat
>/dev
/null
2>&1 \
61 || die
"Must have netstat installed"
63 netstat
-ltn |
grep -qs "${PORT}.*LISTEN" \
64 && die
"Port ${PORT} in use. Try --listen PORT"
66 trap "cleanup" TERM QUIT INT EXIT
69 if [ -e "$(pwd)/vnc.html" ]; then
71 elif [ -e "${HERE}/../vnc.html" ]; then
73 elif [ -e "${HERE}/vnc.html" ]; then
76 die
"Could not find vnc.html"
80 if [ -n "${CERT}" ]; then
81 if [ ! -e "${CERT}" ]; then
82 die
"Could not find ${CERT}"
84 elif [ -e "$(pwd)/self.pem" ]; then
85 CERT
="$(pwd)/self.pem"
86 elif [ -e "${HERE}/../self.pem" ]; then
87 CERT
="${HERE}/../self.pem"
88 elif [ -e "${HERE}/self.pem" ]; then
89 CERT
="${HERE}/self.pem"
91 echo "Warning: could not find self.pem"
94 echo "Starting webserver and WebSockets proxy on port ${PORT}"
95 ${HERE}/wsproxy.py -f --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} &
98 if ps
-p ${proxy_pid} >/dev
/null
; then
99 echo "Started WebSockets proxy (pid: ${proxy_pid})"
102 echo "Failed to start WebSockets proxy"
106 echo -e "\n\nNavigate to to this URL:\n"
107 echo -e " http://$(hostname):${PORT}/vnc.html?host=$(hostname)&port=${PORT}\n"
108 echo -e "Press Ctrl-C to exit\n\n"