netdata-installer.sh 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. # Next unused error code: I0012
  4. export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
  5. uniquepath() {
  6. path=""
  7. tmp="$(mktemp)"
  8. (echo "${PATH}" | tr ":" "\n") > "$tmp"
  9. while read -r REPLY;
  10. do
  11. if echo "${path}" | grep -v "(^|:)${REPLY}(:|$)"; then
  12. [ -n "${path}" ] && path="${path}:"
  13. path="${path}${REPLY}"
  14. fi
  15. done < "$tmp"
  16. rm "$tmp"
  17. [ -n "${path}" ]
  18. export PATH="${path%:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin}"
  19. } > /dev/null
  20. uniquepath
  21. PROGRAM="$0"
  22. NETDATA_SOURCE_DIR="$(pwd)"
  23. INSTALLER_DIR="$(dirname "${PROGRAM}")"
  24. if [ "${NETDATA_SOURCE_DIR}" != "${INSTALLER_DIR}" ] && [ "${INSTALLER_DIR}" != "." ]; then
  25. echo >&2 "Warning: you are currently in '${NETDATA_SOURCE_DIR}' but the installer is in '${INSTALLER_DIR}'."
  26. fi
  27. # -----------------------------------------------------------------------------
  28. # reload the user profile
  29. # shellcheck source=/dev/null
  30. [ -f /etc/profile ] && . /etc/profile
  31. # make sure /etc/profile does not change our current directory
  32. cd "${NETDATA_SOURCE_DIR}" || exit 1
  33. # -----------------------------------------------------------------------------
  34. # load the required functions
  35. if [ -f "${INSTALLER_DIR}/packaging/installer/functions.sh" ]; then
  36. # shellcheck source=packaging/installer/functions.sh
  37. . "${INSTALLER_DIR}/packaging/installer/functions.sh" || exit 1
  38. else
  39. # shellcheck source=packaging/installer/functions.sh
  40. . "${NETDATA_SOURCE_DIR}/packaging/installer/functions.sh" || exit 1
  41. fi
  42. # Used to enable saved warnings support in functions.sh
  43. # shellcheck disable=SC2034
  44. NETDATA_SAVE_WARNINGS=1
  45. # -----------------------------------------------------------------------------
  46. # figure out an appropriate temporary directory
  47. _cannot_use_tmpdir() {
  48. testfile="$(TMPDIR="${1}" mktemp -q -t netdata-test.XXXXXXXXXX)"
  49. ret=0
  50. if [ -z "${testfile}" ]; then
  51. return "${ret}"
  52. fi
  53. if printf '#!/bin/sh\necho SUCCESS\n' > "${testfile}"; then
  54. if chmod +x "${testfile}"; then
  55. if [ "$("${testfile}")" = "SUCCESS" ]; then
  56. ret=1
  57. fi
  58. fi
  59. fi
  60. rm -f "${testfile}"
  61. return "${ret}"
  62. }
  63. if [ -z "${TMPDIR}" ] || _cannot_use_tmpdir "${TMPDIR}"; then
  64. if _cannot_use_tmpdir /tmp; then
  65. if _cannot_use_tmpdir "${PWD}"; then
  66. 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." I0000
  67. else
  68. TMPDIR="${PWD}"
  69. fi
  70. else
  71. TMPDIR="/tmp"
  72. fi
  73. fi
  74. # -----------------------------------------------------------------------------
  75. # set up handling for deferred error messages
  76. #
  77. # This leverages the saved warnings functionality shared with some functions from functions.sh
  78. print_deferred_errors() {
  79. if [ -n "${SAVED_WARNINGS}" ]; then
  80. printf >&2 "\n"
  81. printf >&2 "%b\n" "The following warnings and non-fatal errors were encountered during the installation process:"
  82. printf >&2 "%b\n" "${SAVED_WARNINGS}"
  83. printf >&2 "\n"
  84. fi
  85. }
  86. download_go() {
  87. download_file "${1}" "${2}" "go.d plugin" "go"
  88. }
  89. # make sure we save all commands we run
  90. # Variable is used by code in the packaging/installer/functions.sh
  91. # shellcheck disable=SC2034
  92. run_logfile="netdata-installer.log"
  93. # -----------------------------------------------------------------------------
  94. # fix PKG_CHECK_MODULES error
  95. if [ -d /usr/share/aclocal ]; then
  96. ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
  97. export ACLOCAL_PATH
  98. fi
  99. export LC_ALL=C
  100. umask 002
  101. # Be nice on production environments
  102. renice 19 $$ > /dev/null 2> /dev/null
  103. # you can set CFLAGS before running installer
  104. # shellcheck disable=SC2269
  105. LDFLAGS="${LDFLAGS}"
  106. CFLAGS="${CFLAGS-"-O2 -pipe"}"
  107. [ "z${CFLAGS}" = "z-O3" ] && CFLAGS="-O2"
  108. # shellcheck disable=SC2269
  109. ACLK="${ACLK}"
  110. # keep a log of this command
  111. {
  112. printf "\n# "
  113. date
  114. printf 'CFLAGS="%s" ' "${CFLAGS}"
  115. printf 'LDFLAGS="%s" ' "${LDFLAGS}"
  116. printf "%s" "${PROGRAM}" "${@}"
  117. printf "\n"
  118. } >> netdata-installer.log
  119. REINSTALL_OPTIONS="$(
  120. printf "%s" "${*}"
  121. printf "\n"
  122. )"
  123. # remove options that shown not be inherited by netdata-updater.sh
  124. REINSTALL_OPTIONS="$(echo "${REINSTALL_OPTIONS}" | sed 's/--dont-wait//g' | sed 's/--dont-start-it//g')"
  125. banner_nonroot_install() {
  126. cat << NONROOTNOPREFIX
  127. ${TPUT_RED}${TPUT_BOLD}Sorry! This will fail!${TPUT_RESET}
  128. You are attempting to install netdata as a non-root user, but you plan
  129. to install it in system paths.
  130. Please set an installation prefix, like this:
  131. $PROGRAM ${@} --install-prefix /tmp
  132. or, run the installer as root:
  133. sudo $PROGRAM ${@}
  134. We suggest to install it as root, or certain data collectors will
  135. not be able to work. Netdata drops root privileges when running.
  136. So, if you plan to keep it, install it as root to get the full
  137. functionality.
  138. NONROOTNOPREFIX
  139. }
  140. banner_root_notify() {
  141. cat << NONROOT
  142. ${TPUT_RED}${TPUT_BOLD}IMPORTANT${TPUT_RESET}:
  143. You are about to install netdata as a non-root user.
  144. Netdata will work, but a few data collection modules that
  145. require root access will fail.
  146. If you are installing netdata permanently on your system, run
  147. the installer like this:
  148. ${TPUT_YELLOW}${TPUT_BOLD}sudo $PROGRAM ${@}${TPUT_RESET}
  149. NONROOT
  150. }
  151. usage() {
  152. netdata_banner
  153. progress "installer command line options"
  154. cat << HEREDOC
  155. USAGE: ${PROGRAM} [options]
  156. where options include:
  157. --install-prefix <path> Install netdata in <path>. Ex. --install-prefix /opt will put netdata in /opt/netdata.
  158. --dont-start-it Do not (re)start netdata after installation.
  159. --dont-wait Run installation in non-interactive mode.
  160. --stable-channel Use packages from GitHub release pages instead of nightly updates.
  161. This results in less frequent updates.
  162. --nightly-channel Use most recent nightly updates instead of GitHub releases.
  163. This results in more frequent updates.
  164. --disable-go Disable installation of go.d.plugin.
  165. --disable-ebpf Disable eBPF Kernel plugin. Default: enabled.
  166. --disable-cloud Disable all Netdata Cloud functionality.
  167. --require-cloud Fail the install if it can't build Netdata Cloud support.
  168. --enable-plugin-freeipmi Enable the FreeIPMI plugin. Default: enable it when libipmimonitoring is available.
  169. --disable-plugin-freeipmi Explicitly disable the FreeIPMI plugin.
  170. --disable-https Explicitly disable TLS support.
  171. --disable-dbengine Explicitly disable DB engine support.
  172. --enable-plugin-nfacct Enable nfacct plugin. Default: enable it when libmnl and libnetfilter_acct are available.
  173. --disable-plugin-nfacct Explicitly disable the nfacct plugin.
  174. --enable-plugin-xenstat Enable the xenstat plugin. Default: enable it when libxenstat and libyajl are available.
  175. --disable-plugin-xenstat Explicitly disable the xenstat plugin.
  176. --enable-exporting-kinesis Enable AWS Kinesis exporting connector. Default: enable it when libaws_cpp_sdk_kinesis
  177. and its dependencies are available.
  178. --disable-exporting-kinesis Explicitly disable AWS Kinesis exporting connector.
  179. --enable-exporting-prometheus-remote-write Enable Prometheus remote write exporting connector. Default: enable it
  180. when libprotobuf and libsnappy are available.
  181. --disable-exporting-prometheus-remote-write Explicitly disable Prometheus remote write exporting connector.
  182. --enable-exporting-mongodb Enable MongoDB exporting connector. Default: enable it when libmongoc is available.
  183. --disable-exporting-mongodb Explicitly disable MongoDB exporting connector.
  184. --enable-exporting-pubsub Enable Google Cloud PubSub exporting connector. Default: enable it when
  185. libgoogle_cloud_cpp_pubsub_protos and its dependencies are available.
  186. --disable-exporting-pubsub Explicitly disable Google Cloud PubSub exporting connector.
  187. --enable-lto Enable link-time optimization. Default: disabled.
  188. --disable-lto Explicitly disable link-time optimization.
  189. --enable-ml Enable anomaly detection with machine learning. Default: autodetect.
  190. --disable-ml Explicitly disable anomaly detection with machine learning.
  191. --disable-x86-sse Disable SSE instructions & optimizations. Default: enabled.
  192. --use-system-protobuf Use a system copy of libprotobuf instead of bundled copy. Default: bundled.
  193. --zlib-is-really-here
  194. --libs-are-really-here If you see errors about missing zlib or libuuid but you know it is available, you might
  195. have a broken pkg-config. Use this option to proceed without checking pkg-config.
  196. --disable-telemetry Opt-out from our anonymous telemetry program. (DISABLE_TELEMETRY=1)
  197. --skip-available-ram-check Skip checking the amount of RAM the system has and pretend it has enough to build safely.
  198. Netdata will by default be compiled with gcc optimization -O2
  199. If you need to pass different CFLAGS, use something like this:
  200. CFLAGS="<gcc options>" ${PROGRAM} [options]
  201. If you also need to provide different LDFLAGS, use something like this:
  202. LDFLAGS="<extra ldflag options>" ${PROGRAM} [options]
  203. or use the following if both LDFLAGS and CFLAGS need to be overridden:
  204. CFLAGS="<gcc options>" LDFLAGS="<extra ld options>" ${PROGRAM} [options]
  205. For the installer to complete successfully, you will need these packages installed:
  206. gcc
  207. make
  208. autoconf
  209. automake
  210. pkg-config
  211. zlib1g-dev (or zlib-devel)
  212. uuid-dev (or libuuid-devel)
  213. For the plugins, you will at least need:
  214. curl
  215. bash (v4+)
  216. python (v2 or v3)
  217. node.js
  218. HEREDOC
  219. }
  220. DONOTSTART=0
  221. DONOTWAIT=0
  222. NETDATA_PREFIX=
  223. LIBS_ARE_HERE=0
  224. NETDATA_ENABLE_ML=""
  225. NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS-}"
  226. RELEASE_CHANNEL="nightly" # valid values are 'nightly' and 'stable'
  227. IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY:-"no"}"
  228. while [ -n "${1}" ]; do
  229. case "${1}" in
  230. "--zlib-is-really-here") LIBS_ARE_HERE=1 ;;
  231. "--libs-are-really-here") LIBS_ARE_HERE=1 ;;
  232. "--use-system-protobuf")
  233. USE_SYSTEM_PROTOBUF=1
  234. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--without-bundled-protobuf}" | sed 's/$/ --without-bundled-protobuf/g')"
  235. ;;
  236. "--dont-scrub-cflags-even-though-it-may-break-things") DONT_SCRUB_CFLAGS_EVEN_THOUGH_IT_MAY_BREAK_THINGS=1 ;;
  237. "--dont-start-it") DONOTSTART=1 ;;
  238. "--dont-wait") DONOTWAIT=1 ;;
  239. "--auto-update" | "-u") ;;
  240. "--auto-update-type") ;;
  241. "--stable-channel") RELEASE_CHANNEL="stable" ;;
  242. "--nightly-channel") RELEASE_CHANNEL="nightly" ;;
  243. "--enable-plugin-freeipmi") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-plugin-freeipmi)}" | sed 's/$/ --enable-plugin-freeipmi/g')" ;;
  244. "--disable-plugin-freeipmi") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-plugin-freeipmi)}" | sed 's/$/ --disable-plugin-freeipmi/g')" ;;
  245. "--disable-https") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-https)}" | sed 's/$/ --disable-plugin-https/g')" ;;
  246. "--disable-dbengine")
  247. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-dbengine)}" | sed 's/$/ --disable-dbengine/g')"
  248. ;;
  249. "--enable-plugin-nfacct") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-plugin-nfacct)}" | sed 's/$/ --enable-plugin-nfacct/g')" ;;
  250. "--disable-plugin-nfacct") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-plugin-nfacct)}" | sed 's/$/ --disable-plugin-nfacct/g')" ;;
  251. "--enable-plugin-xenstat") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-plugin-xenstat)}" | sed 's/$/ --enable-plugin-xenstat/g')" ;;
  252. "--disable-plugin-xenstat") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-plugin-xenstat)}" | sed 's/$/ --disable-plugin-xenstat/g')" ;;
  253. "--enable-exporting-kinesis" | "--enable-backend-kinesis")
  254. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-exporting-kinesis)}" | sed 's/$/ --enable-exporting-kinesis/g')" ;;
  255. "--disable-exporting-kinesis" | "--disable-backend-kinesis")
  256. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-exporting-kinesis)}" | sed 's/$/ --disable-exporting-kinesis/g')" ;;
  257. "--enable-exporting-prometheus-remote-write" | "--enable-backend-prometheus-remote-write")
  258. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-exporting-prometheus-remote-write)}" | sed 's/$/ --enable-exporting-prometheus-remote-write/g')" ;;
  259. "--disable-exporting-prometheus-remote-write" | "--disable-backend-prometheus-remote-write")
  260. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-exporting-prometheus-remote-write)}" | sed 's/$/ --disable-exporting-prometheus-remote-write/g')"
  261. NETDATA_DISABLE_PROMETHEUS=1
  262. ;;
  263. "--enable-exporting-mongodb" | "--enable-backend-mongodb")
  264. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-exporting-mongodb)}" | sed 's/$/ --enable-exporting-mongodb/g')" ;;
  265. "--disable-exporting-mongodb" | "--disable-backend-mongodb")
  266. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-exporting-mongodb)}" | sed 's/$/ --disable-exporting-mongodb/g')" ;;
  267. "--enable-exporting-pubsub") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-exporting-pubsub)}" | sed 's/$/ --enable-exporting-pubsub/g')" ;;
  268. "--disable-exporting-pubsub") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-exporting-pubsub)}" | sed 's/$/ --disable-exporting-pubsub/g')" ;;
  269. "--enable-lto") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-lto)}" | sed 's/$/ --enable-lto/g')" ;;
  270. "--enable-ml")
  271. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-ml)}" | sed 's/$/ --enable-ml/g')"
  272. NETDATA_ENABLE_ML=1
  273. ;;
  274. "--disable-ml")
  275. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-ml)}" | sed 's/$/ --disable-ml/g')"
  276. NETDATA_ENABLE_ML=0
  277. ;;
  278. "--disable-lto") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-lto)}" | sed 's/$/ --disable-lto/g')" ;;
  279. "--disable-x86-sse") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-x86-sse)}" | sed 's/$/ --disable-x86-sse/g')" ;;
  280. "--disable-telemetry") NETDATA_DISABLE_TELEMETRY=1 ;;
  281. "--disable-go") NETDATA_DISABLE_GO=1 ;;
  282. "--enable-ebpf") NETDATA_DISABLE_EBPF=0 ;;
  283. "--disable-ebpf") NETDATA_DISABLE_EBPF=1 NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-ebpf)}" | sed 's/$/ --disable-ebpf/g')" ;;
  284. "--skip-available-ram-check") SKIP_RAM_CHECK=1 ;;
  285. "--one-time-build") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-dependency-tracking)}" | sed 's/$/ --disable-dependency-tracking/g')" ;;
  286. "--disable-cloud")
  287. if [ -n "${NETDATA_REQUIRE_CLOUD}" ]; then
  288. warning "Cloud explicitly enabled, ignoring --disable-cloud."
  289. else
  290. NETDATA_DISABLE_CLOUD=1
  291. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-cloud)}" | sed 's/$/ --disable-cloud/g')"
  292. fi
  293. ;;
  294. "--require-cloud")
  295. if [ -n "${NETDATA_DISABLE_CLOUD}" ]; then
  296. warning "Cloud explicitly disabled, ignoring --require-cloud."
  297. else
  298. NETDATA_REQUIRE_CLOUD=1
  299. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-cloud)}" | sed 's/$/ --enable-cloud/g')"
  300. fi
  301. ;;
  302. "--build-json-c")
  303. NETDATA_BUILD_JSON_C=1
  304. ;;
  305. "--install-prefix")
  306. NETDATA_PREFIX="${2}/netdata"
  307. shift 1
  308. ;;
  309. "--install-no-prefix")
  310. NETDATA_PREFIX="${2}"
  311. shift 1
  312. ;;
  313. "--help" | "-h")
  314. usage
  315. exit 1
  316. ;;
  317. *)
  318. echo >&2 "Unrecognized option '${1}'."
  319. exit_reason "Unrecognized option '${1}'." I000E
  320. usage
  321. exit 1
  322. ;;
  323. esac
  324. shift 1
  325. done
  326. if [ ! "${DISABLE_TELEMETRY:-0}" -eq 0 ] ||
  327. [ -n "$DISABLE_TELEMETRY" ] ||
  328. [ ! "${DO_NOT_TRACK:-0}" -eq 0 ] ||
  329. [ -n "$DO_NOT_TRACK" ]; then
  330. NETDATA_DISABLE_TELEMETRY=1
  331. fi
  332. make="make"
  333. # See: https://github.com/netdata/netdata/issues/9163
  334. if [ "$(uname -s)" = "FreeBSD" ]; then
  335. make="gmake"
  336. NETDATA_CONFIGURE_OPTIONS="$NETDATA_CONFIGURE_OPTIONS --disable-dependency-tracking"
  337. fi
  338. if [ "$(uname -s)" = "Linux" ] && [ -f /proc/meminfo ]; then
  339. mega="$((1024 * 1024))"
  340. base=1024
  341. scale=256
  342. # shellcheck disable=SC2086
  343. if [ -n "${MAKEOPTS}" ]; then
  344. proc_count="$(echo ${MAKEOPTS} | grep -oE '\-j *[[:digit:]]+' | tr -d '\-j ')"
  345. else
  346. proc_count="$(find_processors)"
  347. fi
  348. target_ram="$((base * mega + (scale * mega * (proc_count - 1))))"
  349. total_ram="$(grep MemTotal /proc/meminfo | cut -d ':' -f 2 | tr -d ' kB')"
  350. total_ram="$((total_ram * 1024))"
  351. if [ "${total_ram}" -le "$((base * mega))" ] && [ -z "${NETDATA_ENABLE_ML}" ]; then
  352. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-ml)}" | sed 's/$/ --disable-ml/g')"
  353. NETDATA_ENABLE_ML=0
  354. fi
  355. if [ -z "${MAKEOPTS}" ]; then
  356. MAKEOPTS="-j${proc_count}"
  357. while [ "${target_ram}" -gt "${total_ram}" ] && [ "${proc_count}" -gt 1 ]; do
  358. proc_count="$((proc_count - 1))"
  359. target_ram="$((base * mega + (scale * mega * (proc_count - 1))))"
  360. MAKEOPTS="-j${proc_count}"
  361. done
  362. else
  363. if [ "${target_ram}" -gt "${total_ram}" ] && [ "${proc_count}" -gt 1 ] && [ -z "${SKIP_RAM_CHECK}" ]; then
  364. target_ram="$(echo "${target_ram}" | awk '{$1/=1024*1024*1024;printf "%.2fGiB\n",$1}')"
  365. total_ram="$(echo "${total_ram}" | awk '{$1/=1024*1024*1024;printf "%.2fGiB\n",$1}')"
  366. run_failed "Netdata needs ${target_ram} of RAM to safely install, but this system only has ${total_ram}. Try reducing the number of processes used for the install using the \$MAKEOPTS variable."
  367. exit_reason "Insufficient RAM to safely install." I000F
  368. exit 2
  369. fi
  370. fi
  371. fi
  372. # set default make options
  373. if [ -z "${MAKEOPTS}" ]; then
  374. MAKEOPTS="-j$(find_processors)"
  375. elif echo "${MAKEOPTS}" | grep -vqF -e "-j"; then
  376. MAKEOPTS="${MAKEOPTS} -j$(find_processors)"
  377. fi
  378. if [ "$(id -u)" -ne 0 ]; then
  379. if [ -z "${NETDATA_PREFIX}" ]; then
  380. netdata_banner
  381. banner_nonroot_install "${@}"
  382. exit_reason "Attempted install as non-root user to /." I0010
  383. exit 1
  384. else
  385. banner_root_notify "${@}"
  386. fi
  387. fi
  388. netdata_banner
  389. progress "real-time performance monitoring, done right!"
  390. cat << BANNER1
  391. You are about to build and install netdata to your system.
  392. The build process will use ${TPUT_CYAN}${TMPDIR}${TPUT_RESET} for
  393. any temporary files. You can override this by setting \$TMPDIR to a
  394. writable directory where you can execute files.
  395. It will be installed at these locations:
  396. - the daemon at ${TPUT_CYAN}${NETDATA_PREFIX}/usr/sbin/netdata${TPUT_RESET}
  397. - config files in ${TPUT_CYAN}${NETDATA_PREFIX}/etc/netdata${TPUT_RESET}
  398. - web files in ${TPUT_CYAN}${NETDATA_PREFIX}/usr/share/netdata${TPUT_RESET}
  399. - plugins in ${TPUT_CYAN}${NETDATA_PREFIX}/usr/libexec/netdata${TPUT_RESET}
  400. - cache files in ${TPUT_CYAN}${NETDATA_PREFIX}/var/cache/netdata${TPUT_RESET}
  401. - db files in ${TPUT_CYAN}${NETDATA_PREFIX}/var/lib/netdata${TPUT_RESET}
  402. - log files in ${TPUT_CYAN}${NETDATA_PREFIX}/var/log/netdata${TPUT_RESET}
  403. BANNER1
  404. [ "$(id -u)" -eq 0 ] && cat << BANNER2
  405. - pid file at ${TPUT_CYAN}${NETDATA_PREFIX}/var/run/netdata.pid${TPUT_RESET}
  406. - logrotate file at ${TPUT_CYAN}/etc/logrotate.d/netdata${TPUT_RESET}
  407. BANNER2
  408. cat << BANNER3
  409. This installer allows you to change the installation path.
  410. Press Control-C and run the same command with --help for help.
  411. BANNER3
  412. if [ -z "$NETDATA_DISABLE_TELEMETRY" ]; then
  413. cat << BANNER4
  414. ${TPUT_YELLOW}${TPUT_BOLD}NOTE${TPUT_RESET}:
  415. Anonymous usage stats will be collected and sent to Netdata.
  416. To opt-out, pass --disable-telemetry option to the installer or export
  417. the environment variable DISABLE_TELEMETRY to a non-zero or non-empty value
  418. (e.g: export DISABLE_TELEMETRY=1).
  419. BANNER4
  420. fi
  421. have_autotools=
  422. if [ "$(type autoreconf 2> /dev/null)" ]; then
  423. autoconf_maj_min() {
  424. OLDIFS=$IFS
  425. IFS=.-
  426. maj=$1
  427. min=$2
  428. # shellcheck disable=SC2046
  429. set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
  430. # shellcheck disable=SC2086
  431. eval $maj=\$1 $min=\$2
  432. IFS=$OLDIFS
  433. }
  434. autoconf_maj_min AMAJ AMIN
  435. if [ "$AMAJ" -gt 2 ]; then
  436. have_autotools=Y
  437. elif [ "$AMAJ" -eq 2 ] && [ "$AMIN" -ge 60 ]; then
  438. have_autotools=Y
  439. else
  440. echo "Found autotools $AMAJ.$AMIN"
  441. fi
  442. else
  443. echo "No autotools found"
  444. fi
  445. if [ ! "$have_autotools" ]; then
  446. if [ -f configure ]; then
  447. echo "Will skip autoreconf step"
  448. else
  449. fatal "Could not find a usable version of GNU autotools, which is required for building Netdata. Version 2.60 or later of GNU autotools is required." I0001
  450. fi
  451. fi
  452. if [ ${DONOTWAIT} -eq 0 ]; then
  453. if [ -n "${NETDATA_PREFIX}" ]; then
  454. printf '%s' "${TPUT_BOLD}${TPUT_GREEN}Press ENTER to build and install netdata to '${TPUT_CYAN}${NETDATA_PREFIX}${TPUT_YELLOW}'${TPUT_RESET} > "
  455. else
  456. printf '%s' "${TPUT_BOLD}${TPUT_GREEN}Press ENTER to build and install netdata to your system${TPUT_RESET} > "
  457. fi
  458. read -r REPLY
  459. if [ "$REPLY" != '' ]; then
  460. exit_reason "User did not accept install attempt." I0011
  461. exit 1
  462. fi
  463. fi
  464. build_error() {
  465. netdata_banner
  466. trap - EXIT
  467. fatal "Netdata failed to build for an unknown reason." I0002
  468. }
  469. if [ ${LIBS_ARE_HERE} -eq 1 ]; then
  470. shift
  471. echo >&2 "ok, assuming libs are really installed."
  472. export ZLIB_CFLAGS=" "
  473. export ZLIB_LIBS="-lz"
  474. export UUID_CFLAGS=" "
  475. export UUID_LIBS="-luuid"
  476. fi
  477. trap build_error EXIT
  478. # -----------------------------------------------------------------------------
  479. build_protobuf() {
  480. env_cmd=''
  481. if [ -z "${DONT_SCRUB_CFLAGS_EVEN_THOUGH_IT_MAY_BREAK_THINGS}" ]; then
  482. env_cmd="env CFLAGS='-fPIC -pipe' CXXFLAGS='-fPIC -pipe' LDFLAGS="
  483. fi
  484. cd "${1}" > /dev/null || return 1
  485. if ! run eval "${env_cmd} ./configure --disable-shared --without-zlib --disable-dependency-tracking --with-pic"; then
  486. cd - > /dev/null || return 1
  487. return 1
  488. fi
  489. if ! run eval "${env_cmd} ${make} ${MAKEOPTS}"; then
  490. cd - > /dev/null || return 1
  491. return 1
  492. fi
  493. cd - > /dev/null || return 1
  494. }
  495. copy_protobuf() {
  496. target_dir="${PWD}/externaldeps/protobuf"
  497. run mkdir -p "${target_dir}" || return 1
  498. run cp -a "${1}/src" "${target_dir}" || return 1
  499. }
  500. bundle_protobuf() {
  501. if [ -n "${NETDATA_DISABLE_CLOUD}" ] && [ -n "${NETDATA_DISABLE_PROMETHEUS}" ]; then
  502. echo "Skipping protobuf"
  503. return 0
  504. fi
  505. if [ -n "${USE_SYSTEM_PROTOBUF}" ]; then
  506. echo "Skipping protobuf"
  507. warning "You have requested use of a system copy of protobuf. This should work, but it is not recommended as it's very likely to break if you upgrade the currently installed version of protobuf."
  508. return 0
  509. fi
  510. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Bundling protobuf."
  511. PROTOBUF_PACKAGE_VERSION="$(cat packaging/protobuf.version)"
  512. if [ -f "${PWD}/externaldeps/protobuf/.version" ] && [ "${PROTOBUF_PACKAGE_VERSION}" = "$(cat "${PWD}/externaldeps/protobuf/.version")" ]
  513. then
  514. echo >&2 "Found compiled protobuf, same version, not compiling it again. Remove file '${PWD}/externaldeps/protobuf/.version' to recompile."
  515. NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --with-bundled-protobuf"
  516. return 0
  517. fi
  518. tmp="$(mktemp -d -t netdata-protobuf-XXXXXX)"
  519. PROTOBUF_PACKAGE_BASENAME="protobuf-cpp-${PROTOBUF_PACKAGE_VERSION}.tar.gz"
  520. if fetch_and_verify "protobuf" \
  521. "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_PACKAGE_VERSION}/${PROTOBUF_PACKAGE_BASENAME}" \
  522. "${PROTOBUF_PACKAGE_BASENAME}" \
  523. "${tmp}" \
  524. "${NETDATA_LOCAL_TARBALL_VERRIDE_PROTOBUF}"; then
  525. if run tar --no-same-owner -xf "${tmp}/${PROTOBUF_PACKAGE_BASENAME}" -C "${tmp}" &&
  526. build_protobuf "${tmp}/protobuf-${PROTOBUF_PACKAGE_VERSION}" &&
  527. copy_protobuf "${tmp}/protobuf-${PROTOBUF_PACKAGE_VERSION}" &&
  528. echo "${PROTOBUF_PACKAGE_VERSION}" >"${PWD}/externaldeps/protobuf/.version" &&
  529. rm -rf "${tmp}"; then
  530. run_ok "protobuf built and prepared."
  531. NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --with-bundled-protobuf"
  532. else
  533. run_failed "Failed to build protobuf. Netdata Cloud support will not be available in this build."
  534. fi
  535. else
  536. run_failed "Unable to fetch sources for protobuf. Netdata Cloud support will not be available in this build."
  537. fi
  538. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  539. }
  540. bundle_protobuf
  541. # -----------------------------------------------------------------------------
  542. build_jsonc() {
  543. env_cmd=''
  544. if [ -z "${DONT_SCRUB_CFLAGS_EVEN_THOUGH_IT_MAY_BREAK_THINGS}" ]; then
  545. env_cmd="env CFLAGS='-fPIC -pipe' CXXFLAGS='-fPIC -pipe' LDFLAGS="
  546. fi
  547. cd "${1}" > /dev/null || exit 1
  548. run eval "${env_cmd} cmake -DBUILD_SHARED_LIBS=OFF ."
  549. run eval "${env_cmd} ${make} ${MAKEOPTS}"
  550. cd - > /dev/null || return 1
  551. }
  552. copy_jsonc() {
  553. target_dir="${PWD}/externaldeps/jsonc"
  554. run mkdir -p "${target_dir}" "${target_dir}/json-c" || return 1
  555. run cp "${1}/libjson-c.a" "${target_dir}/libjson-c.a" || return 1
  556. # shellcheck disable=SC2086
  557. run cp ${1}/*.h "${target_dir}/json-c" || return 1
  558. }
  559. bundle_jsonc() {
  560. # If --build-json-c flag or not json-c on system, then bundle our own json-c
  561. if [ -z "${NETDATA_BUILD_JSON_C}" ] && pkg-config json-c; then
  562. return 0
  563. fi
  564. if [ -z "$(command -v cmake)" ]; then
  565. run_failed "Could not find cmake, which is required to build JSON-C. The install process will continue, but Netdata Cloud support will be disabled."
  566. return 0
  567. fi
  568. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Bundling JSON-C."
  569. progress "Prepare JSON-C"
  570. JSONC_PACKAGE_VERSION="$(cat packaging/jsonc.version)"
  571. tmp="$(mktemp -d -t netdata-jsonc-XXXXXX)"
  572. JSONC_PACKAGE_BASENAME="json-c-${JSONC_PACKAGE_VERSION}.tar.gz"
  573. if fetch_and_verify "jsonc" \
  574. "https://github.com/json-c/json-c/archive/${JSONC_PACKAGE_BASENAME}" \
  575. "${JSONC_PACKAGE_BASENAME}" \
  576. "${tmp}" \
  577. "${NETDATA_LOCAL_TARBALL_OVERRIDE_JSONC}"; then
  578. if run tar --no-same-owner -xf "${tmp}/${JSONC_PACKAGE_BASENAME}" -C "${tmp}" &&
  579. build_jsonc "${tmp}/json-c-json-c-${JSONC_PACKAGE_VERSION}" &&
  580. copy_jsonc "${tmp}/json-c-json-c-${JSONC_PACKAGE_VERSION}" &&
  581. rm -rf "${tmp}"; then
  582. run_ok "JSON-C built and prepared."
  583. else
  584. run_failed "Failed to build JSON-C, Netdata Cloud support will be disabled in this build."
  585. fi
  586. else
  587. run_failed "Unable to fetch sources for JSON-C, Netdata Cloud support will be disabled in this build."
  588. fi
  589. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  590. }
  591. bundle_jsonc
  592. # -----------------------------------------------------------------------------
  593. get_kernel_version() {
  594. r="$(uname -r | cut -f 1 -d '-')"
  595. tmpfile="$(mktemp)"
  596. echo "${r}" | tr '.' ' ' > "${tmpfile}"
  597. read -r maj min patch _ < "${tmpfile}"
  598. rm -f "${tmpfile}"
  599. printf "%03d%03d%03d" "${maj}" "${min}" "${patch}"
  600. }
  601. detect_libc() {
  602. libc=
  603. if ldd --version 2>&1 | grep -q -i glibc; then
  604. echo >&2 " Detected GLIBC"
  605. libc="glibc"
  606. elif ldd --version 2>&1 | grep -q -i 'gnu libc'; then
  607. echo >&2 " Detected GLIBC"
  608. libc="glibc"
  609. elif ldd --version 2>&1 | grep -q -i musl; then
  610. echo >&2 " Detected musl"
  611. libc="musl"
  612. else
  613. cmd=$(ldd /bin/sh | grep -w libc | cut -d" " -f 3)
  614. if bash -c "${cmd}" 2>&1 | grep -q -i "GNU C Library"; then
  615. echo >&2 " Detected GLIBC"
  616. libc="glibc"
  617. fi
  618. fi
  619. if [ -z "$libc" ]; then
  620. warning "Cannot detect a supported libc on your system, eBPF support will be disabled."
  621. return 1
  622. fi
  623. echo "${libc}"
  624. return 0
  625. }
  626. rename_libbpf_packaging() {
  627. if [ "$(get_kernel_version)" -ge "004014000" ]; then
  628. cp packaging/current_libbpf.checksums packaging/libbpf.checksums
  629. cp packaging/current_libbpf.version packaging/libbpf.version
  630. else
  631. cp packaging/libbpf_0_0_9.checksums packaging/libbpf.checksums
  632. cp packaging/libbpf_0_0_9.version packaging/libbpf.version
  633. fi
  634. }
  635. build_libbpf() {
  636. cd "${1}/src" > /dev/null || return 1
  637. mkdir root build
  638. # shellcheck disable=SC2086
  639. run env CFLAGS='-fPIC -pipe' CXXFLAGS='-fPIC -pipe' LDFLAGS= BUILD_STATIC_ONLY=y OBJDIR=build DESTDIR=.. ${make} ${MAKEOPTS} install
  640. cd - > /dev/null || return 1
  641. }
  642. copy_libbpf() {
  643. target_dir="${PWD}/externaldeps/libbpf"
  644. if [ "$(uname -m)" = x86_64 ]; then
  645. lib_subdir="lib64"
  646. else
  647. lib_subdir="lib"
  648. fi
  649. run mkdir -p "${target_dir}" || return 1
  650. run cp "${1}/usr/${lib_subdir}/libbpf.a" "${target_dir}/libbpf.a" || return 1
  651. run cp -r "${1}/usr/include" "${target_dir}" || return 1
  652. run cp -r "${1}/include/uapi" "${target_dir}/include" || return 1
  653. }
  654. bundle_libbpf() {
  655. if { [ -n "${NETDATA_DISABLE_EBPF}" ] && [ ${NETDATA_DISABLE_EBPF} = 1 ]; } || [ "$(uname -s)" != Linux ]; then
  656. return 0
  657. fi
  658. # When libc is not detected, we do not have necessity to compile libbpf and we should not do download of eBPF programs
  659. libc="${EBPF_LIBC:-"$(detect_libc)"}"
  660. if [ -z "$libc" ]; then
  661. NETDATA_DISABLE_EBPF=1
  662. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-ebpf)}" | sed 's/$/ --disable-ebpf/g')"
  663. return 0
  664. fi
  665. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Bundling libbpf."
  666. rename_libbpf_packaging
  667. progress "Prepare libbpf"
  668. LIBBPF_PACKAGE_VERSION="$(cat packaging/libbpf.version)"
  669. tmp="$(mktemp -d -t netdata-libbpf-XXXXXX)"
  670. LIBBPF_PACKAGE_BASENAME="v${LIBBPF_PACKAGE_VERSION}.tar.gz"
  671. if fetch_and_verify "libbpf" \
  672. "https://github.com/netdata/libbpf/archive/${LIBBPF_PACKAGE_BASENAME}" \
  673. "${LIBBPF_PACKAGE_BASENAME}" \
  674. "${tmp}" \
  675. "${NETDATA_LOCAL_TARBALL_OVERRIDE_LIBBPF}"; then
  676. if run tar --no-same-owner -xf "${tmp}/${LIBBPF_PACKAGE_BASENAME}" -C "${tmp}" &&
  677. build_libbpf "${tmp}/libbpf-${LIBBPF_PACKAGE_VERSION}" &&
  678. copy_libbpf "${tmp}/libbpf-${LIBBPF_PACKAGE_VERSION}" &&
  679. rm -rf "${tmp}"; then
  680. run_ok "libbpf built and prepared."
  681. else
  682. if [ -n "${NETDATA_DISABLE_EBPF}" ] && [ ${NETDATA_DISABLE_EBPF} = 0 ]; then
  683. fatal "failed to build libbpf." I0005
  684. else
  685. run_failed "Failed to build libbpf. eBPF support will be disabled"
  686. fi
  687. fi
  688. else
  689. if [ -n "${NETDATA_DISABLE_EBPF}" ] && [ ${NETDATA_DISABLE_EBPF} = 0 ]; then
  690. fatal "Failed to fetch sources for libbpf." I0006
  691. else
  692. run_failed "Unable to fetch sources for libbpf. eBPF support will be disabled"
  693. fi
  694. fi
  695. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  696. }
  697. bundle_libbpf
  698. copy_co_re() {
  699. cp -R "${1}/includes" "collectors/ebpf.plugin/"
  700. }
  701. bundle_ebpf_co_re() {
  702. if { [ -n "${NETDATA_DISABLE_EBPF}" ] && [ ${NETDATA_DISABLE_EBPF} = 1 ]; } || [ "$(uname -s)" != Linux ]; then
  703. return 0
  704. fi
  705. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Bundling libbpf."
  706. progress "eBPF CO-RE"
  707. CORE_PACKAGE_VERSION="$(cat packaging/ebpf-co-re.version)"
  708. tmp="$(mktemp -d -t netdata-ebpf-co-re-XXXXXX)"
  709. CORE_PACKAGE_BASENAME="netdata-ebpf-co-re-glibc-${CORE_PACKAGE_VERSION}.tar.xz"
  710. if fetch_and_verify "ebpf-co-re" \
  711. "https://github.com/netdata/ebpf-co-re/releases/download/${CORE_PACKAGE_VERSION}/${CORE_PACKAGE_BASENAME}" \
  712. "${CORE_PACKAGE_BASENAME}" \
  713. "${tmp}" \
  714. "${NETDATA_LOCAL_TARBALL_OVERRIDE_CORE}"; then
  715. if run tar --no-same-owner -xf "${tmp}/${CORE_PACKAGE_BASENAME}" -C "${tmp}" &&
  716. copy_co_re "${tmp}" &&
  717. rm -rf "${tmp}"; then
  718. run_ok "libbpf built and prepared."
  719. else
  720. if [ -n "${NETDATA_DISABLE_EBPF}" ] && [ ${NETDATA_DISABLE_EBPF} = 0 ]; then
  721. fatal "Failed to get eBPF CO-RE files." I0007
  722. else
  723. run_failed "Failed to get eBPF CO-RE files. eBPF support will be disabled"
  724. NETDATA_DISABLE_EBPF=1
  725. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-ebpf)}" | sed 's/$/ --disable-ebpf/g')"
  726. fi
  727. fi
  728. else
  729. if [ -n "${NETDATA_DISABLE_EBPF}" ] && [ ${NETDATA_DISABLE_EBPF} = 0 ]; then
  730. fatal "Failed to fetch eBPF CO-RE files." I0008
  731. else
  732. run_failed "Failed to fetch eBPF CO-RE files. eBPF support will be disabled"
  733. NETDATA_DISABLE_EBPF=1
  734. NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--disable-ebpf)}" | sed 's/$/ --disable-ebpf/g')"
  735. fi
  736. fi
  737. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  738. }
  739. bundle_ebpf_co_re
  740. # -----------------------------------------------------------------------------
  741. # If we have the dashboard switching logic, make sure we're on the classic
  742. # dashboard during the install (updates don't work correctly otherwise).
  743. if [ -x "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" ]; then
  744. "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" classic
  745. fi
  746. # -----------------------------------------------------------------------------
  747. # By default, `git` does not update local tags based on remotes. Because
  748. # we use the most recent tag as part of our version determination in
  749. # our build, this can lead to strange versions that look ancient but are
  750. # actually really recent. To avoid this, try and fetch tags if we're
  751. # working in a git checkout.
  752. if [ -d ./.git ] ; then
  753. echo >&2
  754. progress "Updating tags in git to ensure a consistent version number"
  755. run git fetch -t || true
  756. fi
  757. # -----------------------------------------------------------------------------
  758. echo >&2
  759. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Configuring Netdata."
  760. progress "Run autotools to configure the build environment"
  761. if [ "$have_autotools" ]; then
  762. if ! run autoreconf -ivf; then
  763. fatal "Failed to prepare Netdata sources." I0009
  764. fi
  765. fi
  766. # function to extract values from the config file
  767. config_option() {
  768. section="${1}"
  769. key="${2}"
  770. value="${3}"
  771. if [ -x "${NETDATA_PREFIX}/usr/sbin/netdata" ] && [ -r "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]; then
  772. "${NETDATA_PREFIX}/usr/sbin/netdata" \
  773. -c "${NETDATA_PREFIX}/etc/netdata/netdata.conf" \
  774. -W get "${section}" "${key}" "${value}" ||
  775. echo "${value}"
  776. else
  777. echo "${value}"
  778. fi
  779. }
  780. # the user netdata will run as
  781. if [ "$(id -u)" = "0" ]; then
  782. NETDATA_USER="$(config_option "global" "run as user" "netdata")"
  783. ROOT_USER="root"
  784. else
  785. NETDATA_USER="${USER}"
  786. ROOT_USER="${USER}"
  787. fi
  788. NETDATA_GROUP="$(id -g -n "${NETDATA_USER}")"
  789. [ -z "${NETDATA_GROUP}" ] && NETDATA_GROUP="${NETDATA_USER}"
  790. echo >&2 "Netdata user and group set to: ${NETDATA_USER}/${NETDATA_GROUP}"
  791. # shellcheck disable=SC2086
  792. if ! run ./configure \
  793. --prefix="${NETDATA_PREFIX}/usr" \
  794. --sysconfdir="${NETDATA_PREFIX}/etc" \
  795. --localstatedir="${NETDATA_PREFIX}/var" \
  796. --libexecdir="${NETDATA_PREFIX}/usr/libexec" \
  797. --libdir="${NETDATA_PREFIX}/usr/lib" \
  798. --with-zlib \
  799. --with-math \
  800. --with-user="${NETDATA_USER}" \
  801. ${NETDATA_CONFIGURE_OPTIONS} \
  802. CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"; then
  803. fatal "Failed to configure Netdata sources." I000A
  804. fi
  805. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  806. # remove the build_error hook
  807. trap - EXIT
  808. # -----------------------------------------------------------------------------
  809. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Building Netdata."
  810. progress "Cleanup compilation directory"
  811. run $make clean
  812. # -----------------------------------------------------------------------------
  813. progress "Compile netdata"
  814. # shellcheck disable=SC2086
  815. if ! run $make ${MAKEOPTS}; then
  816. fatal "Failed to build Netdata." I000B
  817. fi
  818. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  819. # -----------------------------------------------------------------------------
  820. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Installing Netdata."
  821. # -----------------------------------------------------------------------------
  822. # shellcheck disable=SC2230
  823. md5sum="$(command -v md5sum 2> /dev/null || command -v md5 2> /dev/null)"
  824. deleted_stock_configs=0
  825. if [ ! -f "${NETDATA_PREFIX}/etc/netdata/.installer-cleanup-of-stock-configs-done" ]; then
  826. progress "Backup existing netdata configuration before installing it"
  827. config_signature_matches() {
  828. md5="${1}"
  829. file="${2}"
  830. if [ -f "configs.signatures" ]; then
  831. grep "\['${md5}'\]='${file}'" "configs.signatures" > /dev/null
  832. return $?
  833. fi
  834. return 1
  835. }
  836. # clean up stock config files from the user configuration directory
  837. (find -L "${NETDATA_PREFIX}/etc/netdata" -type f -not -path '*/\.*' -not -path "${NETDATA_PREFIX}/etc/netdata/orig/*" \( -name '*.conf.old' -o -name '*.conf' -o -name '*.conf.orig' -o -name '*.conf.installer_backup.*' \)) | while IFS= read -r x; do
  838. if [ -f "${x}" ]; then
  839. # find it relative filename
  840. f=$("$x" | sed "${NETDATA_PREFIX}/etc/netdata/")
  841. # find the stock filename
  842. t=$("${f}" | sed ".conf.installer_backup.*/.conf")
  843. t=$("${t}" | sed ".conf.old/.conf")
  844. t=$("${t}" | sed ".conf.orig/.conf")
  845. t=$("${t}" | sed "orig//")
  846. if [ -z "${md5sum}" ] || [ ! -x "${md5sum}" ]; then
  847. # we don't have md5sum - keep it
  848. echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED}is not known to distribution${TPUT_RESET}. Keeping it."
  849. else
  850. # find its checksum
  851. md5="$(${md5sum} < "${x}" | cut -d ' ' -f 1)"
  852. if config_signature_matches "${md5}" "${t}"; then
  853. # it is a stock version - remove it
  854. echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' is stock version of '${t}'."
  855. run rm -f "${x}"
  856. # shellcheck disable=SC2030
  857. deleted_stock_configs=$((deleted_stock_configs + 1))
  858. else
  859. # edited by user - keep it
  860. echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED} does not match stock of${TPUT_RESET} ${TPUT_CYAN}'${t}'${TPUT_RESET}. Keeping it."
  861. fi
  862. fi
  863. fi
  864. done
  865. fi
  866. touch "${NETDATA_PREFIX}/etc/netdata/.installer-cleanup-of-stock-configs-done"
  867. # -----------------------------------------------------------------------------
  868. progress "Install netdata"
  869. if ! run $make install; then
  870. fatal "Failed to install Netdata." I000C
  871. fi
  872. # -----------------------------------------------------------------------------
  873. progress "Fix generated files permissions"
  874. run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.timer -a \! -name \*.logrotate -a \! -name \.install-type -exec chmod 755 {} \;
  875. # -----------------------------------------------------------------------------
  876. progress "Creating standard user and groups for netdata"
  877. NETDATA_WANTED_GROUPS="docker nginx varnish haproxy adm nsd proxy squid ceph nobody"
  878. NETDATA_ADDED_TO_GROUPS=""
  879. if [ "$(id -u)" -eq 0 ]; then
  880. progress "Adding group 'netdata'"
  881. portable_add_group netdata || :
  882. progress "Adding user 'netdata'"
  883. portable_add_user netdata "${NETDATA_PREFIX}/var/lib/netdata" || :
  884. progress "Assign user 'netdata' to required groups"
  885. for g in ${NETDATA_WANTED_GROUPS}; do
  886. # shellcheck disable=SC2086
  887. portable_add_user_to_group ${g} netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}"
  888. done
  889. # Netdata must be able to read /etc/pve/qemu-server/* and /etc/pve/lxc/*
  890. # for reading VMs/containers names, CPU and memory limits on Proxmox.
  891. if [ -d "/etc/pve" ]; then
  892. portable_add_user_to_group "www-data" netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} www-data"
  893. fi
  894. else
  895. run_failed "The installer does not run as root. Nothing to do for user and groups"
  896. fi
  897. # -----------------------------------------------------------------------------
  898. progress "Install logrotate configuration for netdata"
  899. install_netdata_logrotate
  900. # -----------------------------------------------------------------------------
  901. progress "Read installation options from netdata.conf"
  902. # create an empty config if it does not exist
  903. [ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] &&
  904. touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
  905. # port
  906. defport=19999
  907. NETDATA_PORT="$(config_option "web" "default port" ${defport})"
  908. # directories
  909. NETDATA_LIB_DIR="$(config_option "global" "lib directory" "${NETDATA_PREFIX}/var/lib/netdata")"
  910. NETDATA_CACHE_DIR="$(config_option "global" "cache directory" "${NETDATA_PREFIX}/var/cache/netdata")"
  911. NETDATA_WEB_DIR="$(config_option "global" "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web")"
  912. NETDATA_LOG_DIR="$(config_option "global" "log directory" "${NETDATA_PREFIX}/var/log/netdata")"
  913. NETDATA_USER_CONFIG_DIR="$(config_option "global" "config directory" "${NETDATA_PREFIX}/etc/netdata")"
  914. NETDATA_STOCK_CONFIG_DIR="$(config_option "global" "stock config directory" "${NETDATA_PREFIX}/usr/lib/netdata/conf.d")"
  915. NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
  916. NETDATA_CLAIMING_DIR="${NETDATA_LIB_DIR}/cloud.d"
  917. cat << OPTIONSEOF
  918. Permissions
  919. - netdata user : ${NETDATA_USER}
  920. - netdata group : ${NETDATA_GROUP}
  921. - root user : ${ROOT_USER}
  922. Directories
  923. - netdata user config dir : ${NETDATA_USER_CONFIG_DIR}
  924. - netdata stock config dir : ${NETDATA_STOCK_CONFIG_DIR}
  925. - netdata log dir : ${NETDATA_LOG_DIR}
  926. - netdata run dir : ${NETDATA_RUN_DIR}
  927. - netdata lib dir : ${NETDATA_LIB_DIR}
  928. - netdata web dir : ${NETDATA_WEB_DIR}
  929. - netdata cache dir : ${NETDATA_CACHE_DIR}
  930. Other
  931. - netdata port : ${NETDATA_PORT}
  932. OPTIONSEOF
  933. # -----------------------------------------------------------------------------
  934. progress "Fix permissions of netdata directories (using user '${NETDATA_USER}')"
  935. if [ ! -d "${NETDATA_RUN_DIR}" ]; then
  936. # this is needed if NETDATA_PREFIX is not empty
  937. if ! run mkdir -p "${NETDATA_RUN_DIR}"; then
  938. warning "Failed to create ${NETDATA_RUN_DIR}, it must becreated by hand or the Netdata Agent will not be able to be started."
  939. fi
  940. fi
  941. # --- stock conf dir ----
  942. [ ! -d "${NETDATA_STOCK_CONFIG_DIR}" ] && mkdir -p "${NETDATA_STOCK_CONFIG_DIR}"
  943. helplink="000.-.USE.THE.orig.LINK.TO.COPY.AND.EDIT.STOCK.CONFIG.FILES"
  944. # shellcheck disable=SC2031
  945. [ ${deleted_stock_configs} -eq 0 ] && helplink=""
  946. for link in "orig" "${helplink}"; do
  947. if [ -n "${link}" ]; then
  948. [ -L "${NETDATA_USER_CONFIG_DIR}/${link}" ] && run rm -f "${NETDATA_USER_CONFIG_DIR}/${link}"
  949. run ln -s "${NETDATA_STOCK_CONFIG_DIR}" "${NETDATA_USER_CONFIG_DIR}/${link}"
  950. fi
  951. done
  952. # --- web dir ----
  953. if [ ! -d "${NETDATA_WEB_DIR}" ]; then
  954. echo >&2 "Creating directory '${NETDATA_WEB_DIR}'"
  955. run mkdir -p "${NETDATA_WEB_DIR}" || exit 1
  956. fi
  957. run find "${NETDATA_WEB_DIR}" -type f -exec chmod 0664 {} \;
  958. run find "${NETDATA_WEB_DIR}" -type d -exec chmod 0775 {} \;
  959. # --- data dirs ----
  960. for x in "${NETDATA_LIB_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}"; do
  961. if [ ! -d "${x}" ]; then
  962. echo >&2 "Creating directory '${x}'"
  963. if ! run mkdir -p "${x}"; then
  964. warning "Failed to create ${x}, it must be created by hand or the Netdata Agent will not be able to be started."
  965. fi
  966. fi
  967. run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${x}"
  968. #run find "${x}" -type f -exec chmod 0660 {} \;
  969. #run find "${x}" -type d -exec chmod 0770 {} \;
  970. done
  971. run chmod 755 "${NETDATA_LOG_DIR}"
  972. # --- claiming dir ----
  973. if [ ! -d "${NETDATA_CLAIMING_DIR}" ]; then
  974. echo >&2 "Creating directory '${NETDATA_CLAIMING_DIR}'"
  975. if ! run mkdir -p "${NETDATA_CLAIMING_DIR}"; then
  976. warning "failed to create ${NETDATA_CLAIMING_DIR}, it will need to be created manually."
  977. fi
  978. fi
  979. run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_CLAIMING_DIR}"
  980. run chmod 770 "${NETDATA_CLAIMING_DIR}"
  981. # --- plugins ----
  982. if [ "$(id -u)" -eq 0 ]; then
  983. # find the admin group
  984. admin_group=
  985. test -z "${admin_group}" && get_group root > /dev/null 2>&1 && admin_group="root"
  986. test -z "${admin_group}" && get_group daemon > /dev/null 2>&1 && admin_group="daemon"
  987. test -z "${admin_group}" && admin_group="${NETDATA_GROUP}"
  988. run chown "${NETDATA_USER}:${admin_group}" "${NETDATA_LOG_DIR}"
  989. run chown -R "root:${admin_group}" "${NETDATA_PREFIX}/usr/libexec/netdata"
  990. run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
  991. run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0644 {} \;
  992. # shellcheck disable=SC2086
  993. run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.plugin -exec chown :${NETDATA_GROUP} {} \;
  994. run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.plugin -exec chmod 0750 {} \;
  995. run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.sh -exec chmod 0755 {} \;
  996. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" ]; then
  997. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
  998. capabilities=0
  999. if ! iscontainer && command -v setcap 1> /dev/null 2>&1; then
  1000. run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
  1001. if run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"; then
  1002. # if we managed to setcap, but we fail to execute apps.plugin setuid to root
  1003. "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" -t > /dev/null 2>&1 && capabilities=1 || capabilities=0
  1004. fi
  1005. fi
  1006. if [ $capabilities -eq 0 ]; then
  1007. # fix apps.plugin to be setuid to root
  1008. run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
  1009. fi
  1010. fi
  1011. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" ]; then
  1012. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin"
  1013. run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin"
  1014. fi
  1015. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin" ]; then
  1016. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin"
  1017. run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin"
  1018. fi
  1019. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin" ]; then
  1020. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin"
  1021. run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin"
  1022. fi
  1023. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin" ]; then
  1024. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin"
  1025. run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin"
  1026. run sh -c "setcap cap_perfmon+ep \"${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin\" || setcap cap_sys_admin+ep \"${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin\""
  1027. fi
  1028. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin" ]; then
  1029. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin"
  1030. run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin"
  1031. run setcap cap_dac_read_search+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin"
  1032. fi
  1033. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping" ]; then
  1034. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
  1035. run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
  1036. fi
  1037. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ebpf.plugin" ]; then
  1038. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ebpf.plugin"
  1039. run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ebpf.plugin"
  1040. fi
  1041. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" ]; then
  1042. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
  1043. run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
  1044. fi
  1045. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh" ]; then
  1046. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh"
  1047. run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh"
  1048. fi
  1049. else
  1050. # non-privileged user installation
  1051. run chown "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_LOG_DIR}"
  1052. run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata"
  1053. run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0755 {} \;
  1054. run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
  1055. fi
  1056. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  1057. # -----------------------------------------------------------------------------
  1058. # govercomp compares go.d.plugin versions. Exit codes:
  1059. # 0 - version1 == version2
  1060. # 1 - version1 > version2
  1061. # 2 - version2 > version1
  1062. # 3 - error
  1063. # shellcheck disable=SC2086
  1064. govercomp() {
  1065. # version in file:
  1066. # - v0.14.0
  1067. #
  1068. # 'go.d.plugin -v' output variants:
  1069. # - go.d.plugin, version: unknown
  1070. # - go.d.plugin, version: v0.14.1
  1071. # - go.d.plugin, version: v0.14.1-dirty
  1072. # - go.d.plugin, version: v0.14.1-1-g4c5f98c
  1073. # - go.d.plugin, version: v0.14.1-1-g4c5f98c-dirty
  1074. # we need to compare only MAJOR.MINOR.PATCH part
  1075. ver1=$(echo "$1" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+")
  1076. ver2=$(echo "$2" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+")
  1077. if [ ${#ver1} -eq 0 ] || [ ${#ver2} -eq 0 ]; then
  1078. return 3
  1079. fi
  1080. num1=$(echo $ver1 | grep -o -E '\.' | wc -l)
  1081. num2=$(echo $ver2 | grep -o -E '\.' | wc -l)
  1082. if [ ${num1} -ne ${num2} ]; then
  1083. return 3
  1084. fi
  1085. for i in $(seq 1 $((num1+1))); do
  1086. x=$(echo $ver1 | cut -d'.' -f$i)
  1087. y=$(echo $ver2 | cut -d'.' -f$i)
  1088. if [ "${x}" -gt "${y}" ]; then
  1089. return 1
  1090. elif [ "${y}" -gt "${x}" ]; then
  1091. return 2
  1092. fi
  1093. done
  1094. return 0
  1095. }
  1096. should_install_go() {
  1097. if [ -n "${NETDATA_DISABLE_GO+x}" ]; then
  1098. return 1
  1099. fi
  1100. version_in_file="$(cat packaging/go.d.version 2> /dev/null)"
  1101. binary_version=$("${NETDATA_PREFIX}"/usr/libexec/netdata/plugins.d/go.d.plugin -v 2> /dev/null)
  1102. govercomp "$version_in_file" "$binary_version"
  1103. case $? in
  1104. 0) return 1 ;; # =
  1105. 2) return 1 ;; # <
  1106. *) return 0 ;; # >, error
  1107. esac
  1108. }
  1109. install_go() {
  1110. if ! should_install_go; then
  1111. return 0
  1112. fi
  1113. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Installing go.d.plugin."
  1114. # When updating this value, ensure correct checksums in packaging/go.d.checksums
  1115. GO_PACKAGE_VERSION="$(cat packaging/go.d.version)"
  1116. ARCH_MAP='
  1117. i386::386
  1118. i686::386
  1119. x86_64::amd64
  1120. aarch64::arm64
  1121. armv64::arm64
  1122. armv6l::arm
  1123. armv7l::arm
  1124. armv5tel::arm
  1125. '
  1126. progress "Install go.d.plugin"
  1127. ARCH=$(uname -m)
  1128. OS=$(uname -s | tr '[:upper:]' '[:lower:]')
  1129. for index in ${ARCH_MAP}; do
  1130. KEY="${index%%::*}"
  1131. VALUE="${index##*::}"
  1132. if [ "$KEY" = "$ARCH" ]; then
  1133. ARCH="${VALUE}"
  1134. break
  1135. fi
  1136. done
  1137. tmp="$(mktemp -d -t netdata-go-XXXXXX)"
  1138. GO_PACKAGE_BASENAME="go.d.plugin-${GO_PACKAGE_VERSION}.${OS}-${ARCH}.tar.gz"
  1139. if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}" ]; then
  1140. download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/${GO_PACKAGE_BASENAME}" "${tmp}/${GO_PACKAGE_BASENAME}"
  1141. else
  1142. progress "Using provided go.d tarball ${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}"
  1143. run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}" "${tmp}/${GO_PACKAGE_BASENAME}"
  1144. fi
  1145. if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}" ]; then
  1146. download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/config.tar.gz" "${tmp}/config.tar.gz"
  1147. else
  1148. progress "Using provided config file for go.d ${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}"
  1149. run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}" "${tmp}/config.tar.gz"
  1150. fi
  1151. if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
  1152. run_failed "go.d plugin download failed, go.d plugin will not be available"
  1153. echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
  1154. echo >&2
  1155. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  1156. return 0
  1157. fi
  1158. grep "${GO_PACKAGE_BASENAME}\$" "${INSTALLER_DIR}/packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2> /dev/null
  1159. grep "config.tar.gz" "${INSTALLER_DIR}/packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2> /dev/null
  1160. # Checksum validation
  1161. if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
  1162. echo >&2 "go.d plugin checksum validation failure."
  1163. echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
  1164. echo >&2
  1165. run_failed "go.d.plugin package files checksum validation failed. go.d.plugin will not be available."
  1166. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  1167. return 0
  1168. fi
  1169. # Install new files
  1170. run rm -rf "${NETDATA_STOCK_CONFIG_DIR}/go.d"
  1171. run rm -rf "${NETDATA_STOCK_CONFIG_DIR}/go.d.conf"
  1172. run tar --no-same-owner -xf "${tmp}/config.tar.gz" -C "${NETDATA_STOCK_CONFIG_DIR}/"
  1173. run chown -R "${ROOT_USER}:${ROOT_GROUP}" "${NETDATA_STOCK_CONFIG_DIR}"
  1174. run tar --no-same-owner -xf "${tmp}/${GO_PACKAGE_BASENAME}"
  1175. run mv "${GO_PACKAGE_BASENAME%.tar.gz}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
  1176. if [ "$(id -u)" -eq 0 ]; then
  1177. run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
  1178. fi
  1179. run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
  1180. if command -v setcap 1>/dev/null 2>&1; then
  1181. run setcap "cap_net_admin+epi cap_net_raw=eip" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
  1182. fi
  1183. rm -rf "${tmp}"
  1184. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  1185. }
  1186. install_go
  1187. should_install_ebpf() {
  1188. if [ "${NETDATA_DISABLE_EBPF:=0}" -eq 1 ]; then
  1189. run_failed "eBPF has been explicitly disabled, it will not be available in this install."
  1190. return 1
  1191. fi
  1192. if [ "$(uname -s)" != "Linux" ] || [ "$(uname -m)" != "x86_64" ]; then
  1193. if [ "${NETDATA_DISABLE_EBPF:=1}" -eq 0 ]; then
  1194. run_failed "Currently eBPF is only supported on Linux on X86_64."
  1195. fi
  1196. return 1
  1197. fi
  1198. # Check Kernel Config
  1199. if ! run "${INSTALLER_DIR}"/packaging/check-kernel-config.sh; then
  1200. warning "Kernel unsupported or missing required config (eBPF may not work on your system)"
  1201. fi
  1202. return 0
  1203. }
  1204. remove_old_ebpf() {
  1205. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ebpf_process.plugin" ]; then
  1206. echo >&2 "Removing alpha eBPF collector."
  1207. rm -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ebpf_process.plugin"
  1208. fi
  1209. if [ -f "${NETDATA_PREFIX}/usr/lib/netdata/conf.d/ebpf_process.conf" ]; then
  1210. echo >&2 "Removing alpha eBPF stock file"
  1211. rm -f "${NETDATA_PREFIX}/usr/lib/netdata/conf.d/ebpf_process.conf"
  1212. fi
  1213. if [ -f "${NETDATA_PREFIX}/etc/netdata/ebpf_process.conf" ]; then
  1214. echo >&2 "Renaming eBPF configuration file."
  1215. mv "${NETDATA_PREFIX}/etc/netdata/ebpf_process.conf" "${NETDATA_PREFIX}/etc/netdata/ebpf.d.conf"
  1216. fi
  1217. # Added to remove eBPF programs with name pattern: NAME_VERSION.SUBVERSION.PATCH
  1218. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/pnetdata_ebpf_process.3.10.0.o" ]; then
  1219. echo >&2 "Removing old eBPF programs with patch."
  1220. rm -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/rnetdata_ebpf"*.?.*.*.o
  1221. rm -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/pnetdata_ebpf"*.?.*.*.o
  1222. fi
  1223. # Remove old eBPF program to store new eBPF program inside subdirectory
  1224. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/pnetdata_ebpf_process.3.10.o" ]; then
  1225. echo >&2 "Removing old eBPF programs installed in old directory."
  1226. rm -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/rnetdata_ebpf"*.?.*.o
  1227. rm -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/pnetdata_ebpf"*.?.*.o
  1228. fi
  1229. # Remove old reject list from previous directory
  1230. if [ -f "${NETDATA_PREFIX}/usr/lib/netdata/conf.d/ebpf_kernel_reject_list.txt" ]; then
  1231. echo >&2 "Removing old ebpf_kernel_reject_list.txt."
  1232. rm -f "${NETDATA_PREFIX}/usr/lib/netdata/conf.d/ebpf_kernel_reject_list.txt"
  1233. fi
  1234. # Remove old reset script
  1235. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/reset_netdata_trace.sh" ]; then
  1236. echo >&2 "Removing old reset_netdata_trace.sh."
  1237. rm -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/reset_netdata_trace.sh"
  1238. fi
  1239. }
  1240. install_ebpf() {
  1241. if ! should_install_ebpf; then
  1242. return 0
  1243. fi
  1244. [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Installing eBPF code."
  1245. remove_old_ebpf
  1246. progress "Installing eBPF plugin"
  1247. # Detect libc
  1248. libc="${EBPF_LIBC:-"$(detect_libc)"}"
  1249. EBPF_VERSION="$(cat packaging/ebpf.version)"
  1250. EBPF_TARBALL="netdata-kernel-collector-${libc}-${EBPF_VERSION}.tar.xz"
  1251. tmp="$(mktemp -d -t netdata-ebpf-XXXXXX)"
  1252. if ! fetch_and_verify "ebpf" \
  1253. "https://github.com/netdata/kernel-collector/releases/download/${EBPF_VERSION}/${EBPF_TARBALL}" \
  1254. "${EBPF_TARBALL}" \
  1255. "${tmp}" \
  1256. "${NETDATA_LOCAL_TARBALL_OVERRIDE_EBPF}"; then
  1257. run_failed "Failed to download eBPF collector package"
  1258. echo 2>&" Removing temporary directory ${tmp} ..."
  1259. rm -rf "${tmp}"
  1260. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  1261. return 1
  1262. fi
  1263. echo >&2 " Extracting ${EBPF_TARBALL} ..."
  1264. tar --no-same-owner -xf "${tmp}/${EBPF_TARBALL}" -C "${tmp}"
  1265. # chown everything to root:netdata before we start copying out of our package
  1266. run chown -R root:netdata "${tmp}"
  1267. if [ ! -d "${NETDATA_PREFIX}"/usr/libexec/netdata/plugins.d/ebpf.d ]; then
  1268. mkdir "${NETDATA_PREFIX}"/usr/libexec/netdata/plugins.d/ebpf.d
  1269. RET=$?
  1270. if [ "${RET}" != "0" ]; then
  1271. rm -rf "${tmp}"
  1272. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  1273. return 1
  1274. fi
  1275. fi
  1276. run cp -a -v "${tmp}"/*netdata_ebpf_*.o "${NETDATA_PREFIX}"/usr/libexec/netdata/plugins.d/ebpf.d
  1277. rm -rf "${tmp}"
  1278. [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
  1279. }
  1280. progress "eBPF Kernel Collector"
  1281. install_ebpf
  1282. # -----------------------------------------------------------------------------
  1283. progress "Telemetry configuration"
  1284. # Opt-out from telemetry program
  1285. if [ -n "${NETDATA_DISABLE_TELEMETRY+x}" ]; then
  1286. run touch "${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics"
  1287. else
  1288. printf "You can opt out from anonymous statistics via the --disable-telemetry option, or by creating an empty file %s \n\n" "${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics"
  1289. fi
  1290. # -----------------------------------------------------------------------------
  1291. progress "Install netdata at system init"
  1292. # By default we assume the shutdown/startup of the Netdata Agent are effectively
  1293. # without any system supervisor/init like SystemD or SysV. So we assume the most
  1294. # basic startup/shutdown commands...
  1295. NETDATA_STOP_CMD="${NETDATA_PREFIX}/usr/sbin/netdatacli shutdown-agent"
  1296. NETDATA_START_CMD="${NETDATA_PREFIX}/usr/sbin/netdata"
  1297. if grep -q docker /proc/1/cgroup > /dev/null 2>&1; then
  1298. # If docker runs systemd for some weird reason, let the install proceed
  1299. is_systemd_running="NO"
  1300. if command -v pidof > /dev/null 2>&1; then
  1301. is_systemd_running="$(pidof /usr/sbin/init || pidof systemd || echo "NO")"
  1302. else
  1303. is_systemd_running="$( (pgrep -q -f systemd && echo "1") || echo "NO")"
  1304. fi
  1305. if [ "${is_systemd_running}" = "1" ]; then
  1306. echo >&2 "Found systemd within the docker container, running install_netdata_service() method"
  1307. install_netdata_service || run_failed "Cannot install netdata init service."
  1308. else
  1309. echo >&2 "We are running within a docker container, will not be installing netdata service"
  1310. fi
  1311. echo >&2
  1312. else
  1313. install_netdata_service || run_failed "Cannot install netdata init service."
  1314. fi
  1315. # -----------------------------------------------------------------------------
  1316. # check if we can re-start netdata
  1317. # TODO(paulfantom): Creation of configuration file should be handled by a build system. Additionally we shouldn't touch configuration files in /etc/netdata/...
  1318. started=0
  1319. if [ ${DONOTSTART} -eq 1 ]; then
  1320. create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
  1321. else
  1322. if ! restart_netdata "${NETDATA_PREFIX}/usr/sbin/netdata" "${@}"; then
  1323. fatal "Cannot start netdata!" I000D
  1324. fi
  1325. started=1
  1326. run_ok "netdata started!"
  1327. create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:${NETDATA_PORT}/netdata.conf"
  1328. fi
  1329. run chmod 0644 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
  1330. if [ "$(uname)" = "Linux" ]; then
  1331. # -------------------------------------------------------------------------
  1332. progress "Check KSM (kernel memory deduper)"
  1333. ksm_is_available_but_disabled() {
  1334. cat << KSM1
  1335. ${TPUT_BOLD}Memory de-duplication instructions${TPUT_RESET}
  1336. You have kernel memory de-duper (called Kernel Same-page Merging,
  1337. or KSM) available, but it is not currently enabled.
  1338. To enable it run:
  1339. ${TPUT_YELLOW}${TPUT_BOLD}echo 1 >/sys/kernel/mm/ksm/run${TPUT_RESET}
  1340. ${TPUT_YELLOW}${TPUT_BOLD}echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs${TPUT_RESET}
  1341. If you enable it, you will save 40-60% of netdata memory.
  1342. KSM1
  1343. }
  1344. ksm_is_not_available() {
  1345. cat << KSM2
  1346. ${TPUT_BOLD}Memory de-duplication not present in your kernel${TPUT_RESET}
  1347. It seems you do not have kernel memory de-duper (called Kernel Same-page
  1348. Merging, or KSM) available.
  1349. To enable it, you need a kernel built with CONFIG_KSM=y
  1350. If you can have it, you will save 40-60% of netdata memory.
  1351. KSM2
  1352. }
  1353. if [ -f "/sys/kernel/mm/ksm/run" ]; then
  1354. if [ "$(cat "/sys/kernel/mm/ksm/run")" != "1" ]; then
  1355. ksm_is_available_but_disabled
  1356. fi
  1357. else
  1358. ksm_is_not_available
  1359. fi
  1360. fi
  1361. # -----------------------------------------------------------------------------
  1362. progress "Check version.txt"
  1363. if [ ! -s web/gui/version.txt ]; then
  1364. cat << VERMSG
  1365. ${TPUT_BOLD}Version update check warning${TPUT_RESET}
  1366. The way you downloaded netdata, we cannot find its version. This means the
  1367. Update check on the dashboard, will not work.
  1368. If you want to have version update check, please re-install it
  1369. following the procedure in:
  1370. https://docs.netdata.cloud/packaging/installer/
  1371. VERMSG
  1372. fi
  1373. if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" ]; then
  1374. # -----------------------------------------------------------------------------
  1375. progress "Check apps.plugin"
  1376. if [ "$(id -u)" -ne 0 ]; then
  1377. cat << SETUID_WARNING
  1378. ${TPUT_BOLD}apps.plugin needs privileges${TPUT_RESET}
  1379. Since you have installed netdata as a normal user, to have apps.plugin collect
  1380. all the needed data, you have to give it the access rights it needs, by running
  1381. either of the following sets of commands:
  1382. To run apps.plugin with escalated capabilities:
  1383. ${TPUT_YELLOW}${TPUT_BOLD}sudo chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"${TPUT_RESET}
  1384. ${TPUT_YELLOW}${TPUT_BOLD}sudo chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"${TPUT_RESET}
  1385. ${TPUT_YELLOW}${TPUT_BOLD}sudo setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"${TPUT_RESET}
  1386. or, to run apps.plugin as root:
  1387. ${TPUT_YELLOW}${TPUT_BOLD}sudo chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"${TPUT_RESET}
  1388. ${TPUT_YELLOW}${TPUT_BOLD}sudo chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"${TPUT_RESET}
  1389. apps.plugin is performing a hard-coded function of data collection for all
  1390. running processes. It cannot be instructed from the netdata daemon to perform
  1391. any task, so it is pretty safe to do this.
  1392. SETUID_WARNING
  1393. fi
  1394. fi
  1395. # -----------------------------------------------------------------------------
  1396. progress "Copy uninstaller"
  1397. if [ -f "${NETDATA_PREFIX}"/usr/libexec/netdata-uninstaller.sh ]; then
  1398. echo >&2 "Removing uninstaller from old location"
  1399. rm -f "${NETDATA_PREFIX}"/usr/libexec/netdata-uninstaller.sh
  1400. fi
  1401. sed "s|ENVIRONMENT_FILE=\"/etc/netdata/.environment\"|ENVIRONMENT_FILE=\"${NETDATA_PREFIX}/etc/netdata/.environment\"|" packaging/installer/netdata-uninstaller.sh > "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh"
  1402. chmod 750 "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh"
  1403. # -----------------------------------------------------------------------------
  1404. progress "Basic netdata instructions"
  1405. cat << END
  1406. netdata by default listens on all IPs on port ${NETDATA_PORT},
  1407. so you can access it with:
  1408. ${TPUT_CYAN}${TPUT_BOLD}http://this.machine.ip:${NETDATA_PORT}/${TPUT_RESET}
  1409. To stop netdata run:
  1410. ${TPUT_YELLOW}${TPUT_BOLD}${NETDATA_STOP_CMD}${TPUT_RESET}
  1411. To start netdata run:
  1412. ${TPUT_YELLOW}${TPUT_BOLD}${NETDATA_START_CMD}${TPUT_RESET}
  1413. END
  1414. echo >&2 "Uninstall script copied to: ${TPUT_RED}${TPUT_BOLD}${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh${TPUT_RESET}"
  1415. echo >&2
  1416. # -----------------------------------------------------------------------------
  1417. progress "Installing (but not enabling) the netdata updater tool"
  1418. install_netdata_updater || run_failed "Cannot install netdata updater tool."
  1419. # -----------------------------------------------------------------------------
  1420. progress "Wrap up environment set up"
  1421. # Save environment variables
  1422. echo >&2 "Preparing .environment file"
  1423. cat << EOF > "${NETDATA_USER_CONFIG_DIR}/.environment"
  1424. # Created by installer
  1425. PATH="${PATH}"
  1426. CFLAGS="${CFLAGS}"
  1427. LDFLAGS="${LDFLAGS}"
  1428. MAKEOPTS="${MAKEOPTS}"
  1429. NETDATA_TMPDIR="${TMPDIR}"
  1430. NETDATA_PREFIX="${NETDATA_PREFIX}"
  1431. NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS}"
  1432. NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS}"
  1433. INSTALL_UID="$(id -u)"
  1434. NETDATA_GROUP="${NETDATA_GROUP}"
  1435. REINSTALL_OPTIONS="${REINSTALL_OPTIONS}"
  1436. RELEASE_CHANNEL="${RELEASE_CHANNEL}"
  1437. IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY}"
  1438. NETDATA_LIB_DIR="${NETDATA_LIB_DIR}"
  1439. EOF
  1440. run chmod 0644 "${NETDATA_USER_CONFIG_DIR}/.environment"
  1441. echo >&2 "Setting netdata.tarball.checksum to 'new_installation'"
  1442. cat << EOF > "${NETDATA_LIB_DIR}/netdata.tarball.checksum"
  1443. new_installation
  1444. EOF
  1445. print_deferred_errors
  1446. # -----------------------------------------------------------------------------
  1447. echo >&2
  1448. progress "We are done!"
  1449. if [ ${started} -eq 1 ]; then
  1450. netdata_banner
  1451. progress "is installed and running now!"
  1452. else
  1453. netdata_banner
  1454. progress "is installed now!"
  1455. fi
  1456. echo >&2 " enjoy real-time performance and health monitoring..."
  1457. echo >&2
  1458. exit 0