netdata-installer.sh 66 KB

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