summaryrefslogtreecommitdiffstats
path: root/packaging/docker/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/docker/run.sh')
-rwxr-xr-xpackaging/docker/run.sh26
1 files changed, 20 insertions, 6 deletions
diff --git a/packaging/docker/run.sh b/packaging/docker/run.sh
index 3f05a1708..1e001256c 100755
--- a/packaging/docker/run.sh
+++ b/packaging/docker/run.sh
@@ -9,13 +9,20 @@
# Author : Austin S. Hemmelgarn <austin@netdata.cloud>
set -e
-if [ ! "${DO_NOT_TRACK:-0}" -eq 0 ] || [ -n "$DO_NOT_TRACK" ]; then
- touch /etc/netdata/.opt-out-from-anonymous-statistics
+if [ ! -w / ] && [ "${EUID}" -eq 0 ]; then
+ echo >&2 "WARNING: This Docker host appears to not properly support newer stat system calls. This is known to cause issues with Netdata (most notably, nodes running on such hosts **cannot be claimed**)."
+ echo >&2 "WARNING: For more information, see https://learn.netdata.cloud/docs/agent/claim#known-issues-on-older-hosts-with-seccomp-enabled"
fi
+if [ ! "${DISABLE_TELEMETRY:-0}" -eq 0 ] ||
+ [ -n "$DISABLE_TELEMETRY" ] ||
+ [ ! "${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}')
+BALENA_PGID=$(stat -c %g /var/run/balena.sock 2>/dev/null || true)
+DOCKER_PGID=$(stat -c %g /var/run/docker.sock 2>/dev/null || true)
re='^[0-9]+$'
if [[ $BALENA_PGID =~ $re ]]; then
@@ -25,7 +32,7 @@ if [[ $BALENA_PGID =~ $re ]]; then
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}')
+ PGID="$DOCKER_PGID"
fi
export PGID
export DOCKER_HOST
@@ -37,12 +44,19 @@ if [ -n "${PGID}" ]; then
usermod -a -G "${PGID}" "${DOCKER_USR}" || echo >&2 "Could not add netdata user to group docker with ID ${PGID}"
fi
+if mountpoint -q /etc/netdata && [ -z "$(ls -A /etc/netdata)" ]; then
+ echo "Copying stock configuration to /etc/netdata"
+ cp -a /etc/netdata.stock/. /etc/netdata
+fi
+
if [ -n "${NETDATA_CLAIM_URL}" ] && [ -n "${NETDATA_CLAIM_TOKEN}" ] && [ ! -f /var/lib/netdata/cloud.d/claimed_id ]; then
+ # shellcheck disable=SC2086
/usr/sbin/netdata-claim.sh -token="${NETDATA_CLAIM_TOKEN}" \
-url="${NETDATA_CLAIM_URL}" \
${NETDATA_CLAIM_ROOMS:+-rooms="${NETDATA_CLAIM_ROOMS}"} \
${NETDATA_CLAIM_PROXY:+-proxy="${NETDATA_CLAIM_PROXY}"} \
+ ${NETDATA_EXTRA_CLAIM_OPTS} \
-daemon-not-running
fi
-exec /usr/sbin/netdata -u "${DOCKER_USR}" -D -s /host -p "${NETDATA_LISTENER_PORT}" -W set web "web files group" root -W set web "web files owner" root "$@"
+exec /usr/sbin/netdata -u "${DOCKER_USR}" -D -s /host -p "${NETDATA_LISTENER_PORT}" "$@"