From 1e91270c0f053de36a5dcce104ac9406dff4feeb Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Mon, 25 May 2026 07:01:44 -0700 Subject: [PATCH] Move non-LSIO currentOsVariantOverride to entrypoint.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copilot review on PR #381 caught that the non-LSIO build-time RUN is hidden by the README's recommended bind-mount of /opt/${COMPANY_NAME}/mediaserver/etc — the host's empty etc directory shadows the image's pre-edited mediaserver.conf at runtime. Mirrors the LSIO fix from #380: drop the build-time RUN and inject idempotently at runtime via Docker/entrypoint.sh before exec'ing mediaserver. Both variants now follow the same pattern (LSIO does it in init-nx-relocate; non-LSIO does it in entrypoint.sh). --- CreateMatrix/Dockerfile.cs | 8 ++++---- Docker/DWSpectrum.Dockerfile | 4 ---- Docker/NxGo.Dockerfile | 4 ---- Docker/NxMeta.Dockerfile | 4 ---- Docker/NxWitness.Dockerfile | 4 ---- Docker/WisenetWAVE.Dockerfile | 4 ---- Docker/entrypoint.sh | 12 ++++++++++++ 7 files changed, 16 insertions(+), 24 deletions(-) diff --git a/CreateMatrix/Dockerfile.cs b/CreateMatrix/Dockerfile.cs index 2035c556..57a23a60 100644 --- a/CreateMatrix/Dockerfile.cs +++ b/CreateMatrix/Dockerfile.cs @@ -316,11 +316,11 @@ RUN apt-get update \ # Only allow sudo no password access to the root-tool RUN echo "${COMPANY_NAME} ALL = NOPASSWD: /opt/${COMPANY_NAME}/mediaserver/bin/root-tool" > /etc/sudoers.d/${COMPANY_NAME} - # Tell mediaserver it is running under Docker so it reports its OS variant correctly - # https://github.com/networkoptix/nxvms-docker/commit/54bbd16 - RUN echo "currentOsVariantOverride=docker" >> /opt/${COMPANY_NAME}/mediaserver/etc/mediaserver.conf - """; + // Note: for non-LSIO, currentOsVariantOverride=docker is injected at runtime by + // Docker/entrypoint.sh, because the recommended non-LSIO setup bind-mounts + // /opt/${COMPANY_NAME}/mediaserver/etc from the host, which would hide any + // build-time edit. Both variants now use runtime injection for the same reason. } return install; diff --git a/Docker/DWSpectrum.Dockerfile b/Docker/DWSpectrum.Dockerfile index a3b72c17..52d66c8e 100644 --- a/Docker/DWSpectrum.Dockerfile +++ b/Docker/DWSpectrum.Dockerfile @@ -101,10 +101,6 @@ RUN apt-get update \ # Only allow sudo no password access to the root-tool RUN echo "${COMPANY_NAME} ALL = NOPASSWD: /opt/${COMPANY_NAME}/mediaserver/bin/root-tool" > /etc/sudoers.d/${COMPANY_NAME} -# Tell mediaserver it is running under Docker so it reports its OS variant correctly -# https://github.com/networkoptix/nxvms-docker/commit/54bbd16 -RUN echo "currentOsVariantOverride=docker" >> /opt/${COMPANY_NAME}/mediaserver/etc/mediaserver.conf - # Copy the entrypoint.sh launch script # entrypoint.sh will run the mediaserver and root-tool COPY entrypoint.sh /opt/entrypoint.sh diff --git a/Docker/NxGo.Dockerfile b/Docker/NxGo.Dockerfile index e637fb49..c77be6a1 100644 --- a/Docker/NxGo.Dockerfile +++ b/Docker/NxGo.Dockerfile @@ -101,10 +101,6 @@ RUN apt-get update \ # Only allow sudo no password access to the root-tool RUN echo "${COMPANY_NAME} ALL = NOPASSWD: /opt/${COMPANY_NAME}/mediaserver/bin/root-tool" > /etc/sudoers.d/${COMPANY_NAME} -# Tell mediaserver it is running under Docker so it reports its OS variant correctly -# https://github.com/networkoptix/nxvms-docker/commit/54bbd16 -RUN echo "currentOsVariantOverride=docker" >> /opt/${COMPANY_NAME}/mediaserver/etc/mediaserver.conf - # Copy the entrypoint.sh launch script # entrypoint.sh will run the mediaserver and root-tool COPY entrypoint.sh /opt/entrypoint.sh diff --git a/Docker/NxMeta.Dockerfile b/Docker/NxMeta.Dockerfile index b52ae321..d827fa6c 100644 --- a/Docker/NxMeta.Dockerfile +++ b/Docker/NxMeta.Dockerfile @@ -101,10 +101,6 @@ RUN apt-get update \ # Only allow sudo no password access to the root-tool RUN echo "${COMPANY_NAME} ALL = NOPASSWD: /opt/${COMPANY_NAME}/mediaserver/bin/root-tool" > /etc/sudoers.d/${COMPANY_NAME} -# Tell mediaserver it is running under Docker so it reports its OS variant correctly -# https://github.com/networkoptix/nxvms-docker/commit/54bbd16 -RUN echo "currentOsVariantOverride=docker" >> /opt/${COMPANY_NAME}/mediaserver/etc/mediaserver.conf - # Copy the entrypoint.sh launch script # entrypoint.sh will run the mediaserver and root-tool COPY entrypoint.sh /opt/entrypoint.sh diff --git a/Docker/NxWitness.Dockerfile b/Docker/NxWitness.Dockerfile index deba664d..f46374bc 100644 --- a/Docker/NxWitness.Dockerfile +++ b/Docker/NxWitness.Dockerfile @@ -101,10 +101,6 @@ RUN apt-get update \ # Only allow sudo no password access to the root-tool RUN echo "${COMPANY_NAME} ALL = NOPASSWD: /opt/${COMPANY_NAME}/mediaserver/bin/root-tool" > /etc/sudoers.d/${COMPANY_NAME} -# Tell mediaserver it is running under Docker so it reports its OS variant correctly -# https://github.com/networkoptix/nxvms-docker/commit/54bbd16 -RUN echo "currentOsVariantOverride=docker" >> /opt/${COMPANY_NAME}/mediaserver/etc/mediaserver.conf - # Copy the entrypoint.sh launch script # entrypoint.sh will run the mediaserver and root-tool COPY entrypoint.sh /opt/entrypoint.sh diff --git a/Docker/WisenetWAVE.Dockerfile b/Docker/WisenetWAVE.Dockerfile index ce2006d9..5c6c7bbb 100644 --- a/Docker/WisenetWAVE.Dockerfile +++ b/Docker/WisenetWAVE.Dockerfile @@ -101,10 +101,6 @@ RUN apt-get update \ # Only allow sudo no password access to the root-tool RUN echo "${COMPANY_NAME} ALL = NOPASSWD: /opt/${COMPANY_NAME}/mediaserver/bin/root-tool" > /etc/sudoers.d/${COMPANY_NAME} -# Tell mediaserver it is running under Docker so it reports its OS variant correctly -# https://github.com/networkoptix/nxvms-docker/commit/54bbd16 -RUN echo "currentOsVariantOverride=docker" >> /opt/${COMPANY_NAME}/mediaserver/etc/mediaserver.conf - # Copy the entrypoint.sh launch script # entrypoint.sh will run the mediaserver and root-tool COPY entrypoint.sh /opt/entrypoint.sh diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.sh index 90825e32..c3dea33c 100755 --- a/Docker/entrypoint.sh +++ b/Docker/entrypoint.sh @@ -4,6 +4,18 @@ echo "Launching root-tool" sudo /opt/${COMPANY_NAME}/mediaserver/bin/root-tool & +# Tell mediaserver it is running under Docker so it reports its OS variant correctly +# https://github.com/networkoptix/nxvms-docker/commit/54bbd16 +# Inject at runtime rather than build time because the recommended non-LSIO setup +# bind-mounts /opt/${COMPANY_NAME}/mediaserver/etc from the host, which hides any +# build-time edit. Idempotent so subsequent starts don't duplicate the line. +MEDIASERVER_CONF="/opt/${COMPANY_NAME}/mediaserver/etc/mediaserver.conf" +if ! grep -q "^currentOsVariantOverride=docker" "${MEDIASERVER_CONF}" 2>/dev/null +then + echo "Adding currentOsVariantOverride=docker to ${MEDIASERVER_CONF}" + echo "currentOsVariantOverride=docker" >> "${MEDIASERVER_CONF}" +fi + # Launch the mediaserver using exec so it receives shutdown commands echo "Launching mediaserver" exec /opt/${COMPANY_NAME}/mediaserver/bin/mediaserver -e