launch.sh --listen option handle bind IP

see https://github.com/novnc/websockify/issues/411
This commit is contained in:
Takatoshi MATSUO 2020-08-11 00:11:22 +09:00
parent 9142f8f0f7
commit 698af0a6e0
1 changed files with 13 additions and 5 deletions

View File

@ -13,7 +13,7 @@ usage() {
echo "Starts the WebSockets proxy and a mini-webserver and " echo "Starts the WebSockets proxy and a mini-webserver and "
echo "provides a cut-and-paste URL to go to." echo "provides a cut-and-paste URL to go to."
echo echo
echo " --listen PORT Port for proxy/webserver to listen on" echo " --listen IP:PORT Port or IP:Port for proxy/webserver to listen on"
echo " Default: 6080" echo " Default: 6080"
echo " --vnc VNC_HOST:PORT VNC server host:port proxy target" echo " --vnc VNC_HOST:PORT VNC server host:port proxy target"
echo " Default: localhost:5900" echo " Default: localhost:5900"
@ -63,7 +63,7 @@ cleanup() {
while [ "$*" ]; do while [ "$*" ]; do
param=$1; shift; OPTARG=$1 param=$1; shift; OPTARG=$1
case $param in case $param in
--listen) PORT="${OPTARG}"; shift ;; --listen) IP_PORT="${OPTARG}"; shift ;;
--vnc) VNC_DEST="${OPTARG}"; shift ;; --vnc) VNC_DEST="${OPTARG}"; shift ;;
--cert) CERT="${OPTARG}"; shift ;; --cert) CERT="${OPTARG}"; shift ;;
--key) KEY="${OPTARG}"; shift ;; --key) KEY="${OPTARG}"; shift ;;
@ -76,6 +76,13 @@ while [ "$*" ]; do
esac esac
done done
if [ -n "$IP_PORT" ]; then
if [[ ${IP_PORT} =~ : ]]; then
IP=`echo ${IP_PORT%:*}:`
fi
PORT=`echo ${IP_PORT##*:}`
fi
# Sanity checks # Sanity checks
if bash -c "exec 7<>/dev/tcp/localhost/${PORT}" &> /dev/null; then if bash -c "exec 7<>/dev/tcp/localhost/${PORT}" &> /dev/null; then
exec 7<&- exec 7<&-
@ -160,9 +167,10 @@ else
fi fi
fi fi
echo "Starting webserver and WebSockets proxy on port ${PORT}" echo "Starting webserver and WebSockets proxy on port ${IP}${PORT}"
#${HERE}/websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} & #${HERE}/websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${IP}${PORT} ${VNC_DEST} &
${WEBSOCKIFY} ${SSLONLY} --web ${WEB} ${CERT:+--cert ${CERT}} ${KEY:+--key ${KEY}} ${PORT} ${VNC_DEST} ${RECORD_ARG} & ${WEBSOCKIFY} ${SSLONLY} --web ${WEB} ${CERT:+--cert ${CERT}} ${KEY:+--key ${KEY}} ${IP}${PORT} ${VNC_DEST} ${RECORD_ARG} &
proxy_pid="$!" proxy_pid="$!"
sleep 1 sleep 1
if ! ps -p ${proxy_pid} >/dev/null; then if ! ps -p ${proxy_pid} >/dev/null; then