summaryrefslogtreecommitdiffstats
path: root/claim/netdata-claim.sh.in
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-26 18:05:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-26 18:05:42 +0000
commit112b5b91647c3dea45cc1c9bc364df526c8012f1 (patch)
tree450af925135ec664c4310a1eb28b69481094ee2a /claim/netdata-claim.sh.in
parentReleasing debian version 1.32.1-2. (diff)
downloadnetdata-112b5b91647c3dea45cc1c9bc364df526c8012f1.tar.xz
netdata-112b5b91647c3dea45cc1c9bc364df526c8012f1.zip
Merging upstream version 1.33.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'claim/netdata-claim.sh.in')
-rwxr-xr-xclaim/netdata-claim.sh.in15
1 files changed, 12 insertions, 3 deletions
diff --git a/claim/netdata-claim.sh.in b/claim/netdata-claim.sh.in
index 18813a6b..9f04de0d 100755
--- a/claim/netdata-claim.sh.in
+++ b/claim/netdata-claim.sh.in
@@ -151,7 +151,14 @@ NETDATA_USER=$(get_config_value netdata global "run as user")
gen_id() {
local id
- id="$(uuidgen)"
+ if command -v uuidgen > /dev/null 2>&1; then
+ id="$(uuidgen)"
+ elif [ -r /proc/sys/kernel/random/uuid ]; then
+ id="$(cat /proc/sys/kernel/random/uuid)"
+ else
+ echo >&2 "Unable to generate machine ID."
+ exit 18
+ fi
if [ "${id}" = "8a795b0c-2311-11e6-8563-000c295076a6" ] || [ "${id}" = "4aed1458-1c3e-11e6-a53f-000c290fc8f5" ]; then
gen_id
@@ -191,7 +198,7 @@ for arg in "$@"
do
case $arg in
-token=*) TOKEN=${arg:7} ;;
- -url=*) URL_BASE=${arg:5} ;;
+ -url=*) [ -n "${arg:5}" ] && URL_BASE=${arg:5} ;;
-id=*) ID=${arg:4} ;;
-rooms=*) ROOMS=${arg:7} ;;
-hostname=*) HOSTNAME=${arg:10} ;;
@@ -379,7 +386,9 @@ fi
if [ "${HTTP_STATUS_CODE}" = "204" ] || [ "${ERROR_KEY}" = "ErrAlreadyClaimed" ] ; then
rm -f "${CLAIMING_DIR}/tmpout.txt"
- echo -n "${ID}" >"${CLAIMING_DIR}/claimed_id" || (echo >&2 "Claiming failed"; set -e; exit 2)
+ if [ "${HTTP_STATUS_CODE}" = "204" ] ; then
+ echo -n "${ID}" >"${CLAIMING_DIR}/claimed_id" || (echo >&2 "Claiming failed"; set -e; exit 2)
+ fi
rm -f "${CLAIMING_DIR}/token" || (echo >&2 "Claiming failed"; set -e; exit 2)
# Rewrite the cloud.conf on the disk