Auto-detect PGID in Dockerfile's ENTRYPOINT script (#11274)
* initial commit for balena, docker * chage else if to elif
Odysseas Lamtzidis committed
Jul 13, 2021 at 16:00 UTC
7b24b12a15e57c06fbed1d5538e16ce163e92e77
1 file changed
+17
packaging/docker/run.sh
+17
@@ -13,6 +13,23 @@ if [ ! "${DO_NOT_TRACK:-0}" -eq 0 ] || [ -n "$DO_NOT_TRACK" ]; then
13
touch /etc/netdata/.opt-out-from-anonymous-statistics
14
fi
15
16
+
17
+BALENA_PGID=$(ls -nd /var/run/balena.sock | awk '{print $4}')
18
+DOCKER_PGID=$(ls -nd /var/run/docker.sock | awk '{print $4}')
19
+
20
+re='^[0-9]+$'
21
+if [[ $BALENA_PGID =~ $re ]]; then
22
+ echo "Netdata detected balena-engine.sock"
23
+ DOCKER_HOST='/var/run/balena-engine.sock'
24
+ PGID="$BALENA_PGID"
25
+elif [[ $DOCKER_PGID =~ $re ]]; then
26
+ echo "Netdata detected docker.sock"
27
+ DOCKER_HOST="/var/run/docker.sock"
28
+ PGID=$(ls -nd /var/run/docker.sock | awk '{print $4}')
29
+fi
30
+export PGID
31
+export DOCKER_HOST
32
+
33
if [ -n "${PGID}" ]; then
34
echo "Creating docker group ${PGID}"
35
addgroup -g "${PGID}" "docker" || echo >&2 "Could not add group docker with ID ${PGID}, its already there probably"