summaryrefslogtreecommitdiffstats
path: root/packaging/installer/kickstart-static64.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/installer/kickstart-static64.sh')
-rwxr-xr-xpackaging/installer/kickstart-static64.sh48
1 files changed, 38 insertions, 10 deletions
diff --git a/packaging/installer/kickstart-static64.sh b/packaging/installer/kickstart-static64.sh
index 36aca54d7..ec1800a61 100755
--- a/packaging/installer/kickstart-static64.sh
+++ b/packaging/installer/kickstart-static64.sh
@@ -206,6 +206,33 @@ safe_sha256sum() {
fi
}
+mark_install_type() {
+ install_type_file="/opt/netdata/etc/netdata/.install-type"
+ if [ -f "${install_type_file}" ]; then
+ # shellcheck disable=SC1090
+ . "${install_type_file}"
+ cat > "${TMPDIR}/install-type" <<- EOF
+ INSTALL_TYPE='kickstart-static'
+ PREBUILT_ARCH='${PREBUILT_ARCH}'
+ EOF
+ ${sudo} chown netdata:netdata "${TMPDIR}/install-type"
+ ${sudo} cp "${TMPDIR}/install-type" "${install_type_file}"
+ fi
+}
+
+claim() {
+ progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
+ NETDATA_CLAIM_PATH=/opt/netdata/bin/netdata-claim.sh
+
+ if ${sudo} "${NETDATA_CLAIM_PATH}" -token=${NETDATA_CLAIM_TOKEN} -rooms=${NETDATA_CLAIM_ROOMS} -url=${NETDATA_CLAIM_URL} ${NETDATA_CLAIM_EXTRA}; then
+ progress "Successfully claimed node"
+ return 0
+ else
+ run_failed "Unable to claim node, you must do so manually."
+ return 1
+ fi
+}
+
# ----------------------------------------------------------------------------
umask 022
@@ -326,7 +353,10 @@ if [ -n "$ndpath" ] ; then
if [ -r "${ndprefix}/etc/netdata/.environment" ] ; then
ndstatic="$(grep IS_NETDATA_STATIC_BINARY "${ndprefix}/etc/netdata/.environment" | cut -d "=" -f 2 | tr -d \")"
if [ -z "${NETDATA_REINSTALL}" ] && [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE}" ] ; then
- if [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then
+ if [ -n "${NETDATA_CLAIM_TOKEN}" ] ; then
+ claim
+ exit $?
+ elif [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then
progress "Attempting to update existing install instead of creating a new one"
if run ${sudo} "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" --not-running-from-cron ; then
progress "Updated existing install at ${ndpath}"
@@ -353,7 +383,10 @@ if [ -n "$ndpath" ] ; then
fi
else
progress "Existing install appears to be handled manually or through the system package manager."
- if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
+ if [ -n "${NETDATA_CLAIM_TOKEN}" ] ; then
+ claim
+ exit $?
+ elif [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue."
exit 1
else
@@ -386,6 +419,8 @@ fi
progress "Installing netdata"
run ${sudo} sh "${TMPDIR}/netdata-latest.gz.run" ${opts} -- ${NETDATA_UPDATES} ${NETDATA_INSTALLER_OPTIONS}
+mark_install_type
+
#shellcheck disable=SC2181
if [ $? -eq 0 ]; then
run ${sudo} rm "${TMPDIR}/netdata-latest.gz.run"
@@ -400,12 +435,5 @@ fi
# --------------------------------------------------------------------------------------------------------------------
if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then
- progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
- NETDATA_CLAIM_PATH=/opt/netdata/bin/netdata-claim.sh
-
- if "${NETDATA_CLAIM_PATH}" -token=${NETDATA_CLAIM_TOKEN} -rooms=${NETDATA_CLAIM_ROOMS} -url=${NETDATA_CLAIM_URL} ${NETDATA_CLAIM_EXTRA}; then
- progress "Successfully claimed node"
- else
- run_failed "Unable to claim node, you must do so manually."
- fi
+ claim
fi