feat: refactor and allow running in background
This commit is contained in:
parent
5a330e60d6
commit
d98d8500ae
29
start.sh
29
start.sh
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
# export FORCE_REINSTALL_TURBOVNC=1 to reinstall turbovnc to the latest version
|
||||
# Sample usage: RUN_IN_BACKGROUND=1 ./start.sh
|
||||
# set FORCE_REINSTALL_TURBOVNC=1 to reinstall turbovnc to the latest version
|
||||
# set RUN_IN_BACKGROUND=1 to start proxy and vnc client in background
|
||||
|
||||
set -e
|
||||
|
||||
|
|
@ -9,6 +11,7 @@ cd "$SCRIPT_DIR"
|
|||
. ./utils/shell-logger
|
||||
|
||||
hasUpdated=0
|
||||
NOVNC_PORT=6080
|
||||
|
||||
# desktop environment installation
|
||||
if ! dpkg-query -W -f='${Status}' xfce4 2>/dev/null | grep -q "install ok installed"; then
|
||||
|
|
@ -44,21 +47,35 @@ startxfce4 &
|
|||
EOF
|
||||
|
||||
display=$(/opt/TurboVNC/bin/vncserver -list | grep -E "^:" | awk '{print $1}')
|
||||
displayNumber=${display/:}
|
||||
info "previous display number $displayNumber"
|
||||
|
||||
if [ ! -z $display ]; then
|
||||
info "restarting vnc server on display $display"
|
||||
/opt/TurboVNC/bin/vncserver -kill $display
|
||||
else
|
||||
info "no display found"
|
||||
fi
|
||||
/opt/TurboVNC/bin/vncserver -localhost -depth 24 -geometry 3440x1440
|
||||
display=$(/opt/TurboVNC/bin/vncserver -list | grep -E "^:" | awk '{print $1}')
|
||||
displayNumber=${display/:}
|
||||
displayPort=$((5900+$displayNumber))
|
||||
info "display number $displayNumber, display port $displayPort"
|
||||
|
||||
cd utils
|
||||
|
||||
# Start noVNC
|
||||
info "starting vnc client and forwarder"
|
||||
if lsof -t -i:6080; then
|
||||
kill -9 $(lsof -t -i:6080)
|
||||
if lsof -t -i:$NOVNC_PORT>/dev/null; then
|
||||
info "previous novnc client detected, killing process now"
|
||||
kill -9 $(lsof -t -i:$NOVNC_PORT)
|
||||
fi
|
||||
|
||||
echo "6080-$WEB_HOST:80"
|
||||
|
||||
./novnc_proxy --vnc localhost:5901
|
||||
if [ ! -z $RUN_IN_BACKGROUND ]; then
|
||||
info "running novnc proxy in background"
|
||||
mkdir -p ~/logs
|
||||
./novnc_proxy --vnc localhost:$displayPort &> ~/logs/novnc.log &
|
||||
printf "\nNavigate to this URL:\n\n$NOVNC_PORT-$WEB_HOST/vnc.html\n"
|
||||
else
|
||||
./novnc_proxy --vnc localhost:$displayPort
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue