summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOdysseas Lamtzidis <odyslam@gmail.com>2021-07-13 16:00:30 +0300
committerGitHub <noreply@github.com>2021-07-13 16:00:30 +0300
commit7b24b12a15e57c06fbed1d5538e16ce163e92e77 (patch)
tree53c4ccd6e4bd453febf3b9f575be54a4bb869f0b
parentc9a5e22f1b61f1d05448f4a7596ab1932a98c450 (diff)
Auto-detect PGID in Dockerfile's ENTRYPOINT script (#11274)
* initial commit for balena, docker * chage else if to elif
-rwxr-xr-xpackaging/docker/run.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/packaging/docker/run.sh b/packaging/docker/run.sh
index c04be9ff8c..3f05a1708d 100755
--- a/packaging/docker/run.sh
+++ b/packaging/docker/run.sh
@@ -13,6 +13,23 @@ if [ ! "${DO_NOT_TRACK:-0}" -eq 0 ] || [ -n "$DO_NOT_TRACK" ]; then
touch /etc/netdata/.opt-out-from-anonymous-statistics
fi
+
+BALENA_PGID=$(ls -nd /var/run/balena.sock | awk '{print $4}')
+DOCKER_PGID=$(ls -nd /var/run/docker.sock | awk '{print $4}')
+
+re='^[0-9]+$'
+if [[ $BALENA_PGID =~ $re ]]; then
+ echo "Netdata detected balena-engine.sock"
+ DOCKER_HOST='/var/run/balena-engine.sock'
+ PGID="$BALENA_PGID"
+elif [[ $DOCKER_PGID =~ $re ]]; then
+ echo "Netdata detected docker.sock"
+ DOCKER_HOST="/var/run/docker.sock"
+ PGID=$(ls -nd /var/run/docker.sock | awk '{print $4}')
+fi
+export PGID
+export DOCKER_HOST
+
if [ -n "${PGID}" ]; then
echo "Creating docker group ${PGID}"
addgroup -g "${PGID}" "docker" || echo >&2 "Could not add group docker with ID ${PGID}, its already there probably"