Add novnc support deCONZ & rework ingress (#1505)

* Add novnc support deCONZ & rework ingress

* add page

* rename index to ingress

* fix issues

* fix vnc setup

* Fix config

* fix lint

* Fix docs
This commit is contained in:
Pascal Vizeli
2020-07-28 14:01:47 +02:00
committed by GitHub
parent 5077a1f922
commit 5ec3867b18
15 changed files with 99 additions and 101 deletions

View File

@@ -90,7 +90,7 @@ function run_supervisor() {
-e SUPERVISOR_SHARE="/workspaces/test_hassio" \
-e SUPERVISOR_NAME=hassio_supervisor \
-e SUPERVISOR_DEV=1 \
-e HOMEASSISTANT_REPOSITORY="homeassistant/qemux86-64-homeassistant" \
-e SUPERVISOR_MACHINE="qemux86-64" \
homeassistant/amd64-hassio-supervisor:dev
}

View File

@@ -1,5 +1,10 @@
# Changelog
## 6.2.0
- Enable VNC per default
- Ingress entry page to select noVNC or Phoscon
## 6.1.2
- Disable default init system

View File

@@ -77,7 +77,6 @@ To enable it:
- Set a port number for VNC in the "Network" configuration section of the
add-on and hit "SAVE". Advised is to use port 5900, but any other port above
5900 works as well.
- Set a VNC password in the add-on configuration and hit "SAVE".
- Restart the add-on.
To access it, you need a [VNC Viewer][vnc-viewer] application. If you are using
@@ -138,7 +137,6 @@ Example add-on config with `dbg_aps` enabled on log level 1:
```yaml
device: /dev/ttyUSB0
vnc_password: ""
dbg_aps: 1
```

View File

@@ -23,6 +23,7 @@ RUN apt-get update \
lsof \
netcat \
nginx \
novnc \
sqlite3 \
tigervnc-common \
tigervnc-standalone-server \

View File

@@ -1,6 +1,6 @@
{
"name": "deCONZ",
"version": "6.1.2",
"version": "6.2.0",
"slug": "deconz",
"description": "Control a Zigbee network with ConBee or RaspBee by Dresden Elektronik",
"arch": ["amd64", "armhf", "aarch64"],
@@ -9,7 +9,7 @@
"boot": "auto",
"init": false,
"ingress": true,
"ingress_entry": "pwa/index.html",
"ingress_entry": "ingress.html",
"panel_icon": "mdi:zigbee",
"homeassistant": "0.91.2",
"discovery": ["deconz"],
@@ -19,7 +19,7 @@
"40850/tcp": null
},
"ports_description": {
"5900/tcp": "deCONZ graphical desktop via VNC",
"5900/tcp": "deCONZ desktop via VNC (Not required for Ingress)",
"8081/tcp": "deCONZ WebSocket (Not required for Ingress)",
"40850/tcp": "deCONZ API backend (Not required for Ingress)"
},
@@ -32,12 +32,10 @@
"devices": ["/dev/bus/usb:/dev/bus/usb:rwm", "/dev/mem:/dev/mem:rw"],
"snapshot_exclude": ["/data/otau/*"],
"options": {
"device": null,
"vnc_password": ""
"device": null
},
"schema": {
"device": "str",
"vnc_password": "str",
"dbg_aps": "int?",
"dbg_info": "int?",
"dbg_otau": "int?",

View File

@@ -0,0 +1,7 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Setup noVNC
# ==============================================================================
declare ingress_entry
ingress_entry=$(bashio::addon.ingress_entry)
sed -i "s#websockify#${ingress_entry#?}/novnc/websockify#g" /usr/share/novnc/vnc_lite.html

View File

@@ -1,19 +0,0 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Configure VNC for use with deCONZ
# ==============================================================================
# Check if VNC is enabled
VNC_PORT="$(bashio::addon.port 5900)"
if ! bashio::var.has_value "${VNC_PORT}"; then
# VNC is not enabled, skip this.
bashio::exit.ok
fi
# Require password when VNC is enabled
if ! bashio::config.has_value 'vnc_password'; then
bashio::exit.nok "VNC has been enabled, but no password has been set!"
fi
VNC_PASSWORD=$(bashio::config 'vnc_password')
echo "${VNC_PASSWORD}" | tigervncpasswd -f > /root/.vncpasswd

View File

@@ -43,6 +43,19 @@ http {
proxy_set_header Connection $connection_upgrade;
}
location /novnc {
proxy_pass http://127.0.0.1:5901/;
proxy_redirect default;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location =/ingress.html {
root /usr/share/www/;
}
location / {
proxy_pass http://127.0.0.1:40850;
proxy_redirect default;

View File

@@ -2,13 +2,15 @@
# ==============================================================================
# Start deCONZ service
# ==============================================================================
TMP_FOLDER=$(mktemp -d)
# Lookup udev link
bashio::log.info "Waiting for device..."
DECONZ_DEVICE=$(bashio::config 'device')
if [[ -c "${DECONZ_DEVICE}" ]]; then
bashio::log.debug "Specified device points to a character special file, continuing"
else
bashio::log.info "Waiting for device..."
# 180 second timeout to wait for udev to finish processing
timeout=180
while [[ ! -L "${DECONZ_DEVICE}" ]]; do
@@ -23,6 +25,45 @@ else
bashio::log.debug "Found device! Location: ${DECONZ_DEVICE}"
fi
# VNC is not enabled as a seperate service, as it cannot handle multiple
# session when running in the foreground.
VNC_PORT="$(bashio::addon.port 5900)"
ARCH="$(bashio::info.arch)"
# Fix tigervnc for 32 bits ARM
if [[ "armhf armv7" = *"${ARCH}"* ]]; then
export LD_PRELOAD=/lib/arm-linux-gnueabihf/libgcc_s.so.1
fi
# Fix tigervnc for 64 bits ARM
if [[ "aarch64" = "${ARCH}" ]]; then
export LD_PRELOAD=/lib/aarch64-linux-gnu/libgcc_s.so.1
fi
# Run it only on localhost if not expose
if bashio::var.has_value "${VNC_PORT}"; then
LOCAL_ONLY=no
else
LOCAL_ONLY=yes
fi
export XDG_RUNTIME_DIR="${TMP_FOLDER}"
export DISPLAY=":0"
bashio::log.info "Starting VNC server (local/${LOCAL_ONLY})..."
tigervncserver \
-name "Home Assistant - deCONZ" \
-geometry 1920x1080 \
-depth 16 \
-localhost ${LOCAL_ONLY} \
-SecurityTypes None \
"${DISPLAY}" \
&> /dev/null
# Wait for VNC server to start before continuing
bashio::log.info "deCONZ waiting for VNC to start"
bashio::net.wait_for 5900
# Load debug values
bashio::config.has_value 'dbg_info' \
&& DBG_INFO="$(bashio::config 'dbg_info')" || DBG_INFO=1
@@ -35,52 +76,13 @@ bashio::config.has_value 'dbg_zcl' \
bashio::config.has_value 'dbg_zdp' \
&& DBG_ZDP="$(bashio::config 'dbg_zdp')" || DBG_ZDP=0
# Check if VNC is enabled
# VNC is not enabled as a seperate service, as it cannot handle multiple
# session when running in the foreground.
PLATFORM="minimal"
VNC_PORT="$(bashio::addon.port 5900)"
if bashio::var.has_value "${VNC_PORT}"; then
ARCH="$(bashio::info.arch)"
TMP_FOLDER=$(mktemp -d)
export XDG_RUNTIME_DIR="${TMP_FOLDER}"
export DISPLAY=":0"
PLATFORM="xcb"
# Fix tigervnc for 32 bits ARM
if [[ "armhf armv7" = *"${ARCH}"* ]]; then
export LD_PRELOAD=/lib/arm-linux-gnueabihf/libgcc_s.so.1
fi
# Fix tigervnc for 64 bits ARM
if [[ "aarch64" = "${ARCH}" ]]; then
export LD_PRELOAD=/lib/aarch64-linux-gnu/libgcc_s.so.1
fi
bashio::log.info "Starting VNC server..."
tigervncserver \
-name "Home Assistant - deCONZ" \
-geometry 1920x1080 \
-depth 16 \
-localhost no \
-PasswordFile /root/.vncpasswd \
"${DISPLAY}" \
&> /dev/null
# Wait for VNC server to start before continuing
bashio::log.info "Waiting for VNC to start"
bashio::net.wait_for "${VNC_PORT}"
fi
# Send out discovery information to Home Assistant
./discovery &
# Start deCONZ
bashio::log.info "Starting the deCONZ gateway..."
exec deCONZ \
-platform "${PLATFORM}" \
-platform "xcb" \
--auto-connect=1 \
--dbg-info="${DBG_INFO}" \
--dbg-aps="${DBG_APS}" \

View File

@@ -1,8 +0,0 @@
#!/usr/bin/execlineb -S1
# ==============================================================================
# Take down the S6 supervision tree based on service exit code
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View File

@@ -1,8 +0,0 @@
#!/usr/bin/execlineb -S1
# ==============================================================================
# Take down the S6 supervision tree based on service exit code
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View File

@@ -1,8 +0,0 @@
#!/usr/bin/execlineb -S1
# ==============================================================================
# Take down the S6 supervision tree based on service exit code
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View File

@@ -1,8 +0,0 @@
#!/usr/bin/execlineb -S1
# ==============================================================================
# Take down the S6 supervision tree based on service exit code
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View File

@@ -0,0 +1,11 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start ozw-admin
# ==============================================================================
# Wait until ozwadmin is up and running
bashio::log.info "Websockify waiting for VNC to start"
bashio::net.wait_for 5900
bashio::log.info "Starting websockify..."
exec websockify -v --web /usr/share/novnc/ 127.0.0.1:5901 127.0.0.1:5900

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<body>
<h2>Zigbee network by Dresden Elektronik</h2>
<p>You can use the webui Phoscon or the VNC based deCONZ</p>
<div>
<a href="pwa/index.html">Phoscon</a></br>
<a href="novnc/vnc_lite.html">deCONZ</a>
</div>
</body>
</html>