From 9f14c47c48859c1123606b60d4fe12b818877e4f Mon Sep 17 00:00:00 2001 From: Philippe Delodder <7259755+phdelodder@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:28:09 +0100 Subject: [PATCH] Expose DECONZ_APPDATA_DIR as environment variable (#235) * Expose DECONZ_APPDATA_DIR as environment variable * Replace /opt/deCONZ everywhere with --- README.md | 1 + docker/Dockerfile | 3 ++- docker/root/start.sh | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d0bbb68..7f72eb7 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Use these environment variables to change the default behaviour of the container | `-e DECONZ_GID=1000` | Set the group id of deCONZ volume | | `-e DECONZ_START_VERBOSE=0` | Set this option to 0 to disable verbose of start script, set to 1 to enable `set -x` logging | | `-e DECONZ_BAUDRATE=115200` | Set the baudrate of the conbee stick, for conbee 3 this needs to be set | +| `-e DECONZ_APPDATA_DIR=/opt/deCONZ` | Set an alternative appdata directory incase volume bindings are not possible, eg Home Assistant OS #232 | #### Docker-Compose diff --git a/docker/Dockerfile b/docker/Dockerfile index a422c93..11f6b40 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -32,7 +32,8 @@ ENV DEBIAN_FRONTEND=noninteractive \ DECONZ_UID=1000 \ DECONZ_GID=1000 \ DECONZ_START_VERBOSE=0 \ - DECONZ_BAUDRATE=0 + DECONZ_BAUDRATE=0 \ + DECONZ_APPDATA_DIR=/opt/deCONZ # Install deCONZ dependencies RUN apt-get update && \ diff --git a/docker/root/start.sh b/docker/root/start.sh index 05f8303..75da302 100755 --- a/docker/root/start.sh +++ b/docker/root/start.sh @@ -11,7 +11,7 @@ echo "[deconzcommunity/deconz] Web UI port: $DECONZ_WEB_PORT" echo "[deconzcommunity/deconz] Websockets port: $DECONZ_WS_PORT" DECONZ_OPTS="--auto-connect=1 \ - --appdata=/opt/deCONZ \ + --appdata=$DECONZ_APPDATA_DIR \ --dbg-info=$DEBUG_INFO \ --dbg-aps=$DEBUG_APS \ --dbg-zcl=$DEBUG_ZCL \ @@ -80,13 +80,13 @@ if [ "$DECONZ_VNC_MODE" != 0 ]; then DECONZ_VNC_DISPLAY=:$(($DECONZ_VNC_PORT - 5900)) echo "[deconzcommunity/deconz] VNC port: $DECONZ_VNC_PORT" - if [ ! -e /opt/deCONZ/vnc ]; then - mkdir -p /opt/deCONZ/vnc + if [ ! -e $DECONZ_APPDATA_DIR/vnc ]; then + mkdir -p $DECONZ_APPDATA_DIR/vnc fi - ln -sfT /opt/deCONZ/vnc /home/deconz/.vnc + ln -sfT $DECONZ_APPDATA_DIR/vnc /home/deconz/.vnc chown deconz:deconz /home/deconz/.vnc - chown deconz:deconz /opt/deCONZ -R + chown deconz:deconz $DECONZ_APPDATA_DIR -R echo "[deconzcommunity/deconz] VNC DISABLE PASSWORD: $DECONZ_VNC_DISABLE_PASSWORD" if [ "$DECONZ_VNC_DISABLE_PASSWORD" = 0 ]; then @@ -95,9 +95,9 @@ if [ "$DECONZ_VNC_MODE" != 0 ]; then DECONZ_VNC_PASSWORD=$(cat $DECONZ_VNC_PASSWORD_FILE) fi - echo "$DECONZ_VNC_PASSWORD" | tigervncpasswd -f >/opt/deCONZ/vnc/passwd - chmod 600 /opt/deCONZ/vnc/passwd - chown deconz:deconz /opt/deCONZ/vnc/passwd + echo "$DECONZ_VNC_PASSWORD" | tigervncpasswd -f >$DECONZ_APPDATA_DIR/vnc/passwd + chmod 600 $DECONZ_APPDATA_DIR/vnc/passwd + chown deconz:deconz $DECONZ_APPDATA_DIR/vnc/passwd SECURITYTYPES="VncAuth,TLSVnc" else SECURITYTYPES="None,TLSNone" @@ -136,7 +136,7 @@ if [ "$DECONZ_VNC_MODE" != 0 ]; then fi # Assert valid SSL certificate - NOVNC_CERT="/opt/deCONZ/vnc/novnc.pem" + NOVNC_CERT="$DECONZ_APPDATA_DIR/vnc/novnc.pem" if [ -f "$NOVNC_CERT" ]; then openssl x509 -noout -in "$NOVNC_CERT" -checkend 0 >/dev/null if [ $? != 0 ]; then @@ -168,9 +168,9 @@ if [ "$DECONZ_UPNP" != 1 ]; then DECONZ_OPTS="$DECONZ_OPTS --upnp=0" fi -mkdir -p /opt/deCONZ/otau -ln -sfT /opt/deCONZ/otau /home/deconz/otau +mkdir -p $DECONZ_APPDATA_DIR/otau +ln -sfT $DECONZ_APPDATA_DIR/otau /home/deconz/otau chown deconz:deconz /home/deconz/otau -chown deconz:deconz /opt/deCONZ -R +chown deconz:deconz $DECONZ_APPDATA_DIR -R exec gosu deconz /usr/bin/deCONZ $DECONZ_OPTS