--- a/utils/launch.sh +++ b/utils/launch.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/ash # Copyright 2016 Joel Martin # Copyright 2016 Solly Ross @@ -25,8 +25,8 @@ exit 2 } -NAME="$(basename $0)" -REAL_NAME="$(readlink -f $0)" +NAME="$(basename "$0")" +REAL_NAME="$(readlink -f "$0")" HERE="$(cd "$(dirname "$REAL_NAME")" && pwd)" PORT="6080" VNC_DEST="localhost:5900" @@ -106,42 +106,11 @@ echo "Warning: could not find self.pem" fi -# try to find websockify (prefer local, try global, then download local) -if [[ -e ${HERE}/websockify ]]; then - WEBSOCKIFY=${HERE}/websockify/run - - if [[ ! -x $WEBSOCKIFY ]]; then - echo "The path ${HERE}/websockify exists, but $WEBSOCKIFY either does not exist or is not executable." - echo "If you intended to use an installed websockify package, please remove ${HERE}/websockify." - exit 1 - fi - - echo "Using local websockify at $WEBSOCKIFY" -else - WEBSOCKIFY=$(which websockify 2>/dev/null) - - if [[ $? -ne 0 ]]; then - echo "No installed websockify, attempting to clone websockify..." - WEBSOCKIFY=${HERE}/websockify/run - git clone https://github.com/kanaka/websockify ${HERE}/websockify - - if [[ ! -e $WEBSOCKIFY ]]; then - echo "Unable to locate ${HERE}/websockify/run after downloading" - exit 1 - fi - - echo "Using local websockify at $WEBSOCKIFY" - else - echo "Using installed websockify at $WEBSOCKIFY" - fi -fi - echo "Starting webserver and WebSockets proxy on port ${PORT}" -#${HERE}/websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} & -${WEBSOCKIFY} --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} & +websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} & proxy_pid="$!" sleep 1 -if ! ps -p ${proxy_pid} >/dev/null; then +if [ -z "$proxy_pid" ] || ! ps -o pid= | grep -qw ${proxy_pid}; then proxy_pid= echo "Failed to start WebSockets proxy" exit 1