16
# --local-files set the full path of the desired tarball to run install with
17
# --allow-duplicate-install do not bail if we detect a duplicate install
18
# --reinstall if an existing install would be updated, reinstall instead
19
+# --claim-token specify a token to use for claiming the newly installed instance
20
+# --claim-url specify a URL to use for claiming the newly installed isntance
21
+# --claim-rooms specify a list of rooms to claim the newly installed instance to
22
+# --claim-proxy specify a proxy to use while claiming the newly installed instance
23
#
24
# Environment options:
25
#
321
NETDATA_UPDATES="--auto-update"
322
RELEASE_CHANNEL="nightly"
323
while [ -n "${1}" ]; do
320
- if [ "${1}" = "all" ]; then
321
- PACKAGES_INSTALLER_OPTIONS="netdata-all"
322
- shift 1
323
- elif [ "${1}" = "--dont-wait" ] || [ "${1}" = "--non-interactive" ]; then
324
- INTERACTIVE=0
325
- shift 1
326
- elif [ "${1}" = "--no-updates" ]; then
327
- # echo >&2 "netdata will not auto-update"
328
- NETDATA_UPDATES=
329
- shift 1
330
- elif [ "${1}" = "--stable-channel" ]; then
331
- RELEASE_CHANNEL="stable"
332
- NETDATA_INSTALLER_OPTIONS="$NETDATA_INSTALLER_OPTIONS --stable-channel"
333
- shift 1
334
- elif [ "${1}" = "--allow-duplicate-install" ]; then
335
- NETDATA_ALLOW_DUPLICATE_INSTALL=1
336
- shift 1
337
- elif [ "${1}" = "--reinstall" ]; then
338
- NETDATA_REINSTALL=1
339
- shift 1
340
- elif [ "${1}" = "--local-files" ]; then
341
- shift 1
342
- if [ -z "${1}" ]; then
343
- fatal "Missing netdata: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
344
- fi
324
+ case "${1}" in
325
+ "all") PACKAGES_INSTALLER_OPTIONS="netdata-all" ;;
326
+ "--dont-wait") INTERACTIVE=0 ;;
327
+ "--non-interactive") INTERACTIVE=0 ;;
328
+ "--no-updates") NETDATA_UPDATES= ;;
329
+ "--stable-channel")
330
+ RELEASE_CHANNEL="stable"
331
+ NETDATA_INSTALLER_OPTIONS="$NETDATA_INSTALLER_OPTIONS --stable-channel"
332
+ ;;
333
+ "--allow-duplicate-install") NETDATA_ALLOW_DUPLICATE_INSTALL=1 ;;
334
+ "--reinstall") NETDATA_REINSTALL=1 ;;
335
+ "--claim-token")
336
+ NETDATA_CLAIM_TOKEN="${2}"
337
+ shift 1
338
+ ;;
339
+ "--claim-rooms")
340
+ NETDATA_CLAIM_ROOMS="${2}"
341
+ shift 1
342
+ ;;
343
+ "--claim-url")
344
+ NETDATA_CLAIM_URL="${2}"
345
+ shift 1
346
+ ;;
347
+ "--claim-proxy")
348
+ NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -proxy ${2}"
349
+ shift 1
350
+ ;;
351
+ "--dont-start-it")
352
+ NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -daemon-not-running"
353
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --dont-start-it"
354
+ ;;
355
+ "--install")
356
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install ${2}"
357
+ NETDATA_PREFIX="${2}"
358
+ shift 1
359
+ ;;
360
+ "--disable-cloud")
361
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --disable-cloud"
362
+ NETDATA_DISABLE_CLOUD=1
363
+ ;;
364
+ "--local-files")
365
+ if [ -z "${2}" ]; then
366
+ fatal "Missing netdata: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
367
+ fi
368
346
- export NETDATA_LOCAL_TARBALL_OVERRIDE="${1}"
347
- shift 1
369
+ export NETDATA_LOCAL_TARBALL_OVERRIDE="${2}"
370
349
- if [ -z "${1}" ]; then
350
- fatal "Missing checksum file: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
351
- fi
371
+ if [ -z "${3}" ]; then
372
+ fatal "Missing checksum file: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
373
+ fi
374
353
- export NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM="${1}"
354
- shift 1
375
+ export NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM="${3}"
376
356
- if [ -z "${1}" ]; then
357
- fatal "Missing go.d tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
358
- fi
377
+ if [ -z "${4}" ]; then
378
+ fatal "Missing go.d tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
379
+ fi
380
360
- export NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN="${1}"
361
- shift 1
381
+ export NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN="${4}"
382
363
- if [ -z "${1}" ]; then
364
- fatal "Missing go.d config tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
365
- fi
383
+ if [ -z "${5}" ]; then
384
+ fatal "Missing go.d config tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
385
+ fi
386
367
- export NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG="${1}"
368
- shift 1
387
+ export NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG="${5}"
388
370
- if [ -z "${1}" ]; then
371
- fatal "Missing dependencies management scriptlet: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
372
- fi
389
+ if [ -z "${6}" ]; then
390
+ fatal "Missing dependencies management scriptlet: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order"
391
+ fi
392
374
- export NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT="${1}"
375
- shift 1
376
- else
377
- NETDATA_INSTALLER_OPTIONS="$NETDATA_INSTALLER_OPTIONS ${1}"
378
- shift 1
379
- fi
393
+ export NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT="${6}"
394
+ shift 5
395
+ ;;
396
+ *)
397
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${1}"
398
+ ;;
399
+ esac
400
+ shift 1
401
done
402
403
if [ "${INTERACTIVE}" = "0" ]; then
405
NETDATA_INSTALLER_OPTIONS="$NETDATA_INSTALLER_OPTIONS --dont-wait"
406
fi
407
408
+if [ -n "${NETDATA_DISABLE_CLOUD}" ]; then
409
+ if [ -n "${NETDATA_CLAIM_TOKEN}" ] || [ -n "${NETDATA_CLAIM_ROOMS}" ] || [ -n "${NETDATA_CLAIM_URL}" ]; then
410
+ run_failed "Cloud explicitly disabled but automatic claiming requested."
411
+ run_failed "Either enable Netdata Cloud, or remove the --claim-* options."
412
+ exit 1
413
+ fi
414
+fi
415
+
416
+# shellcheck disable=SC2235,SC2030
417
+if ( [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_URL}" ] ) || ( [ -n "${NETDATA_CLAIM_TOKEN}" ] && [ -z "${NETDATA_CLAIM_URL}" ] ); then
418
+ run_failed "Invalid claiming options, both a claiming token and URL must be specified."
419
+ exit 1
420
+elif [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_ROOMS}" ]; then
421
+ run_failed "Invalid claiming options, claim rooms may only be specified when a token and URL are specified."
422
+ exit 1
423
+fi
424
+
425
# ---------------------------------------------------------------------------------------------------------------------
426
# look for an existing install and try to update that instead if it exists
427
525
cd "$(find . -mindepth 1 -maxdepth 1 -type d)" && install "$@"
526
else
527
fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh). Leaving all files in ${ndtmpdir}"
528
+ exit 1
529
+ fi
530
+fi
531
+
532
+# --------------------------------------------------------------------------------------------------------------------
533
+
534
+if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then
535
+ progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
536
+ if [ -z "${NETDATA_PREFIX}" ] ; then
537
+ NETDATA_CLAIM_PATH=/usr/sbin/netdata-claim.sh
538
+ else
539
+ NETDATA_CLAIM_PATH="${NETDATA_PREFIX}/bin/netdata-claim.sh"
540
+ fi
541
+
542
+ if "${NETDATA_CLAIM_PATH}" -token=${NETDATA_CLAIM_TOKEN} -rooms=${NETDATA_CLAIM_ROOMS} -url=${NETDATA_CLAIM_URL} ${NETDATA_CLAIM_EXTRA}; then
543
+ progress "Successfully claimed node"
544
+ else
545
+ run_failed "Unable to claim node, you must do so manually."
546
fi
547
fi