netdata-installer.sh 66 KB

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