5
# ======================================================================
6
# Constants
7
8
+KICKSTART_OPTIONS="${*}"
9
PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh"
10
+PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
11
REPOCONFIG_URL_PREFIX="https://packagecloud.io/netdata/netdata-repoconfig/packages"
12
REPOCONFIG_VERSION="1-1"
11
-PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
13
+TELEMETRY_URL="https://posthog.netdata.cloud/capture/"
14
+START_TIME="$(date +%s)"
15
16
# ======================================================================
17
# Defaults for environment variables
18
19
+SELECTED_INSTALL_METHOD="none"
20
+INSTALL_TYPE="unknown"
21
INSTALL_PREFIX=""
22
NETDATA_AUTO_UPDATES="1"
23
NETDATA_CLAIM_ONLY=0
32
NETDATA_DISABLE_TELEMETRY="${DO_NOT_TRACK:-0}"
33
NETDATA_TARBALL_BASEURL="${NETDATA_TARBALL_BASEURL:-https://storage.googleapis.com/netdata-nightlies}"
34
NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:-""}"
35
+TELEMETRY_API_KEY="${NETDATA_POSTHOG_API_KEY:-mqkwGT0JNFqO-zX2t0mW6Tec9yooaVu7xCBlXtHnt5Y}"
36
37
if [ ! -t 1 ]; then
38
INTERACTIVE=0
85
HEREDOC
86
}
87
88
+# ======================================================================
89
+# Telemetry functions
90
+
91
+telemetry_event() {
92
+ if [ "${NETDATA_DISABLE_TELEMETRY}" -eq 1 ]; then
93
+ return 0
94
+ fi
95
+
96
+ now="$(date +%s)"
97
+ total_duration="$((now - START_TIME))"
98
+
99
+ if [ -e "/etc/os-release" ]; then
100
+ eval "$(grep -E "^(NAME|ID|ID_LIKE|VERSION|VERSION_ID)=" < /etc/os-release | sed 's/^/HOST_/')"
101
+ fi
102
+
103
+ if [ -z "${HOST_NAME}" ] || [ -z "${HOST_VERSION}" ] || [ -z "${HOST_ID}" ]; then
104
+ if [ -f "/etc/lsb-release" ]; then
105
+ DISTRIB_ID="unknown"
106
+ DISTRIB_RELEASE="unknown"
107
+ DISTRIB_CODENAME="unknown"
108
+ eval "$(grep -E "^(DISTRIB_ID|DISTRIB_RELEASE|DISTRIB_CODENAME)=" < /etc/lsb-release)"
109
+ if [ -z "${HOST_NAME}" ]; then HOST_NAME="${DISTRIB_ID}"; fi
110
+ if [ -z "${HOST_VERSION}" ]; then HOST_VERSION="${DISTRIB_RELEASE}"; fi
111
+ if [ -z "${HOST_ID}" ]; then HOST_ID="${DISTRIB_CODENAME}"; fi
112
+ fi
113
+ fi
114
+
115
+ KERNEL_NAME="$(uname -s)"
116
+
117
+ if [ "${KERNEL_NAME}" = FreeBSD ]; then
118
+ TOTAL_RAM="$(sysctl -n hw.physmem)"
119
+ elif [ "${KERNEL_NAME}" = Darwin ]; then
120
+ TOTAL_RAM="$(sysctl -n hw.memsize)"
121
+ elif [ -r /proc/meminfo ]; then
122
+ TOTAL_RAM="$(grep -F MemTotal /proc/meminfo | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | cut -f 1 -d ' ')"
123
+ TOTAL_RAM="$((TOTAL_RAM * 1024))"
124
+ fi
125
+
126
+ if [ -f /etc/machine-id ]; then
127
+ DISTINCT_ID="$(cat /etc/machine-id)"
128
+ elif command -v uuidgen > /dev/null 2>&1; then
129
+ DISTINCT_ID="$(uuidgen)"
130
+ else
131
+ DISTINCT_ID="null"
132
+ fi
133
+
134
+ REQ_BODY="$(cat << EOF
135
+{
136
+ "api_key": "${TELEMETRY_API_KEY}",
137
+ "event": "${1}",
138
+ "properties": {
139
+ "distinct_id": "${DISTINCT_ID}",
140
+ "event_source": "agent installer",
141
+ "\$current_url": "agent installer",
142
+ "\$pathname": "netdata-installer",
143
+ "\$host": "installer.netdata.io",
144
+ "\$ip": "127.0.0.1",
145
+ "script_variant": "kickstart-ng",
146
+ "error_code": "${3}",
147
+ "error_message": "${2}",
148
+ "install_options": "${KICKSTART_OPTIONS}",
149
+ "total_runtime": "${total_duration}",
150
+ "selected_install_method": "${SELECTED_INSTALL_METHOD}",
151
+ "netdata_release_channel": "${RELEASE_CHANNEL:-null}",
152
+ "netdata_install_type": "${INSTALL_TYPE}",
153
+ "host_os_name": "${HOST_NAME:-unknown}",
154
+ "host_os_id": "${HOST_ID:-unknown}",
155
+ "host_os_id_like": "${HOST_ID_LIKE:-unknown}",
156
+ "host_os_version": "${HOST_VERSION:-unknown}",
157
+ "host_os_version_id": "${HOST_VERSION_ID:-unknown}",
158
+ "system_kernel_name": "${KERNEL_NAME}",
159
+ "system_kernel_version": "$(uname -r)",
160
+ "system_architecture": "$(uname -m)",
161
+ "system_total_ram": "${TOTAL_RAM:-unknown}"
162
+ }
163
+}
164
+EOF
165
+)"
166
+
167
+ if [ -n "$(command -v curl 2> /dev/null)" ]; then
168
+ curl --silent -o /dev/null -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" > /dev/null
169
+ else
170
+ wget -q -O - --no-check-certificate \
171
+ --method POST \
172
+ --timeout=1 \
173
+ --header 'Content-Type: application/json' \
174
+ --body-data "${REQ_BODY}" \
175
+ "${TELEMETRY_URL}" > /dev/null
176
+ fi
177
+}
178
+
179
+trap_handler() {
180
+ code="${1}"
181
+ lineno="${2}"
182
+
183
+ printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ERROR ${TPUT_RESET} Installer exited unexpectedly (${code}-${lineno})"
184
+
185
+ telemetry_event INSTALL_CRASH "Installer exited unexpectedly (${code}-${lineno})" "E${code}-${lineno}"
186
+
187
+ trap - EXIT
188
+
189
+ cleanup
190
+
191
+ exit 1
192
+}
193
+
194
+trap 'trap_handler 0 ${LINENO}' EXIT
195
+trap 'trap_handler 1 0' HUP
196
+trap 'trap_handler 2 0' INT
197
+trap 'trap_handler 3 0' QUIT
198
+trap 'trap_handler 13 0' PIPE
199
+trap 'trap_handler 15 0' TERM
200
+
201
# ======================================================================
202
# Utility functions
203
237
238
fatal() {
239
printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*}"
240
+ telemetry_event "INSTALL_FAILED" "${1}" "${2}"
241
cleanup
242
+ trap - EXIT
243
exit 1
244
}
245
336
if [ -z "${TMPDIR}" ] || _cannot_use_tmpdir "${TMPDIR}"; then
337
if _cannot_use_tmpdir /tmp; then
338
if _cannot_use_tmpdir "${PWD}"; then
218
- fatal "Unable to find a usable temporary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again."
339
+ fatal "Unable to find a usable temporary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again." F0400
340
else
341
TMPDIR="${PWD}"
342
fi
356
elif command -v wget > /dev/null 2>&1; then
357
run wget -T 15 -O "${dest}" "${url}" || return 1
358
else
238
- fatal "I need curl or wget to proceed, but neither of them are available on this system."
359
+ fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003
360
fi
361
}
362
368
elif command -v wget > /dev/null 2>&1; then
369
run sh -c "wget --max-redirect=0 ${url} 2>&1 | grep Location | cut -d ' ' -f2 | grep -o '[^/]*$'" || return 1
370
else
250
- fatal "I need curl or wget to proceed, but neither of them are available on this system."
371
+ fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003
372
fi
373
}
374
380
elif command -v shasum > /dev/null 2>&1; then
381
shasum -a 256 "$@"
382
else
262
- fatal "I could not find a suitable checksum binary to use"
383
+ fatal "I could not find a suitable checksum binary to use" F0004
384
fi
385
}
386
395
elif [ -s "/usr/lib/os-release" ] && [ -r "/usr/lib/os-release" ]; then
396
os_release_file="/usr/lib/os-release"
397
else
277
- fatal "Cannot find an os-release file ..."
398
+ fatal "Cannot find an os-release file ..." F0401
399
fi
400
401
# shellcheck disable=SC1090
435
SYSARCH="$(uname -m)"
436
;;
437
*)
317
- fatal "Unsupported system type detected. Netdata cannot be installed on this system using this script."
438
+ fatal "Unsupported system type detected. Netdata cannot be installed on this system using this script." F0200
439
;;
440
esac
441
}
460
fi
461
462
if [ -z "${ROOTCMD}" ]; then
342
- fatal "We need root privileges to continue, but cannot find a way to gain them. Either re-run this script as root, or set \$ROOTCMD to a command that can be used to gain root privileges"
463
+ fatal "We need root privileges to continue, but cannot find a way to gain them. Either re-run this script as root, or set \$ROOTCMD to a command that can be used to gain root privileges" F0201
464
fi
465
fi
466
}
491
progress "Updated existing install at ${ndprefix}"
492
return 0
493
else
373
- fatal "Failed to update existing Netdata install at ${ndprefix}"
494
+ fatal "Failed to update existing Netdata install at ${ndprefix}" F0100
495
fi
496
else
497
return 1
502
if pkg_installed netdata; then
503
ndprefix="/"
504
else
384
- ndpath="$(command -v netdata 2>/dev/null)"
505
+ if [ -n "${INSTALL_PREFIX}" ]; then
506
+ searchpath="${INSTALL_PREFIX}/bin:${INSTALL_PREFIX}/sbin:${INSTALL_PREFIX}/usr/bin:${INSTALL_PREFIX}/usr/sbin:${PATH}"
507
+ searchpath="${INSTALL_PREFIX}/netdata/bin:${INSTALL_PREFIX}/netdata/sbin:${INSTALL_PREFIX}/netdata/usr/bin:${INSTALL_PREFIX}/netdata/usr/sbin:${searchpath}"
508
+ else
509
+ searchpath="${PATH}"
510
+ fi
511
+
512
+ ndpath="$(PATH="${searchpath}" command -v netdata 2>/dev/null)"
513
+
514
if [ -z "$ndpath" ] && [ -x /opt/netdata/bin/netdata ]; then
515
ndpath="/opt/netdata/bin/netdata"
516
fi
519
ndprefix="$(dirname "$(dirname "${ndpath}")")"
520
fi
521
393
- if [ "${ndprefix}" = /usr ]; then
394
- ndprefix="/"
522
+ if echo "${ndprefix}" | grep -Eq '/usr$'; then
523
+ ndprefix="$(dirname "${ndprefix}")"
524
fi
525
fi
526
559
if [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
560
warning "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, but the user has requested we proceed."
561
elif [ "${INTERACTIVE}" -eq 0 ]; then
433
- fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting."
562
+ fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting." F0104
563
else
564
if confirm "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, do you want to continue?"; then
565
progress "OK, continuing."
566
else
438
- fatal "Cancelling reinstallation at user request."
567
+ fatal "Cancelling reinstallation at user request." F0105
568
fi
569
fi
570
;;
589
claim
590
ret=$?
591
elif [ "${NETDATA_CLAIM_ONLY}" -eq 1 ]; then
463
- fatal "User asked to claim, but did not proide a claiming token."
592
+ fatal "User asked to claim, but did not proide a claiming token." F0202
593
else
594
progress "Not attempting to claim existing install at ${ndprefix} (no claiming token provided)."
595
fi
596
597
cleanup
598
+ trap - EXIT
599
exit $ret
600
;;
601
oci)
472
- fatal "This is an OCI container, use the regular image lifecycle management commands in your container instead of this script for managing it."
602
+ fatal "This is an OCI container, use the regular image lifecycle management commands in your container instead of this script for managing it." F0203
603
;;
604
*)
605
if [ -n "${NETDATA_REINSTALL}" ] || [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
606
if [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
607
warning "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, but the user has requested we proceed."
608
elif [ "${INTERACTIVE}" -eq 0 ]; then
479
- fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting."
609
+ fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting." F0104
610
else
611
if confirm "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, do you want to continue?"; then
612
progress "OK, continuing."
613
else
484
- fatal "Cancelling reinstallation at user request."
614
+ fatal "Cancelling reinstallation at user request." F0105
615
fi
616
fi
617
else
488
- fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed."
618
+ fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed." F0103
619
fi
620
;;
621
esac
656
657
confirm_install_prefix() {
658
if [ -n "${INSTALL_PREFIX}" ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
529
- fatal "The \`--install\` option is only supported together with the \`--only-build\` option."
659
+ fatal "The \`--install\` option is only supported together with the \`--only-build\` option." F0204
660
fi
661
532
- case "${SYSTYPE}" in
533
- Darwin) INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local/netdata}" ;;
534
- FreeBSD) INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}" ;;
535
- esac
536
-
662
if [ -n "${INSTALL_PREFIX}" ]; then
663
NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install ${INSTALL_PREFIX}"
664
+ else
665
+ case "${SYSTYPE}" in
666
+ Darwin)
667
+ INSTALL_PREFIX="/usr/local/netdata"
668
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install-no-prefix ${INSTALL_PREFIX}"
669
+ ;;
670
+ FreeBSD)
671
+ INSTALL_PREFIX="/usr/local"
672
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install-no-prefix ${INSTALL_PREFIX}"
673
+ ;;
674
+ esac
675
fi
676
}
677
681
check_claim_opts() {
682
# shellcheck disable=SC2235,SC2030
683
if [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_ROOMS}" ]; then
548
- fatal "Invalid claiming options, claim rooms may only be specified when a token and URL are specified."
684
+ fatal "Invalid claiming options, claim rooms may only be specified when a token and URL are specified." F0204
685
elif [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_EXTRA}" ]; then
550
- fatal "Invalid claiming options, a claiming token must be specified."
686
+ fatal "Invalid claiming options, a claiming token must be specified." F0204
687
elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ] && [ -n "${NETDATA_CLAIM_TOKEN}" ]; then
552
- fatal "Cloud explicitly disabled, but automatic claiming requested. Either enable Netdata Cloud, or remove the --claim-* options."
688
+ fatal "Cloud explicitly disabled, but automatic claiming requested. Either enable Netdata Cloud, or remove the --claim-* options." F0204
689
fi
690
}
691
710
warning "Unable to claim node, you must do so manually."
711
if [ -z "${NETDATA_NEW_INSTALL}" ]; then
712
cleanup
713
+ trap - EXIT
714
exit 1
715
fi
716
fi
818
pkg_install_opts="${interactive_opts}"
819
repo_update_opts="${interactive_opts}"
820
uninstall_subcmd="uninstall"
821
+ INSTALL_TYPE="binpkg-deb"
822
;;
823
ubuntu)
824
needs_early_refresh=1
831
pkg_install_opts="${interactive_opts}"
832
repo_update_opts="${interactive_opts}"
833
uninstall_subcmd="uninstall"
834
+ INSTALL_TYPE="binpkg-deb"
835
;;
836
centos)
837
if command -v dnf > /dev/null; then
847
pkg_install_opts="${interactive_opts}"
848
repo_update_opts="${interactive_opts}"
849
uninstall_subcmd="remove"
850
+ INSTALL_TYPE="binpkg-rpm"
851
;;
852
fedora)
853
if command -v dnf > /dev/null; then
863
pkg_install_opts="${interactive_opts}"
864
repo_update_opts="${interactive_opts}"
865
uninstall_subcmd="remove"
866
+ INSTALL_TYPE="binpkg-rpm"
867
;;
868
opensuse)
869
pm_cmd="zypper"
875
pkg_install_opts="${interactive_opts} --allow-unsigned-rpm"
876
repo_update_opts=""
877
uninstall_subcmd="remove"
878
+ INSTALL_TYPE="binpkg-rpm"
879
;;
880
*)
881
warning "We do not provide native packages for ${DISTRO}."
914
progress "Updating repository metadata."
915
# shellcheck disable=SC2086
916
if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
775
- fatal "Failed to update repository metadata."
917
+ fatal "Failed to update repository metadata." F0205
918
fi
919
fi
920
else
984
fi
985
986
if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then
845
- fatal "Unable to fetch checksums to verify static build archive."
987
+ fatal "Unable to fetch checksums to verify static build archive." F0206
988
fi
989
990
if ! grep "netdata-${SYSARCH}-latest.gz.run" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
849
- fatal "Static binary checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour."
991
+ fatal "Static binary checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0207
992
fi
993
994
if [ "${INTERACTIVE}" -eq 0 ]; then
998
progress "Installing netdata"
999
# shellcheck disable=SC2086
1000
if ! run ${ROOTCMD} sh "${tmpdir}/netdata-${SYSARCH}-latest.gz.run" ${opts} -- ${NETDATA_AUTO_UPDATES:+--auto-update} ${NETDATA_INSTALLER_OPTIONS}; then
859
- fatal "Failed to install static build of Netdata on ${SYSARCH}."
1001
+ warning "Failed to install static build of Netdata on ${SYSARCH}."
1002
+ run rm -rf /opt/netdata
1003
+ return 2
1004
fi
1005
1006
install_type_file="/opt/netdata/etc/netdata/.install-type"
1091
fi
1092
1093
# shellcheck disable=SC2086
950
- run ${ROOTCMD} ./netdata-installer.sh ${opts} || fatal "netdata-installer.sh exited with error"
1094
+ run ${ROOTCMD} ./netdata-installer.sh ${opts}
1095
+
1096
+ case $? in
1097
+ 1)
1098
+ fatal "netdata-installer.sh exited with error" F0007
1099
+ ;;
1100
+ 2)
1101
+ fatal "Insufficient RAM to install netdata" F0008
1102
+ ;;
1103
+ esac
1104
}
1105
1106
try_build_install() {
1114
download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz"
1115
1116
if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
964
- fatal "Tarball checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour."
1117
+ fatal "Tarball checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0005
1118
fi
1119
1120
run tar -xf "${tmpdir}/netdata-latest.tar.gz" -C "${tmpdir}"
1121
rm -rf "${tmpdir}/netdata-latest.tar.gz" > /dev/null 2>&1
969
- cd "$(find "${tmpdir}" -mindepth 1 -maxdepth 1 -type d -name netdata-)" || fatal "Cannot cd to netdata source tree"
1122
+ cd "$(find "${tmpdir}" -mindepth 1 -maxdepth 1 -type d -name netdata-)" || fatal "Cannot cd to netdata source tree" F0006
1123
1124
if [ -x netdata-installer.sh ]; then
1125
build_and_install || return 1
1128
if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ] && [ -x "$(find . -mindepth 1 -maxdepth 1 -type d)/netdata-installer.sh" ]; then
1129
cd "$(find . -mindepth 1 -maxdepth 1 -type d)" && build_and_install || return 1
1130
else
978
- fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh). Leaving all files in ${tmpdir}"
1131
+ fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh). Leaving all files in ${tmpdir}" F0009
1132
fi
1133
fi
1134
}
1138
1139
install_on_linux() {
1140
if [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
1141
+ SELECTED_INSTALL_METHOD="native"
1142
try_package_install
1143
1144
case "$?" in
1146
NETDATA_INSTALL_SUCCESSFUL=1
1147
;;
1148
1)
995
- fatal "Unable to install on this system."
1149
+ fatal "Unable to install on this system." F0300
1150
;;
1151
2)
1152
if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then
999
- fatal "Could not install native binary packages."
1153
+ fatal "Could not install native binary packages." F0301
1154
else
1155
warning "Could not install native binary packages, falling back to alternative installation method."
1156
fi
1159
fi
1160
1161
if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then
1162
+ SELECTED_INSTALL_METHOD="static"
1163
+ INSTALL_TYPE="kickstart-static"
1164
try_static_install
1165
1166
case "$?" in
1169
INSTALL_PREFIX="/opt/netdata"
1170
;;
1171
1)
1016
- fatal "Unable to install on this system."
1172
+ fatal "Unable to install on this system." F0302
1173
;;
1174
2)
1175
if [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then
1020
- fatal "Could not install static build."
1176
+ fatal "Could not install static build." F0303
1177
else
1178
warning "Could not install static build, falling back to alternative installation method."
1179
fi
1182
fi
1183
1184
if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then
1185
+ SELECTED_INSTALL_METHOD="build"
1186
+ INSTALL_TYPE="kickstart-build"
1187
try_build_install
1188
1189
case "$?" in
1191
NETDATA_INSTALL_SUCCESSFUL=1
1192
;;
1193
*)
1036
- fatal "Unable to install on this system."
1194
+ fatal "Unable to install on this system." F0304
1195
;;
1196
esac
1197
fi
1199
1200
install_on_macos() {
1201
if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then
1044
- fatal "User requested native package, but native packages are not available for macOS. Try installing without \`--only-native\` option."
1202
+ fatal "User requested native package, but native packages are not available for macOS. Try installing without \`--only-native\` option." F0305
1203
elif [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then
1046
- fatal "User requested static build, but static builds are not available for macOS. Try installing without \`--only-static\` option."
1204
+ fatal "User requested static build, but static builds are not available for macOS. Try installing without \`--only-static\` option." F0306
1205
else
1206
+ SELECTED_INSTALL_METHOD="build"
1207
+ INSTALL_TYPE="kickstart-build"
1208
try_build_install
1209
1210
case "$?" in
1212
NETDATA_INSTALL_SUCCESSFUL=1
1213
;;
1214
*)
1055
- fatal "Unable to install on this system."
1215
+ fatal "Unable to install on this system." F0307
1216
;;
1217
esac
1218
fi
1220
1221
install_on_freebsd() {
1222
if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then
1063
- fatal "User requested native package, but native packages are not available for FreeBSD. Try installing without \`--only-native\` option."
1223
+ fatal "User requested native package, but native packages are not available for FreeBSD. Try installing without \`--only-native\` option." F0308
1224
elif [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then
1065
- fatal "User requested static build, but static builds are not available for FreeBSD. Try installing without \`--only-static\` option."
1225
+ fatal "User requested static build, but static builds are not available for FreeBSD. Try installing without \`--only-static\` option." F0309
1226
else
1227
+ SELECTED_INSTALL_METHOD="build"
1228
+ INSTALL_TYPE="kickstart-build"
1229
try_build_install
1230
1231
case "$?" in
1233
NETDATA_INSTALL_SUCCESSFUL=1
1234
;;
1235
*)
1074
- fatal "Unable to install on this system."
1236
+ fatal "Unable to install on this system." F030A
1237
;;
1238
esac
1239
fi
1249
"--help")
1250
usage
1251
cleanup
1252
+ trap - EXIT
1253
exit 0
1254
;;
1255
"--no-cleanup") NO_CLEANUP=1 ;;
1274
NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --dont-start-it"
1275
;;
1276
"--disable-telemetry")
1114
- NETDATA_DISABLE_TELEMETRY="0"
1277
+ NETDATA_DISABLE_TELEMETRY="1"
1278
NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --disable-telemetry"
1279
;;
1280
"--install")
1285
NETDATA_ONLY_NATIVE=1
1286
NETDATA_ONLY_STATIC=0
1287
NETDATA_ONLY_BUILD=0
1288
+ SELECTED_INSTALL_METHOD="native"
1289
;;
1290
"--static-only")
1291
NETDATA_ONLY_STATIC=1
1292
NETDATA_ONLY_NATIVE=0
1293
NETDATA_ONLY_BUILD=0
1294
+ SELECTED_INSTALL_METHOD="static"
1295
;;
1296
"--build-only")
1297
NETDATA_ONLY_BUILD=1
1298
NETDATA_ONLY_NATIVE=0
1299
NETDATA_ONLY_STATIC=0
1300
+ SELECTED_INSTALL_METHOD="build"
1301
;;
1136
-
1302
"--claim-token")
1303
NETDATA_CLAIM_TOKEN="${2}"
1304
shift 1
1357
soft_disable_cloud
1358
fi
1359
1360
+telemetry_event INSTALL_SUCCESS "" ""
1361
cleanup
1362
+trap - EXIT