diff --git a/d42-agent-remote/Dockerfile b/d42-agent-remote/Dockerfile index 50e9aac..93aad36 100644 --- a/d42-agent-remote/Dockerfile +++ b/d42-agent-remote/Dockerfile @@ -7,6 +7,8 @@ RUN unzip d42-agent-remote.zip RUN chmod +x d42-agent-remote/d42_autodisc_linux_x64 FROM debian:buster +COPY entrypoint.sh /entrypoint.sh COPY --from=builder d42-agent-remote/d42_autodisc_linux_x64 /usr/local/bin/d42_autodisc_linux_x64 -ENTRYPOINT ["/usr/local/bin/d42_autodisc_linux_x64", "-config", "/etc/device42/inventory.cfg"] +WORKDIR /etc/device42 +ENTRYPOINT ["/entrypoint.sh"] diff --git a/d42-agent-remote/entrypoint.sh b/d42-agent-remote/entrypoint.sh new file mode 100755 index 0000000..f73e299 --- /dev/null +++ b/d42-agent-remote/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -xe + +BUILD_MODIFY_TIME=$(stat -c %y /usr/local/bin/d42_autodisc_linux_x64) +/usr/local/bin/d42_autodisc_linux_x64 + +# NOTE(mnaser): If Device42 self-updates, it restarts itself but the problem +# with this is that in a containerized environment, we will be +# in an update loop. +NEW_MODIFY_TIME=$(stat -c %y /usr/local/bin/d42_autodisc_linux_x64) +if [ "$BUILD_MODIFY_TIME" != "$NEW_MODIFY_TIME" ]; then + /usr/local/bin/d42_autodisc_linux_x64 +fi +