netdata-installer.sh 66 KB

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