From cc821dec0c6dedac16f806cc4a880ce31b549038 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 10 Jul 2014 20:10:10 +0100 Subject: [PATCH] Fix permissions issue with data dir If the mounted data directory on the host is owned by root, the znc user within the container would fail to write any settings to disk. Hence this changes ownership of the data directory to the znc user (Uid: 1000) and znc group (Gid: 1000) from within the container. --- Dockerfile | 1 - bootstrap.sh | 7 ++++++- start-znc | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f76350e..0cf0cca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,6 @@ ADD start-znc /usr/local/bin/ ADD znc.conf.default /src/ RUN chmod 644 /src/znc.conf.default -USER znc EXPOSE 6667 ENTRYPOINT ["/usr/local/bin/start-znc"] CMD [""] diff --git a/bootstrap.sh b/bootstrap.sh index dea3615..9c95b88 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -6,8 +6,13 @@ set -e ZNC_VERSION="1.4" -# Install build dependencies. +# Ensure package list is up to date. apt-get update + +# Install runtime dependencies. +apt-get install -y sudo + +# Install build dependencies. apt-get install -y wget build-essential libssl-dev libperl-dev pkg-config diff --git a/start-znc b/start-znc index 45f0fff..b35a6bd 100755 --- a/start-znc +++ b/start-znc @@ -27,5 +27,9 @@ if [ ! -f "${DATADIR}/configs/znc.conf" ]; then cp /src/znc.conf.default "${DATADIR}/configs/znc.conf" fi +# Make sure $DATADIR is owned by znc user. This effects ownership of the +# mounted directory on the host machine too. +chown -R znc:znc "$DATADIR" + # Start ZNC. -exec znc --foreground --datadir="$DATADIR" $@ +exec sudo -u znc znc --foreground --datadir="$DATADIR" $@