Better handle creation of UUID for claiming. (#11974)
* Properly check for the availability of `uuidgen` before blindly using it. * Fall back on Linux to the kernel-provided interface for generating UUIDs if `uuidgen` is not present. * Provide a more useful error message if we can’t use either option.
Austin S. Hemmelgarn committed
Jan 14, 2022 at 10:36 UTC
3f06aa65ae56a78ba810d1b10d064be5c5100ed5
1 file changed
+8
-1
claim/netdata-claim.sh.in
+8
-1
@@ -151,7 +151,14 @@ NETDATA_USER=$(get_config_value netdata global "run as user")
151
gen_id() {
152
local id
153
154
- id="$(uuidgen)"
154
+ if command -v uuidgen > /dev/null 2>&1; then
155
+ id="$(uuidgen)"
156
+ elif [ -r /proc/sys/kernel/random/uuid ]; then
157
+ id="$(cat /proc/sys/kernel/random/uuid)"
158
+ else
159
+ echo >&2 "Unable to generate machine ID."
160
+ exit 18
161
+ fi
162
163
if [ "${id}" = "8a795b0c-2311-11e6-8563-000c295076a6" ] || [ "${id}" = "4aed1458-1c3e-11e6-a53f-000c290fc8f5" ]; then
164
gen_id