Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First try at making non root compatible #257

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Use these environment variables to change the default behaviour of the container
| `-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 |
| `-e NON_ROOT=0 | Set this option to 1 to enable NON ROOT exectution of deconz
|

#### Docker-Compose

Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:12.2-slim
FROM debian:12.6-slim

# Build arguments
ARG VERSION
Expand Down Expand Up @@ -34,7 +34,8 @@ ENV DEBIAN_FRONTEND=noninteractive \
DECONZ_GID=1000 \
DECONZ_START_VERBOSE=0 \
DECONZ_BAUDRATE=0 \
DECONZ_APPDATA_DIR=/opt/deCONZ
DECONZ_APPDATA_DIR=/opt/deCONZ \
NON_ROOT=0

# Install deCONZ dependencies
RUN apt-get update && \
Expand Down
16 changes: 11 additions & 5 deletions docker/root/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ DECONZ_OPTS="--auto-connect=1 \
--http-port=$DECONZ_WEB_PORT \
--ws-port=$DECONZ_WS_PORT"

if [ "$NON_ROOT" = 0 ]; then
GOSU="gosu deconz"
else
GOSU=""
fi

if [ "$DECONZ_BAUDRATE" != 0 ]; then
DECONZ_OPTS="$DECONZ_OPTS --baudrate=$DECONZ_BAUDRATE"
fi
Expand Down Expand Up @@ -114,16 +120,16 @@ if [ "$DECONZ_VNC_MODE" != 0 ]; then
fi

# Cleanup previous VNC session data
gosu deconz tigervncserver -kill ':*'
gosu deconz tigervncserver -list ':*' -cleanstale
$GOSU tigervncserver -kill ':*'
$GOSU tigervncserver -list ':*' -cleanstale
for lock in "/tmp/.X${DECONZ_VNC_DISPLAY#:}-lock" "/tmp/.X11-unix/X${DECONZ_VNC_DISPLAY#:}"; do
[ -e "$lock" ] || continue
echo "[deconzcommunity/deconz] WARN - VNC-lock found. Deleting: $lock"
rm "$lock"
done

# Set VNC security
gosu deconz tigervncserver -SecurityTypes "$SECURITYTYPES" "$DECONZ_VNC_DISPLAY"
$GOSU tigervncserver -SecurityTypes "$SECURITYTYPES" "$DECONZ_VNC_DISPLAY"

# Export VNC display variable
export DISPLAY=$DECONZ_VNC_DISPLAY
Expand Down Expand Up @@ -152,7 +158,7 @@ if [ "$DECONZ_VNC_MODE" != 0 ]; then
chown deconz:deconz $NOVNC_CERT

#Start noVNC
gosu deconz websockify -D --web=/usr/share/novnc/ --cert="$NOVNC_CERT" $DECONZ_NOVNC_PORT localhost:$DECONZ_VNC_PORT
$GOSU websockify -D --web=/usr/share/novnc/ --cert="$NOVNC_CERT" $DECONZ_NOVNC_PORT localhost:$DECONZ_VNC_PORT
echo "[deconzcommunity/deconz] NOVNC port: $DECONZ_NOVNC_PORT"
fi

Expand All @@ -174,4 +180,4 @@ ln -sfT $DECONZ_APPDATA_DIR/otau /home/deconz/otau
chown deconz:deconz /home/deconz/otau
chown deconz:deconz $DECONZ_APPDATA_DIR -R

exec gosu deconz /usr/bin/deCONZ $DECONZ_OPTS
exec $GOSU /usr/bin/deCONZ $DECONZ_OPTS
Loading