Fixes and improves the installer/updater shell scripts. (#7847)
* Auto-formatted the installer/updater shell scripts * Fixed shellcheck problems founds for installer/updater shell scripts * Update netdata-installer.sh Co-Authored-By: Konstantinos Natsakis <5933427+knatsakis@users.noreply.github.com> * Update packaging/installer/kickstart-static64.sh Co-Authored-By: Konstantinos Natsakis <5933427+knatsakis@users.noreply.github.com> * Update packaging/makeself/install-or-update.sh Co-Authored-By: Konstantinos Natsakis <5933427+knatsakis@users.noreply.github.com> * Updated md5sum of kickstart-static64.sh in docs * Fixed bad rebase/merge conflicts Co-authored-by: Konstantinos Natsakis <5933427+knatsakis@users.noreply.github.com>
James Mills committed
Jan 28, 2020 at 05:52 UTC
a4223457b49497f57bd199dfaf5cf35c4fb86997
4 files changed
+810
-823
netdata-installer.sh
+495
-496
@@ -1,18 +1,19 @@
1
#!/usr/bin/env bash
2
+
3
# SPDX-License-Identifier: GPL-3.0-or-later
4
# shellcheck disable=SC2046,SC2086,SC2166
5
6
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
7
uniquepath() {
7
- local path=""
8
- while read -r; do
9
- if [[ ! ${path} =~ (^|:)"${REPLY}"(:|$) ]]; then
10
- [ -n "${path}" ] && path="${path}:"
11
- path="${path}${REPLY}"
12
- fi
13
- done < <(echo "${PATH}" | tr ":" "\\n")
14
-
15
- [ -n "${path}" ] && [[ ${PATH} =~ /bin ]] && [[ ${PATH} =~ /sbin ]] && export PATH="${path}"
8
+ local path=""
9
+ while read -r; do
10
+ if [[ ! ${path} =~ (^|:)"${REPLY}"(:|$) ]]; then
11
+ [ -n "${path}" ] && path="${path}:"
12
+ path="${path}${REPLY}"
13
+ fi
14
+ done < <(echo "${PATH}" | tr ":" "\\n")
15
+
16
+ [ -n "${path}" ] && [[ ${PATH} =~ /bin ]] && [[ ${PATH} =~ /sbin ]] && export PATH="${path}"
17
}
18
uniquepath
19
@@ -21,7 +22,7 @@ NETDATA_SOURCE_DIR="$(pwd)"
22
INSTALLER_DIR="$(dirname "${PROGRAM}")"
23
24
if [ "${NETDATA_SOURCE_DIR}" != "${INSTALLER_DIR}" ] && [ "${INSTALLER_DIR}" != "." ]; then
24
- echo >&2 "Warning: you are currently in '${NETDATA_SOURCE_DIR}' but the installer is in '${INSTALLER_DIR}'."
25
+ echo >&2 "Warning: you are currently in '${NETDATA_SOURCE_DIR}' but the installer is in '${INSTALLER_DIR}'."
26
fi
27
28
# -----------------------------------------------------------------------------
@@ -37,29 +38,29 @@ cd "${NETDATA_SOURCE_DIR}" || exit 1
38
# load the required functions
39
40
if [ -f "${INSTALLER_DIR}/packaging/installer/functions.sh" ]; then
40
- # shellcheck source=packaging/installer/functions.sh
41
- source "${INSTALLER_DIR}/packaging/installer/functions.sh" || exit 1
41
+ # shellcheck source=packaging/installer/functions.sh
42
+ source "${INSTALLER_DIR}/packaging/installer/functions.sh" || exit 1
43
else
43
- # shellcheck source=packaging/installer/functions.sh
44
- source "${NETDATA_SOURCE_DIR}/packaging/installer/functions.sh" || exit 1
44
+ # shellcheck source=packaging/installer/functions.sh
45
+ source "${NETDATA_SOURCE_DIR}/packaging/installer/functions.sh" || exit 1
46
fi
47
48
download_go() {
48
- url="${1}"
49
- dest="${2}"
50
-
51
- if command -v curl >/dev/null 2>&1; then
52
- run curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${dest}"
53
- elif command -v wget >/dev/null 2>&1; then
54
- run wget -T 15 -O - "${url}" > "${dest}"
55
- else
56
- echo >&2
57
- echo >&2 "Downloading go.d plugin from '${url}' failed because of missing mandatory packages."
58
- echo >&2 "Either add packages or disable it by issuing '--disable-go' in the installer"
59
- echo >&2
60
-
61
- run_failed "I need curl or wget to proceed, but neither is available on this system."
62
- fi
49
+ url="${1}"
50
+ dest="${2}"
51
+
52
+ if command -v curl > /dev/null 2>&1; then
53
+ run curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${dest}"
54
+ elif command -v wget > /dev/null 2>&1; then
55
+ run wget -T 15 -O - "${url}" > "${dest}"
56
+ else
57
+ echo >&2
58
+ echo >&2 "Downloading go.d plugin from '${url}' failed because of missing mandatory packages."
59
+ echo >&2 "Either add packages or disable it by issuing '--disable-go' in the installer"
60
+ echo >&2
61
+
62
+ run_failed "I need curl or wget to proceed, but neither is available on this system."
63
+ fi
64
}
65
66
# make sure we save all commands we run
@@ -69,15 +70,15 @@ run_logfile="netdata-installer.log"
70
# fix PKG_CHECK_MODULES error
71
72
if [ -d /usr/share/aclocal ]; then
72
- ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
73
- export ACLOCAL_PATH
73
+ ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
74
+ export ACLOCAL_PATH
75
fi
76
77
export LC_ALL=C
78
umask 002
79
80
# Be nice on production environments
80
-renice 19 $$ >/dev/null 2>/dev/null
81
+renice 19 $$ > /dev/null 2> /dev/null
82
83
# you can set CFLAGS before running installer
84
LDFLAGS="${LDFLAGS}"
@@ -86,22 +87,22 @@ CFLAGS="${CFLAGS--O2}"
87
88
# keep a log of this command
89
# shellcheck disable=SC2129
89
-printf "\\n# " >>netdata-installer.log
90
-date >>netdata-installer.log
91
-printf 'CFLAGS="%s" ' "${CFLAGS}" >>netdata-installer.log
92
-printf 'LDFLAGS="%s" ' "${LDFLAGS}" >>netdata-installer.log
93
-printf "%q " "${PROGRAM}" "${@}" >>netdata-installer.log
94
-printf "\\n" >>netdata-installer.log
90
+printf "\\n# " >> netdata-installer.log
91
+date >> netdata-installer.log
92
+printf 'CFLAGS="%s" ' "${CFLAGS}" >> netdata-installer.log
93
+printf 'LDFLAGS="%s" ' "${LDFLAGS}" >> netdata-installer.log
94
+printf "%q " "${PROGRAM}" "${@}" >> netdata-installer.log
95
+printf "\\n" >> netdata-installer.log
96
97
REINSTALL_OPTIONS="$(
97
- printf "%s" "${*}"
98
- printf "\\n"
98
+ printf "%s" "${*}"
99
+ printf "\\n"
100
)"
101
# remove options that shown not be inherited by netdata-updater.sh
102
REINSTALL_OPTIONS="$(echo "${REINSTALL_OPTIONS}" | sed 's/--dont-wait//g' | sed 's/--dont-start-it//g')"
103
104
banner_nonroot_install() {
104
- cat <<NONROOTNOPREFIX
105
+ cat << NONROOTNOPREFIX
106
107
${TPUT_RED}${TPUT_BOLD}Sorry! This will fail!${TPUT_RESET}
108
@@ -125,7 +126,7 @@ NONROOTNOPREFIX
126
}
127
128
banner_root_notify() {
128
- cat <<NONROOT
129
+ cat << NONROOT
130
131
${TPUT_RED}${TPUT_BOLD}IMPORTANT${TPUT_RESET}:
132
You are about to install netdata as a non-root user.
@@ -141,8 +142,8 @@ NONROOT
142
}
143
144
usage() {
144
- netdata_banner "installer command line options"
145
- cat <<HEREDOC
145
+ netdata_banner "installer command line options"
146
+ cat << HEREDOC
147
148
USAGE: ${PROGRAM} [options]
149
where options include:
@@ -213,65 +214,65 @@ NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS-}"
214
RELEASE_CHANNEL="nightly" # check .travis/create_artifacts.sh before modifying
215
IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY:-"no"}"
216
while [ -n "${1}" ]; do
216
- case "${1}" in
217
- "--zlib-is-really-here") LIBS_ARE_HERE=1;;
218
- "--libs-are-really-here") LIBS_ARE_HERE=1;;
219
- "--dont-start-it") DONOTSTART=1;;
220
- "--dont-wait") DONOTWAIT=1;;
221
- "--auto-update"|"-u") AUTOUPDATE=1;;
222
- "--stable-channel") RELEASE_CHANNEL="stable";;
223
- "--nightly-channel") RELEASE_CHANNEL="nightly";;
224
- "--enable-plugin-freeipmi") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-freeipmi/} --enable-plugin-freeipmi";;
225
- "--disable-plugin-freeipmi") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-freeipmi/} --disable-plugin-freeipmi";;
226
- "--disable-https") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-https/} --disable-https";;
227
- "--disable-dbengine") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-dbengine/} --disable-dbengine";;
228
- "--enable-plugin-nfacct") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-nfacct/} --enable-plugin-nfacct";;
229
- "--disable-plugin-nfacct") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-nfacct/} --disable-plugin-nfacct";;
230
- "--enable-plugin-xenstat") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-xenstat/} --enable-plugin-xenstat";;
231
- "--disable-plugin-xenstat") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-xenstat/} --disable-plugin-xenstat";;
232
- "--enable-backend-kinesis") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-backend-kinesis/} --enable-backend-kinesis";;
233
- "--disable-backend-kinesis") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-backend-kinesis/} --disable-backend-kinesis";;
234
- "--enable-backend-prometheus-remote-write") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-backend-prometheus-remote-write/} --enable-backend-prometheus-remote-write";;
235
- "--disable-backend-prometheus-remote-write") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-backend-prometheus-remote-write/} --disable-backend-prometheus-remote-write";;
236
- "--enable-backend-mongodb") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-backend-mongodb/} --enable-backend-mongodb";;
237
- "--disable-backend-mongodb") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-backend-mongodb/} --disable-backend-mongodb";;
238
- "--enable-lto") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-lto/} --enable-lto";;
239
- "--disable-lto") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-lto/} --disable-lto";;
240
- "--disable-x86-sse") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-x86-sse/} --disable-x86-sse";;
241
- "--disable-telemetry") NETDATA_DISABLE_TELEMETRY=1;;
242
- "--disable-go") NETDATA_DISABLE_GO=1;;
243
- "--install")
244
- NETDATA_PREFIX="${2}/netdata"
245
- shift 1
246
- ;;
247
- "--help"|"-h")
248
- usage
249
- exit 1
250
- ;;
251
- *)
252
- run_failed "I cannot understand option '$1'."
253
- usage
254
- exit 1
255
- ;;
256
- esac
257
- shift 1
217
+ case "${1}" in
218
+ "--zlib-is-really-here") LIBS_ARE_HERE=1 ;;
219
+ "--libs-are-really-here") LIBS_ARE_HERE=1 ;;
220
+ "--dont-start-it") DONOTSTART=1 ;;
221
+ "--dont-wait") DONOTWAIT=1 ;;
222
+ "--auto-update" | "-u") AUTOUPDATE=1 ;;
223
+ "--stable-channel") RELEASE_CHANNEL="stable" ;;
224
+ "--nightly-channel") RELEASE_CHANNEL="nightly" ;;
225
+ "--enable-plugin-freeipmi") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-freeipmi/} --enable-plugin-freeipmi" ;;
226
+ "--disable-plugin-freeipmi") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-freeipmi/} --disable-plugin-freeipmi" ;;
227
+ "--disable-https") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-https/} --disable-https" ;;
228
+ "--disable-dbengine") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-dbengine/} --disable-dbengine" ;;
229
+ "--enable-plugin-nfacct") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-nfacct/} --enable-plugin-nfacct" ;;
230
+ "--disable-plugin-nfacct") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-nfacct/} --disable-plugin-nfacct" ;;
231
+ "--enable-plugin-xenstat") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-xenstat/} --enable-plugin-xenstat" ;;
232
+ "--disable-plugin-xenstat") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-xenstat/} --disable-plugin-xenstat" ;;
233
+ "--enable-backend-kinesis") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-backend-kinesis/} --enable-backend-kinesis" ;;
234
+ "--disable-backend-kinesis") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-backend-kinesis/} --disable-backend-kinesis" ;;
235
+ "--enable-backend-prometheus-remote-write") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-backend-prometheus-remote-write/} --enable-backend-prometheus-remote-write" ;;
236
+ "--disable-backend-prometheus-remote-write") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-backend-prometheus-remote-write/} --disable-backend-prometheus-remote-write" ;;
237
+ "--enable-backend-mongodb") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-backend-mongodb/} --enable-backend-mongodb" ;;
238
+ "--disable-backend-mongodb") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-backend-mongodb/} --disable-backend-mongodb" ;;
239
+ "--enable-lto") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-lto/} --enable-lto" ;;
240
+ "--disable-lto") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-lto/} --disable-lto" ;;
241
+ "--disable-x86-sse") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-x86-sse/} --disable-x86-sse" ;;
242
+ "--disable-telemetry") NETDATA_DISABLE_TELEMETRY=1 ;;
243
+ "--disable-go") NETDATA_DISABLE_GO=1 ;;
244
+ "--install")
245
+ NETDATA_PREFIX="${2}/netdata"
246
+ shift 1
247
+ ;;
248
+ "--help" | "-h")
249
+ usage
250
+ exit 1
251
+ ;;
252
+ *)
253
+ run_failed "I cannot understand option '$1'."
254
+ usage
255
+ exit 1
256
+ ;;
257
+ esac
258
+ shift 1
259
done
260
261
# replace multiple spaces with a single space
262
NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS// / }"
263
264
if [ "${UID}" -ne 0 ]; then
264
- if [ -z "${NETDATA_PREFIX}" ]; then
265
- netdata_banner "wrong command line options!"
266
- banner_nonroot_install "${@}"
267
- exit 1
268
- else
269
- banner_root_notify "${@}"
270
- fi
265
+ if [ -z "${NETDATA_PREFIX}" ]; then
266
+ netdata_banner "wrong command line options!"
267
+ banner_nonroot_install "${@}"
268
+ exit 1
269
+ else
270
+ banner_root_notify "${@}"
271
+ fi
272
fi
273
274
netdata_banner "real-time performance monitoring, done right!"
274
-cat <<BANNER1
275
+cat << BANNER1
276
277
You are about to build and install netdata to your system.
278
@@ -286,12 +287,12 @@ cat <<BANNER1
287
- log files in ${TPUT_CYAN}${NETDATA_PREFIX}/var/log/netdata${TPUT_RESET}
288
BANNER1
289
289
-[ "${UID}" -eq 0 ] && cat <<BANNER2
290
+[ "${UID}" -eq 0 ] && cat << BANNER2
291
- pid file at ${TPUT_CYAN}${NETDATA_PREFIX}/var/run/netdata.pid${TPUT_RESET}
292
- logrotate file at ${TPUT_CYAN}/etc/logrotate.d/netdata${TPUT_RESET}
293
BANNER2
294
294
-cat <<BANNER3
295
+cat << BANNER3
296
297
This installer allows you to change the installation path.
298
Press Control-C and run the same command with --help for help.
@@ -299,7 +300,7 @@ cat <<BANNER3
300
BANNER3
301
302
if [ -z "$NETDATA_DISABLE_TELEMETRY" ]; then
302
- cat <<BANNER4
303
+ cat << BANNER4
304
305
${TPUT_YELLOW}${TPUT_BOLD}NOTE${TPUT_RESET}:
306
Anonymous usage stats will be collected and sent to Google Analytics.
@@ -309,35 +310,35 @@ BANNER4
310
fi
311
312
have_autotools=
312
-if [ "$(type autoreconf 2>/dev/null)" ]; then
313
- autoconf_maj_min() {
314
- local maj min IFS=.-
315
-
316
- maj=$1
317
- min=$2
318
-
319
- set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
320
- eval $maj=\$1 $min=\$2
321
- }
322
- autoconf_maj_min AMAJ AMIN
323
-
324
- if [ "$AMAJ" -gt 2 ]; then
325
- have_autotools=Y
326
- elif [ "$AMAJ" -eq 2 -a "$AMIN" -ge 60 ]; then
327
- have_autotools=Y
328
- else
329
- echo "Found autotools $AMAJ.$AMIN"
330
- fi
313
+if [ "$(type autoreconf 2> /dev/null)" ]; then
314
+ autoconf_maj_min() {
315
+ local maj min IFS=.-
316
+
317
+ maj=$1
318
+ min=$2
319
+
320
+ set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
321
+ eval $maj=\$1 $min=\$2
322
+ }
323
+ autoconf_maj_min AMAJ AMIN
324
+
325
+ if [ "$AMAJ" -gt 2 ]; then
326
+ have_autotools=Y
327
+ elif [ "$AMAJ" -eq 2 -a "$AMIN" -ge 60 ]; then
328
+ have_autotools=Y
329
+ else
330
+ echo "Found autotools $AMAJ.$AMIN"
331
+ fi
332
else
332
- echo "No autotools found"
333
+ echo "No autotools found"
334
fi
335
336
if [ ! "$have_autotools" ]; then
336
- if [ -f configure ]; then
337
- echo "Will skip autoreconf step"
338
- else
339
- netdata_banner "autotools v2.60 required"
340
- cat <<"EOF"
337
+ if [ -f configure ]; then
338
+ echo "Will skip autoreconf step"
339
+ else
340
+ netdata_banner "autotools v2.60 required"
341
+ cat << "EOF"
342
343
-------------------------------------------------------------------------------
344
autotools 2.60 or later is required
@@ -346,26 +347,26 @@ Sorry, you do not seem to have autotools 2.60 or later, which is
347
required to build from the git sources of netdata.
348
349
EOF
349
- exit 1
350
- fi
350
+ exit 1
351
+ fi
352
fi
353
354
if [ ${DONOTWAIT} -eq 0 ]; then
354
- if [ -n "${NETDATA_PREFIX}" ]; then
355
- echo -n "${TPUT_BOLD}${TPUT_GREEN}Press ENTER to build and install netdata to '${TPUT_CYAN}${NETDATA_PREFIX}${TPUT_YELLOW}'${TPUT_RESET} > "
356
- else
357
- echo -n "${TPUT_BOLD}${TPUT_GREEN}Press ENTER to build and install netdata to your system${TPUT_RESET} > "
358
- fi
359
- read -ern1
360
- if [ "$REPLY" != '' ]; then
361
- exit 1
362
- fi
355
+ if [ -n "${NETDATA_PREFIX}" ]; then
356
+ echo -n "${TPUT_BOLD}${TPUT_GREEN}Press ENTER to build and install netdata to '${TPUT_CYAN}${NETDATA_PREFIX}${TPUT_YELLOW}'${TPUT_RESET} > "
357
+ else
358
+ echo -n "${TPUT_BOLD}${TPUT_GREEN}Press ENTER to build and install netdata to your system${TPUT_RESET} > "
359
+ fi
360
+ read -ern1
361
+ if [ "$REPLY" != '' ]; then
362
+ exit 1
363
+ fi
364
365
fi
366
367
build_error() {
367
- netdata_banner "sorry, it failed to build..."
368
- cat <<EOF
368
+ netdata_banner "sorry, it failed to build..."
369
+ cat << EOF
370
371
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
372
@@ -395,17 +396,17 @@ If you still cannot get it to build, ask for help at github:
396
397
398
EOF
398
- trap - EXIT
399
- exit 1
399
+ trap - EXIT
400
+ exit 1
401
}
402
403
if [ ${LIBS_ARE_HERE} -eq 1 ]; then
403
- shift
404
- echo >&2 "ok, assuming libs are really installed."
405
- export ZLIB_CFLAGS=" "
406
- export ZLIB_LIBS="-lz"
407
- export UUID_CFLAGS=" "
408
- export UUID_LIBS="-luuid"
404
+ shift
405
+ echo >&2 "ok, assuming libs are really installed."
406
+ export ZLIB_CFLAGS=" "
407
+ export ZLIB_LIBS="-lz"
408
+ export UUID_CFLAGS=" "
409
+ export UUID_LIBS="-luuid"
410
fi
411
412
trap build_error EXIT
@@ -415,20 +416,20 @@ echo >&2
416
progress "Run autotools to configure the build environment"
417
418
if [ "$have_autotools" ]; then
418
- run autoreconf -ivf || exit 1
419
+ run autoreconf -ivf || exit 1
420
fi
421
422
run ./configure \
422
- --prefix="${NETDATA_PREFIX}/usr" \
423
- --sysconfdir="${NETDATA_PREFIX}/etc" \
424
- --localstatedir="${NETDATA_PREFIX}/var" \
425
- --libexecdir="${NETDATA_PREFIX}/usr/libexec" \
426
- --libdir="${NETDATA_PREFIX}/usr/lib" \
427
- --with-zlib \
428
- --with-math \
429
- --with-user=netdata \
430
- ${NETDATA_CONFIGURE_OPTIONS} \
431
- CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" || exit 1
423
+ --prefix="${NETDATA_PREFIX}/usr" \
424
+ --sysconfdir="${NETDATA_PREFIX}/etc" \
425
+ --localstatedir="${NETDATA_PREFIX}/var" \
426
+ --libexecdir="${NETDATA_PREFIX}/usr/libexec" \
427
+ --libdir="${NETDATA_PREFIX}/usr/lib" \
428
+ --with-zlib \
429
+ --with-math \
430
+ --with-user=netdata \
431
+ ${NETDATA_CONFIGURE_OPTIONS} \
432
+ CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" || exit 1
433
434
# remove the build_error hook
435
trap - EXIT
@@ -449,99 +450,99 @@ progress "Migrate configuration files for node.d.plugin and charts.d.plugin"
450
# migrate existing configuration files
451
# for node.d and charts.d
452
if [ -d "${NETDATA_PREFIX}/etc/netdata" ]; then
452
- # the configuration directory exists
453
-
454
- if [ ! -d "${NETDATA_PREFIX}/etc/netdata/charts.d" ]; then
455
- run mkdir "${NETDATA_PREFIX}/etc/netdata/charts.d"
456
- fi
457
-
458
- # move the charts.d config files
459
- 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
460
- for y in "" ".old" ".orig"; do
461
- if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}" ]; then
462
- run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}"
463
- fi
464
- done
465
- done
466
-
467
- if [ ! -d "${NETDATA_PREFIX}/etc/netdata/node.d" ]; then
468
- run mkdir "${NETDATA_PREFIX}/etc/netdata/node.d"
469
- fi
470
-
471
- # move the node.d config files
472
- for x in named sma_webbox snmp; do
473
- for y in "" ".old" ".orig"; do
474
- if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}" ]; then
475
- run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}"
476
- fi
477
- done
478
- done
453
+ # the configuration directory exists
454
+
455
+ if [ ! -d "${NETDATA_PREFIX}/etc/netdata/charts.d" ]; then
456
+ run mkdir "${NETDATA_PREFIX}/etc/netdata/charts.d"
457
+ fi
458
+
459
+ # move the charts.d config files
460
+ 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
461
+ for y in "" ".old" ".orig"; do
462
+ if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}" ]; then
463
+ run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}"
464
+ fi
465
+ done
466
+ done
467
+
468
+ if [ ! -d "${NETDATA_PREFIX}/etc/netdata/node.d" ]; then
469
+ run mkdir "${NETDATA_PREFIX}/etc/netdata/node.d"
470
+ fi
471
+
472
+ # move the node.d config files
473
+ for x in named sma_webbox snmp; do
474
+ for y in "" ".old" ".orig"; do
475
+ if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}" ]; then
476
+ run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}"
477
+ fi
478
+ done
479
+ done
480
fi
481
482
# -----------------------------------------------------------------------------
483
484
# shellcheck disable=SC2230
484
-md5sum="$(command -v md5sum 2>/dev/null || command -v md5 2>/dev/null)"
485
+md5sum="$(command -v md5sum 2> /dev/null || command -v md5 2> /dev/null)"
486
487
deleted_stock_configs=0
488
if [ ! -f "${NETDATA_PREFIX}/etc/netdata/.installer-cleanup-of-stock-configs-done" ]; then
489
489
- progress "Backup existing netdata configuration before installing it"
490
-
491
- if [ "${BASH_VERSINFO[0]}" -ge "4" ]; then
492
- declare -A configs_signatures=()
493
- if [ -f "configs.signatures" ]; then
494
- source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !"
495
- fi
496
- fi
497
-
498
- config_signature_matches() {
499
- local md5="${1}" file="${2}"
500
-
501
- if [ "${BASH_VERSINFO[0]}" -ge "4" ]; then
502
- [ "${configs_signatures[${md5}]}" = "${file}" ] && return 0
503
- return 1
504
- fi
505
-
506
- if [ -f "configs.signatures" ]; then
507
- grep "\['${md5}'\]='${file}'" "configs.signatures" >/dev/null
508
- return $?
509
- fi
510
-
511
- return 1
512
- }
513
-
514
- # clean up stock config files from the user configuration directory
515
- for x in $(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.*' \)); do
516
- if [ -f "${x}" ]; then
517
- # find it relative filename
518
- f="${x/${NETDATA_PREFIX}\/etc\/netdata\//}"
519
-
520
- # find the stock filename
521
- t="${f/.conf.installer_backup.*/.conf}"
522
- t="${t/.conf.old/.conf}"
523
- t="${t/.conf.orig/.conf}"
524
- t="${t/orig\//}"
525
-
526
- if [ -z "${md5sum}" -o ! -x "${md5sum}" ]; then
527
- # we don't have md5sum - keep it
528
- echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RET}is not known to distribution${TPUT_RESET}. Keeping it."
529
- else
530
- # find its checksum
531
- md5="$(${md5sum} <"${x}" | cut -d ' ' -f 1)"
532
-
533
- if config_signature_matches "${md5}" "${t}"; then
534
- # it is a stock version - remove it
535
- echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' is stock version of '${t}'."
536
- run rm -f "${x}"
537
- deleted_stock_configs=$((deleted_stock_configs + 1))
538
- else
539
- # edited by user - keep it
540
- echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED} does not match stock of${TPUT_RESET} ${TPUT_CYAN}'${t}'${TPUT_RESET}. Keeping it."
541
- fi
542
- fi
543
- fi
544
- done
490
+ progress "Backup existing netdata configuration before installing it"
491
+
492
+ if [ "${BASH_VERSINFO[0]}" -ge "4" ]; then
493
+ declare -A configs_signatures=()
494
+ if [ -f "configs.signatures" ]; then
495
+ source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !"
496
+ fi
497
+ fi
498
+
499
+ config_signature_matches() {
500
+ local md5="${1}" file="${2}"
501
+
502
+ if [ "${BASH_VERSINFO[0]}" -ge "4" ]; then
503
+ [ "${configs_signatures[${md5}]}" = "${file}" ] && return 0
504
+ return 1
505
+ fi
506
+
507
+ if [ -f "configs.signatures" ]; then
508
+ grep "\['${md5}'\]='${file}'" "configs.signatures" > /dev/null
509
+ return $?
510
+ fi
511
+
512
+ return 1
513
+ }
514
+
515
+ # clean up stock config files from the user configuration directory
516
+ while IFS= read -r -d '' x; do
517
+ if [ -f "${x}" ]; then
518
+ # find it relative filename
519
+ f="${x/${NETDATA_PREFIX}\/etc\/netdata\//}"
520
+
521
+ # find the stock filename
522
+ t="${f/.conf.installer_backup.*/.conf}"
523
+ t="${t/.conf.old/.conf}"
524
+ t="${t/.conf.orig/.conf}"
525
+ t="${t/orig\//}"
526
+
527
+ if [ -z "${md5sum}" -o ! -x "${md5sum}" ]; then
528
+ # we don't have md5sum - keep it
529
+ echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED}is not known to distribution${TPUT_RESET}. Keeping it."
530
+ else
531
+ # find its checksum
532
+ md5="$(${md5sum} < "${x}" | cut -d ' ' -f 1)"
533
+
534
+ if config_signature_matches "${md5}" "${t}"; then
535
+ # it is a stock version - remove it
536
+ echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' is stock version of '${t}'."
537
+ run rm -f "${x}"
538
+ deleted_stock_configs=$((deleted_stock_configs + 1))
539
+ else
540
+ # edited by user - keep it
541
+ echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED} does not match stock of${TPUT_RESET} ${TPUT_CYAN}'${t}'${TPUT_RESET}. Keeping it."
542
+ fi
543
+ fi
544
+ fi
545
+ 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.*' \))
546
fi
547
touch "${NETDATA_PREFIX}/etc/netdata/.installer-cleanup-of-stock-configs-done"
548
@@ -561,19 +562,19 @@ progress "Creating standard user and groups for netdata"
562
NETDATA_WANTED_GROUPS="docker nginx varnish haproxy adm nsd proxy squid ceph nobody"
563
NETDATA_ADDED_TO_GROUPS=""
564
if [ "${UID}" -eq 0 ]; then
564
- progress "Adding group 'netdata'"
565
- portable_add_group netdata || :
565
+ progress "Adding group 'netdata'"
566
+ portable_add_group netdata || :
567
567
- progress "Adding user 'netdata'"
568
- portable_add_user netdata "${NETDATA_PREFIX}/var/lib/netdata" || :
568
+ progress "Adding user 'netdata'"
569
+ portable_add_user netdata "${NETDATA_PREFIX}/var/lib/netdata" || :
570
570
- progress "Assign user 'netdata' to required groups"
571
- for g in ${NETDATA_WANTED_GROUPS}; do
572
- # shellcheck disable=SC2086
573
- portable_add_user_to_group ${g} netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}"
574
- done
571
+ progress "Assign user 'netdata' to required groups"
572
+ for g in ${NETDATA_WANTED_GROUPS}; do
573
+ # shellcheck disable=SC2086
574
+ portable_add_user_to_group ${g} netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}"
575
+ done
576
else
576
- run_failed "The installer does not run as root. Nothing to do for user and groups"
577
+ run_failed "The installer does not run as root. Nothing to do for user and groups"
578
fi
579
580
# -----------------------------------------------------------------------------
@@ -581,35 +582,34 @@ progress "Install logrotate configuration for netdata"
582
583
install_netdata_logrotate
584
584
-
585
# -----------------------------------------------------------------------------
586
progress "Read installation options from netdata.conf"
587
588
# create an empty config if it does not exist
589
[ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] &&
590
- touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
590
+ touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
591
592
# function to extract values from the config file
593
config_option() {
594
- local section="${1}" key="${2}" value="${3}"
595
-
596
- if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]; then
597
- "${NETDATA_PREFIX}/usr/sbin/netdata" \
598
- -c "${NETDATA_PREFIX}/etc/netdata/netdata.conf" \
599
- -W get "${section}" "${key}" "${value}" ||
600
- echo "${value}"
601
- else
602
- echo "${value}"
603
- fi
594
+ local section="${1}" key="${2}" value="${3}"
595
+
596
+ if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]; then
597
+ "${NETDATA_PREFIX}/usr/sbin/netdata" \
598
+ -c "${NETDATA_PREFIX}/etc/netdata/netdata.conf" \
599
+ -W get "${section}" "${key}" "${value}" ||
600
+ echo "${value}"
601
+ else
602
+ echo "${value}"
603
+ fi
604
}
605
606
# the user netdata will run as
607
if [ "${UID}" = "0" ]; then
608
- NETDATA_USER="$(config_option "global" "run as user" "netdata")"
609
- ROOT_USER="root"
608
+ NETDATA_USER="$(config_option "global" "run as user" "netdata")"
609
+ ROOT_USER="root"
610
else
611
- NETDATA_USER="${USER}"
612
- ROOT_USER="${USER}"
611
+ NETDATA_USER="${USER}"
612
+ ROOT_USER="${USER}"
613
fi
614
NETDATA_GROUP="$(id -g -n "${NETDATA_USER}")"
615
[ -z "${NETDATA_GROUP}" ] && NETDATA_GROUP="${NETDATA_USER}"
@@ -619,8 +619,8 @@ echo >&2 "Netdata user and group is finally set to: ${NETDATA_USER}/${NETDATA_GR
619
NETDATA_WEB_USER="$(config_option "web" "web files owner" "${NETDATA_USER}")"
620
NETDATA_WEB_GROUP="${NETDATA_GROUP}"
621
if [ "${UID}" = "0" ] && [ "${NETDATA_USER}" != "${NETDATA_WEB_USER}" ]; then
622
- NETDATA_WEB_GROUP="$(id -g -n "${NETDATA_WEB_USER}")"
623
- [ -z "${NETDATA_WEB_GROUP}" ] && NETDATA_WEB_GROUP="${NETDATA_WEB_USER}"
622
+ NETDATA_WEB_GROUP="$(id -g -n "${NETDATA_WEB_USER}")"
623
+ [ -z "${NETDATA_WEB_GROUP}" ] && NETDATA_WEB_GROUP="${NETDATA_WEB_USER}"
624
fi
625
NETDATA_WEB_GROUP="$(config_option "web" "web files group" "${NETDATA_WEB_GROUP}")"
626
@@ -638,7 +638,7 @@ NETDATA_STOCK_CONFIG_DIR="$(config_option "global" "stock config directory" "${N
638
NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
639
NETDATA_CLAIMING_DIR="${NETDATA_USER_CONFIG_DIR}/claim.d"
640
641
-cat <<OPTIONSEOF
641
+cat << OPTIONSEOF
642
643
Permissions
644
- netdata user : ${NETDATA_USER}
@@ -665,8 +665,8 @@ OPTIONSEOF
665
progress "Fix permissions of netdata directories (using user '${NETDATA_USER}')"
666
667
if [ ! -d "${NETDATA_RUN_DIR}" ]; then
668
- # this is needed if NETDATA_PREFIX is not empty
669
- run mkdir -p "${NETDATA_RUN_DIR}" || exit 1
668
+ # this is needed if NETDATA_PREFIX is not empty
669
+ run mkdir -p "${NETDATA_RUN_DIR}" || exit 1
670
fi
671
672
# --- stock conf dir ----
@@ -676,17 +676,17 @@ fi
676
helplink="000.-.USE.THE.orig.LINK.TO.COPY.AND.EDIT.STOCK.CONFIG.FILES"
677
[ ${deleted_stock_configs} -eq 0 ] && helplink=""
678
for link in "orig" "${helplink}"; do
679
- if [ ! -z "${link}" ]; then
680
- [ -L "${NETDATA_USER_CONFIG_DIR}/${link}" ] && run rm -f "${NETDATA_USER_CONFIG_DIR}/${link}"
681
- run ln -s "${NETDATA_STOCK_CONFIG_DIR}" "${NETDATA_USER_CONFIG_DIR}/${link}"
682
- fi
679
+ if [ -n "${link}" ]; then
680
+ [ -L "${NETDATA_USER_CONFIG_DIR}/${link}" ] && run rm -f "${NETDATA_USER_CONFIG_DIR}/${link}"
681
+ run ln -s "${NETDATA_STOCK_CONFIG_DIR}" "${NETDATA_USER_CONFIG_DIR}/${link}"
682
+ fi
683
done
684
685
# --- web dir ----
686
687
if [ ! -d "${NETDATA_WEB_DIR}" ]; then
688
- echo >&2 "Creating directory '${NETDATA_WEB_DIR}'"
689
- run mkdir -p "${NETDATA_WEB_DIR}" || exit 1
688
+ echo >&2 "Creating directory '${NETDATA_WEB_DIR}'"
689
+ run mkdir -p "${NETDATA_WEB_DIR}" || exit 1
690
fi
691
run chown -R "${NETDATA_WEB_USER}:${NETDATA_WEB_GROUP}" "${NETDATA_WEB_DIR}"
692
run find "${NETDATA_WEB_DIR}" -type f -exec chmod 0664 {} \;
@@ -695,14 +695,14 @@ run find "${NETDATA_WEB_DIR}" -type d -exec chmod 0775 {} \;
695
# --- data dirs ----
696
697
for x in "${NETDATA_LIB_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}"; do
698
- if [ ! -d "${x}" ]; then
699
- echo >&2 "Creating directory '${x}'"
700
- run mkdir -p "${x}" || exit 1
701
- fi
702
-
703
- run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${x}"
704
- #run find "${x}" -type f -exec chmod 0660 {} \;
705
- #run find "${x}" -type d -exec chmod 0770 {} \;
698
+ if [ ! -d "${x}" ]; then
699
+ echo >&2 "Creating directory '${x}'"
700
+ run mkdir -p "${x}" || exit 1
701
+ fi
702
+
703
+ run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${x}"
704
+ #run find "${x}" -type f -exec chmod 0660 {} \;
705
+ #run find "${x}" -type d -exec chmod 0770 {} \;
706
done
707
708
run chmod 755 "${NETDATA_LOG_DIR}"
@@ -710,8 +710,8 @@ run chmod 755 "${NETDATA_LOG_DIR}"
710
# --- claiming dir ----
711
712
if [ ! -d "${NETDATA_CLAIMING_DIR}" ]; then
713
- echo >&2 "Creating directory '${NETDATA_CLAIMING_DIR}'"
714
- run mkdir -p "${NETDATA_CLAIMING_DIR}" || exit 1
713
+ echo >&2 "Creating directory '${NETDATA_CLAIMING_DIR}'"
714
+ run mkdir -p "${NETDATA_CLAIMING_DIR}" || exit 1
715
fi
716
run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_CLAIMING_DIR}"
717
run chmod 770 "${NETDATA_CLAIMING_DIR}"
@@ -719,166 +719,166 @@ run chmod 770 "${NETDATA_CLAIMING_DIR}"
719
# --- plugins ----
720
721
if [ "${UID}" -eq 0 ]; then
722
- # find the admin group
723
- admin_group=
724
- test -z "${admin_group}" && getent group root >/dev/null 2>&1 && admin_group="root"
725
- test -z "${admin_group}" && getent group daemon >/dev/null 2>&1 && admin_group="daemon"
726
- test -z "${admin_group}" && admin_group="${NETDATA_GROUP}"
727
-
728
- run chown "${NETDATA_USER}:${admin_group}" "${NETDATA_LOG_DIR}"
729
- run chown -R "root:${admin_group}" "${NETDATA_PREFIX}/usr/libexec/netdata"
730
- run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
731
- run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0644 {} \;
732
- run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.plugin -exec chmod 0750 {} \;
733
- run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.sh -exec chmod 0755 {} \;
734
-
735
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" ]; then
736
- run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
737
- capabilities=0
738
- if ! iscontainer && command -v setcap 1>/dev/null 2>&1; then
739
- run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
740
- if run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"; then
741
- # if we managed to setcap, but we fail to execute apps.plugin setuid to root
742
- "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" -t >/dev/null 2>&1 && capabilities=1 || capabilities=0
743
- fi
744
- fi
745
-
746
- if [ $capabilities -eq 0 ]; then
747
- # fix apps.plugin to be setuid to root
748
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
749
- fi
750
- fi
751
-
752
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" ]; then
753
- run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin"
754
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin"
755
- fi
756
-
757
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin" ]; then
758
- run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin"
759
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin"
760
- fi
761
-
762
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin" ]; then
763
- run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin"
764
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin"
765
- fi
766
-
767
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin" ]; then
768
- run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin"
769
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin"
770
- fi
771
-
772
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin" ]; then
773
- run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin"
774
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin"
775
- fi
776
-
777
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping" ]; then
778
- run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
779
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
780
- fi
781
-
782
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" ]; then
783
- run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
784
- run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
785
- fi
786
-
787
- if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh" ]; then
788
- run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh"
789
- run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh"
790
- fi
722
+ # find the admin group
723
+ admin_group=
724
+ test -z "${admin_group}" && getent group root > /dev/null 2>&1 && admin_group="root"
725
+ test -z "${admin_group}" && getent group daemon > /dev/null 2>&1 && admin_group="daemon"
726
+ test -z "${admin_group}" && admin_group="${NETDATA_GROUP}"
727
+
728
+ run chown "${NETDATA_USER}:${admin_group}" "${NETDATA_LOG_DIR}"
729
+ run chown -R "root:${admin_group}" "${NETDATA_PREFIX}/usr/libexec/netdata"
730
+ run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
731
+ run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0644 {} \;
732
+ run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.plugin -exec chmod 0750 {} \;
733
+ run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.sh -exec chmod 0755 {} \;
734
+
735
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" ]; then
736
+ run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
737
+ capabilities=0
738
+ if ! iscontainer && command -v setcap 1> /dev/null 2>&1; then
739
+ run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
740
+ if run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"; then
741
+ # if we managed to setcap, but we fail to execute apps.plugin setuid to root
742
+ "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" -t > /dev/null 2>&1 && capabilities=1 || capabilities=0
743
+ fi
744
+ fi
745
+
746
+ if [ $capabilities -eq 0 ]; then
747
+ # fix apps.plugin to be setuid to root
748
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
749
+ fi
750
+ fi
751
+
752
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" ]; then
753
+ run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin"
754
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin"
755
+ fi
756
+
757
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin" ]; then
758
+ run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin"
759
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/nfacct.plugin"
760
+ fi
761
+
762
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin" ]; then
763
+ run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin"
764
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/xenstat.plugin"
765
+ fi
766
+
767
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin" ]; then
768
+ run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin"
769
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/perf.plugin"
770
+ fi
771
+
772
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin" ]; then
773
+ run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin"
774
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/slabinfo.plugin"
775
+ fi
776
+
777
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping" ]; then
778
+ run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
779
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/ioping"
780
+ fi
781
+
782
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" ]; then
783
+ run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
784
+ run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network"
785
+ fi
786
+
787
+ if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh" ]; then
788
+ run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh"
789
+ run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh"
790
+ fi
791
792
else
793
- # non-privileged user installation
794
- run chown "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_LOG_DIR}"
795
- run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata"
796
- run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0755 {} \;
797
- run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
793
+ # non-privileged user installation
794
+ run chown "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_LOG_DIR}"
795
+ run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata"
796
+ run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0755 {} \;
797
+ run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
798
fi
799
800
# -----------------------------------------------------------------------------
801
802
install_go() {
803
- # When updating this value, ensure correct checksums in packaging/go.d.checksums
804
- GO_PACKAGE_VERSION="$(cat packaging/go.d.version)"
805
- ARCH_MAP=(
806
- 'i386::386'
807
- 'i686::386'
808
- 'x86_64::amd64'
809
- 'aarch64::arm64'
810
- 'armv64::arm64'
811
- 'armv6l::arm'
812
- 'armv7l::arm'
813
- 'armv5tel::arm'
814
- )
815
-
816
- if [ -z "${NETDATA_DISABLE_GO+x}" ]; then
817
- progress "Install go.d.plugin"
818
- ARCH=$(uname -m)
819
- OS=$(uname -s | tr '[:upper:]' '[:lower:]')
820
-
821
- for index in "${ARCH_MAP[@]}" ; do
822
- KEY="${index%%::*}"
823
- VALUE="${index##*::}"
824
- if [ "$KEY" = "$ARCH" ]; then
825
- ARCH="${VALUE}"
826
- break
827
- fi
828
- done
829
- tmp=$(mktemp -d /tmp/netdata-go-XXXXXX)
830
- GO_PACKAGE_BASENAME="go.d.plugin-${GO_PACKAGE_VERSION}.${OS}-${ARCH}.tar.gz"
831
-
832
- if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}" ]; then
833
- download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/${GO_PACKAGE_BASENAME}" "${tmp}/${GO_PACKAGE_BASENAME}"
834
- else
835
- progress "Using provided go.d tarball ${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}"
836
- run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}" "${tmp}/${GO_PACKAGE_BASENAME}"
837
- fi
838
-
839
- if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}" ]; then
840
- download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/config.tar.gz" "${tmp}/config.tar.gz"
841
- else
842
- progress "Using provided config file for go.d ${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}"
843
- run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}" "${tmp}/config.tar.gz"
844
- fi
845
-
846
- if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
847
- run_failed "go.d plugin download failed, go.d plugin will not be available"
848
- echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
849
- echo >&2
850
- return 0
851
- fi
852
-
853
- grep "${GO_PACKAGE_BASENAME}\$" "${INSTALLER_DIR}/packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2>/dev/null
854
- grep "config.tar.gz" "${INSTALLER_DIR}/packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2>/dev/null
855
-
856
- # Checksum validation
857
- if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
858
-
859
- echo >&2 "go.d plugin checksum validation failure."
860
- echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
861
- echo >&2
862
-
863
- run_failed "go.d.plugin package files checksum validation failed."
864
- return 0
865
- fi
866
-
867
- # Install new files
868
- run rm -rf "${NETDATA_STOCK_CONFIG_DIR}/go.d"
869
- run rm -rf "${NETDATA_STOCK_CONFIG_DIR}/go.d.conf"
870
- run tar -xf "${tmp}/config.tar.gz" -C "${NETDATA_STOCK_CONFIG_DIR}/"
871
- run chown -R "${ROOT_USER}:${ROOT_GROUP}" "${NETDATA_STOCK_CONFIG_DIR}"
872
-
873
- run tar xf "${tmp}/${GO_PACKAGE_BASENAME}"
874
- run mv "${GO_PACKAGE_BASENAME/\.tar\.gz/}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
875
- if [ "${UID}" -eq 0 ]; then
876
- run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
877
- fi
878
- run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
879
- rm -rf "${tmp}"
880
- fi
881
- return 0
803
+ # When updating this value, ensure correct checksums in packaging/go.d.checksums
804
+ GO_PACKAGE_VERSION="$(cat packaging/go.d.version)"
805
+ ARCH_MAP=(
806
+ 'i386::386'
807
+ 'i686::386'
808
+ 'x86_64::amd64'
809
+ 'aarch64::arm64'
810
+ 'armv64::arm64'
811
+ 'armv6l::arm'
812
+ 'armv7l::arm'
813
+ 'armv5tel::arm'
814
+ )
815
+
816
+ if [ -z "${NETDATA_DISABLE_GO+x}" ]; then
817
+ progress "Install go.d.plugin"
818
+ ARCH=$(uname -m)
819
+ OS=$(uname -s | tr '[:upper:]' '[:lower:]')
820
+
821
+ for index in "${ARCH_MAP[@]}"; do
822
+ KEY="${index%%::*}"
823
+ VALUE="${index##*::}"
824
+ if [ "$KEY" = "$ARCH" ]; then
825
+ ARCH="${VALUE}"
826
+ break
827
+ fi
828
+ done
829
+ tmp=$(mktemp -d /tmp/netdata-go-XXXXXX)
830
+ GO_PACKAGE_BASENAME="go.d.plugin-${GO_PACKAGE_VERSION}.${OS}-${ARCH}.tar.gz"
831
+
832
+ if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}" ]; then
833
+ download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/${GO_PACKAGE_BASENAME}" "${tmp}/${GO_PACKAGE_BASENAME}"
834
+ else
835
+ progress "Using provided go.d tarball ${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}"
836
+ run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN}" "${tmp}/${GO_PACKAGE_BASENAME}"
837
+ fi
838
+
839
+ if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}" ]; then
840
+ download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/config.tar.gz" "${tmp}/config.tar.gz"
841
+ else
842
+ progress "Using provided config file for go.d ${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}"
843
+ run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG}" "${tmp}/config.tar.gz"
844
+ fi
845
+
846
+ if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
847
+ run_failed "go.d plugin download failed, go.d plugin will not be available"
848
+ echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
849
+ echo >&2
850
+ return 0
851
+ fi
852
+
853
+ grep "${GO_PACKAGE_BASENAME}\$" "${INSTALLER_DIR}/packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2> /dev/null
854
+ grep "config.tar.gz" "${INSTALLER_DIR}/packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2> /dev/null
855
+
856
+ # Checksum validation
857
+ if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
858
+
859
+ echo >&2 "go.d plugin checksum validation failure."
860
+ echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
861
+ echo >&2
862
+
863
+ run_failed "go.d.plugin package files checksum validation failed."
864
+ return 0
865
+ fi
866
+
867
+ # Install new files
868
+ run rm -rf "${NETDATA_STOCK_CONFIG_DIR}/go.d"
869
+ run rm -rf "${NETDATA_STOCK_CONFIG_DIR}/go.d.conf"
870
+ run tar -xf "${tmp}/config.tar.gz" -C "${NETDATA_STOCK_CONFIG_DIR}/"
871
+ run chown -R "${ROOT_USER}:${ROOT_GROUP}" "${NETDATA_STOCK_CONFIG_DIR}"
872
+
873
+ run tar xf "${tmp}/${GO_PACKAGE_BASENAME}"
874
+ run mv "${GO_PACKAGE_BASENAME/\.tar\.gz/}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
875
+ if [ "${UID}" -eq 0 ]; then
876
+ run chown "root:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
877
+ fi
878
+ run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin"
879
+ rm -rf "${tmp}"
880
+ fi
881
+ return 0
882
}
883
install_go
884
@@ -887,9 +887,9 @@ progress "Telemetry configuration"
887
888
# Opt-out from telemetry program
889
if [ -n "${NETDATA_DISABLE_TELEMETRY+x}" ]; then
890
- run touch "${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics"
890
+ run touch "${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics"
891
else
892
- printf "You can opt out from anonymous statistics via the --disable-telemetry option, or by creating an empty file ${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics \n\n"
892
+ 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"
893
fi
894
895
# -----------------------------------------------------------------------------
@@ -897,24 +897,24 @@ progress "Install netdata at system init"
897
898
NETDATA_START_CMD="${NETDATA_PREFIX}/usr/sbin/netdata"
899
900
-if grep -q docker /proc/1/cgroup >/dev/null 2>&1; then
901
- # If docker runs systemd for some weird reason, let the install proceed
902
- is_systemd_running="NO"
903
- if command -v pidof >/dev/null 2>&1; then
904
- is_systemd_running="$(pidof /usr/sbin/init || pidof systemd || echo "NO")"
905
- else
906
- is_systemd_running="$( (ps -p 1 | grep -q systemd && echo "1") || echo "NO")"
907
- fi
908
-
909
- if [ "${is_systemd_running}" == "1" ]; then
910
- echo >&2 "Found systemd within the docker container, running install_netdata_service() method"
911
- install_netdata_service || run_failed "Cannot install netdata init service."
912
- else
913
- echo >&2 "We are running within a docker container, will not be installing netdata service"
914
- fi
915
- echo >&2
900
+if grep -q docker /proc/1/cgroup > /dev/null 2>&1; then
901
+ # If docker runs systemd for some weird reason, let the install proceed
902
+ is_systemd_running="NO"
903
+ if command -v pidof > /dev/null 2>&1; then
904
+ is_systemd_running="$(pidof /usr/sbin/init || pidof systemd || echo "NO")"
905
+ else
906
+ is_systemd_running="$( (pgrep -q -f systemd && echo "1") || echo "NO")"
907
+ fi
908
+
909
+ if [ "${is_systemd_running}" == "1" ]; then
910
+ echo >&2 "Found systemd within the docker container, running install_netdata_service() method"
911
+ install_netdata_service || run_failed "Cannot install netdata init service."
912
+ else
913
+ echo >&2 "We are running within a docker container, will not be installing netdata service"
914
+ fi
915
+ echo >&2
916
else
917
- install_netdata_service || run_failed "Cannot install netdata init service."
917
+ install_netdata_service || run_failed "Cannot install netdata init service."
918
fi
919
920
# -----------------------------------------------------------------------------
@@ -923,24 +923,24 @@ fi
923
# TODO(paulfantom): Creation of configuration file should be handled by a build system. Additionally we shouldn't touch configuration files in /etc/netdata/...
924
started=0
925
if [ ${DONOTSTART} -eq 1 ]; then
926
- create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
926
+ create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
927
else
928
- if ! restart_netdata "${NETDATA_PREFIX}/usr/sbin/netdata" "${@}"; then
929
- fatal "Cannot start netdata!"
930
- fi
928
+ if ! restart_netdata "${NETDATA_PREFIX}/usr/sbin/netdata" "${@}"; then
929
+ fatal "Cannot start netdata!"
930
+ fi
931
932
- started=1
933
- run_ok "netdata started!"
934
- create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:${NETDATA_PORT}/netdata.conf"
932
+ started=1
933
+ run_ok "netdata started!"
934
+ create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:${NETDATA_PORT}/netdata.conf"
935
fi
936
run chmod 0644 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
937
938
if [ "$(uname)" = "Linux" ]; then
939
- # -------------------------------------------------------------------------
940
- progress "Check KSM (kernel memory deduper)"
939
+ # -------------------------------------------------------------------------
940
+ progress "Check KSM (kernel memory deduper)"
941
942
- ksm_is_available_but_disabled() {
943
- cat <<KSM1
942
+ ksm_is_available_but_disabled() {
943
+ cat << KSM1
944
945
${TPUT_BOLD}Memory de-duplication instructions${TPUT_RESET}
946
@@ -955,10 +955,10 @@ To enable it run:
955
If you enable it, you will save 40-60% of netdata memory.
956
957
KSM1
958
- }
958
+ }
959
960
- ksm_is_not_available() {
961
- cat <<KSM2
960
+ ksm_is_not_available() {
961
+ cat << KSM2
962
963
${TPUT_BOLD}Memory de-duplication not present in your kernel${TPUT_RESET}
964
@@ -970,22 +970,22 @@ To enable it, you need a kernel built with CONFIG_KSM=y
970
If you can have it, you will save 40-60% of netdata memory.
971
972
KSM2
973
- }
974
-
975
- if [ -f "/sys/kernel/mm/ksm/run" ]; then
976
- if [ "$(cat "/sys/kernel/mm/ksm/run")" != "1" ]; then
977
- ksm_is_available_but_disabled
978
- fi
979
- else
980
- ksm_is_not_available
981
- fi
973
+ }
974
+
975
+ if [ -f "/sys/kernel/mm/ksm/run" ]; then
976
+ if [ "$(cat "/sys/kernel/mm/ksm/run")" != "1" ]; then
977
+ ksm_is_available_but_disabled
978
+ fi
979
+ else
980
+ ksm_is_not_available
981
+ fi
982
fi
983
984
# -----------------------------------------------------------------------------
985
progress "Check version.txt"
986
987
if [ ! -s web/gui/version.txt ]; then
988
- cat <<VERMSG
988
+ cat << VERMSG
989
990
${TPUT_BOLD}Version update check warning${TPUT_RESET}
991
@@ -1001,11 +1001,11 @@ VERMSG
1001
fi
1002
1003
if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" ]; then
1004
- # -----------------------------------------------------------------------------
1005
- progress "Check apps.plugin"
1004
+ # -----------------------------------------------------------------------------
1005
+ progress "Check apps.plugin"
1006
1007
- if [ "${UID}" -ne 0 ]; then
1008
- cat <<SETUID_WARNING
1007
+ if [ "${UID}" -ne 0 ]; then
1008
+ cat << SETUID_WARNING
1009
1010
${TPUT_BOLD}apps.plugin needs privileges${TPUT_RESET}
1011
@@ -1029,14 +1029,14 @@ running processes. It cannot be instructed from the netdata daemon to perform
1029
any task, so it is pretty safe to do this.
1030
1031
SETUID_WARNING
1032
- fi
1032
+ fi
1033
fi
1034
1035
# -----------------------------------------------------------------------------
1036
progress "Copy uninstaller"
1037
if [ -f "${NETDATA_PREFIX}"/usr/libexec/netdata-uninstaller.sh ]; then
1038
- echo >&2 "Removing uninstaller from old location"
1039
- rm -f "${NETDATA_PREFIX}"/usr/libexec/netdata-uninstaller.sh;
1038
+ echo >&2 "Removing uninstaller from old location"
1039
+ rm -f "${NETDATA_PREFIX}"/usr/libexec/netdata-uninstaller.sh
1040
fi
1041
1042
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
@@ -1045,7 +1045,7 @@ chmod 750 ${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh
1045
# -----------------------------------------------------------------------------
1046
progress "Basic netdata instructions"
1047
1048
-cat <<END
1048
+cat << END
1049
1050
netdata by default listens on all IPs on port ${NETDATA_PORT},
1051
so you can access it with:
@@ -1071,18 +1071,17 @@ install_netdata_updater || run_failed "Cannot install netdata updater tool."
1071
1072
progress "Check if we must enable/disable the netdata updater tool"
1073
if [ "${AUTOUPDATE}" = "1" ]; then
1074
- enable_netdata_updater || run_failed "Cannot enable netdata updater tool"
1074
+ enable_netdata_updater || run_failed "Cannot enable netdata updater tool"
1075
else
1076
- disable_netdata_updater || run_failed "Cannot disable netdata updater tool"
1076
+ disable_netdata_updater || run_failed "Cannot disable netdata updater tool"
1077
fi
1078
1079
-
1079
# -----------------------------------------------------------------------------
1080
progress "Wrap up environment set up"
1081
1082
# Save environment variables
1083
echo >&2 "Preparing .environment file"
1085
-cat <<EOF > "${NETDATA_USER_CONFIG_DIR}/.environment"
1084
+cat << EOF > "${NETDATA_USER_CONFIG_DIR}/.environment"
1085
# Created by installer
1086
PATH="${PATH}"
1087
CFLAGS="${CFLAGS}"
@@ -1100,7 +1099,7 @@ EOF
1099
run chmod 0644 "${NETDATA_USER_CONFIG_DIR}/.environment"
1100
1101
echo >&2 "Setting netdata.tarball.checksum to 'new_installation'"
1103
-cat <<EOF > "${NETDATA_LIB_DIR}/netdata.tarball.checksum"
1102
+cat << EOF > "${NETDATA_LIB_DIR}/netdata.tarball.checksum"
1103
new_installation
1104
EOF
1105
@@ -1109,9 +1108,9 @@ echo >&2
1108
progress "We are done!"
1109
1110
if [ ${started} -eq 1 ]; then
1112
- netdata_banner "is installed and running now!"
1111
+ netdata_banner "is installed and running now!"
1112
else
1114
- netdata_banner "is installed now!"
1113
+ netdata_banner "is installed now!"
1114
fi
1115
1116
echo >&2 " enjoy real-time performance and health monitoring..."
packaging/installer/README.md
+1
-1
@@ -116,7 +116,7 @@ This script installs Netdata at `/opt/netdata`.
116
Verify the integrity of the script with this:
117
118
```bash
119
-[ "986e7756219717b075675ebe9b812916" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
119
+[ "dfa84c3b5e6fd8975555d68f46eccdde" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
120
```
121
122
*It should print `OK, VALID` if the script is the one we ship.*
packaging/installer/kickstart-static64.sh
+172
-169
@@ -1,5 +1,5 @@
1
#!/usr/bin/env sh
2
-#
2
+
3
# SPDX-License-Identifier: GPL-3.0-or-later
4
# shellcheck disable=SC1117,SC2039,SC2059,SC2086
5
#
@@ -15,155 +15,158 @@
15
# library functions copied from packaging/installer/functions.sh
16
17
setup_terminal() {
18
- TPUT_RESET=""
19
- TPUT_YELLOW=""
20
- TPUT_WHITE=""
21
- TPUT_BGRED=""
22
- TPUT_BGGREEN=""
23
- TPUT_BOLD=""
24
- TPUT_DIM=""
25
-
26
- # Is stderr on the terminal? If not, then fail
27
- test -t 2 || return 1
28
-
29
- if command -v tput >/dev/null 2>&1; then
30
- if [ $(($(tput colors 2>/dev/null))) -ge 8 ]; then
31
- # Enable colors
32
- TPUT_RESET="$(tput sgr 0)"
33
- TPUT_YELLOW="$(tput setaf 3)"
34
- TPUT_WHITE="$(tput setaf 7)"
35
- TPUT_BGRED="$(tput setab 1)"
36
- TPUT_BGGREEN="$(tput setab 2)"
37
- TPUT_BOLD="$(tput bold)"
38
- TPUT_DIM="$(tput dim)"
39
- fi
40
- fi
41
-
42
- return 0
18
+ TPUT_RESET=""
19
+ TPUT_YELLOW=""
20
+ TPUT_WHITE=""
21
+ TPUT_BGRED=""
22
+ TPUT_BGGREEN=""
23
+ TPUT_BOLD=""
24
+ TPUT_DIM=""
25
+
26
+ # Is stderr on the terminal? If not, then fail
27
+ test -t 2 || return 1
28
+
29
+ if command -v tput > /dev/null 2>&1; then
30
+ if [ $(($(tput colors 2> /dev/null))) -ge 8 ]; then
31
+ # Enable colors
32
+ TPUT_RESET="$(tput sgr 0)"
33
+ TPUT_YELLOW="$(tput setaf 3)"
34
+ TPUT_WHITE="$(tput setaf 7)"
35
+ TPUT_BGRED="$(tput setab 1)"
36
+ TPUT_BGGREEN="$(tput setab 2)"
37
+ TPUT_BOLD="$(tput bold)"
38
+ TPUT_DIM="$(tput dim)"
39
+ fi
40
+ fi
41
+
42
+ return 0
43
}
44
-setup_terminal || echo >/dev/null
44
+setup_terminal || echo > /dev/null
45
46
# -----------------------------------------------------------------------------
47
fatal() {
48
- printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
49
- exit 1
48
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
49
+ exit 1
50
}
51
52
run_ok() {
53
- printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
53
+ printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} \n\n"
54
}
55
56
run_failed() {
57
- printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
57
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} \n\n"
58
}
59
60
ESCAPED_PRINT_METHOD=
61
-printf "%q " test >/dev/null 2>&1
62
-[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
61
+if printf "%q " test > /dev/null 2>&1; then
62
+ ESCAPED_PRINT_METHOD="printfq"
63
+fi
64
escaped_print() {
64
- if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then
65
- printf "%q " "${@}"
66
- else
67
- printf "%s" "${*}"
68
- fi
69
- return 0
65
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then
66
+ printf "%q " "${@}"
67
+ else
68
+ printf "%s" "${*}"
69
+ fi
70
+ return 0
71
}
72
73
progress() {
73
- echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
74
+ echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
75
}
76
77
run_logfile="/dev/null"
78
run() {
78
- local user="${USER--}" dir="${PWD}" info info_console
79
-
80
- if [ "${UID}" = "0" ]; then
81
- info="[root ${dir}]# "
82
- info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# "
83
- else
84
- info="[${user} ${dir}]$ "
85
- info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ "
86
- fi
87
-
88
- printf >>"${run_logfile}" "${info}"
89
- escaped_print >>"${run_logfile}" "${@}"
90
- printf >>"${run_logfile}" " ... "
91
-
92
- printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
93
- escaped_print >&2 "${@}"
94
- printf >&2 "${TPUT_RESET}\n"
95
-
96
- "${@}"
97
-
98
- local ret=$?
99
- if [ ${ret} -ne 0 ]; then
100
- run_failed
101
- printf >>"${run_logfile}" "FAILED with exit code ${ret}\n"
102
- else
103
- run_ok
104
- printf >>"${run_logfile}" "OK\n"
105
- fi
106
-
107
- return ${ret}
79
+ local user="${USER--}" dir="${PWD}" info info_console
80
+
81
+ if [ "${UID}" = "0" ]; then
82
+ info="[root ${dir}]# "
83
+ info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# "
84
+ else
85
+ info="[${user} ${dir}]$ "
86
+ info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ "
87
+ fi
88
+
89
+ {
90
+ printf "${info}"
91
+ escaped_print "${@}"
92
+ printf " ... "
93
+ } >> "${run_logfile}"
94
+
95
+ printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
96
+ escaped_print >&2 "${@}"
97
+ printf >&2 "${TPUT_RESET}\n"
98
+
99
+ "${@}"
100
+
101
+ local ret=$?
102
+ if [ ${ret} -ne 0 ]; then
103
+ run_failed
104
+ printf >> "${run_logfile}" "FAILED with exit code ${ret}\n"
105
+ else
106
+ run_ok
107
+ printf >> "${run_logfile}" "OK\n"
108
+ fi
109
+
110
+ return ${ret}
111
}
112
113
fatal() {
111
- printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
112
- exit 1
114
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
115
+ exit 1
116
}
117
118
create_tmp_directory() {
116
- # Check if tmp is mounted as noexec
117
- if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts; then
118
- pattern="$(pwd)/netdata-kickstart-XXXXXX"
119
- else
120
- pattern="/tmp/netdata-kickstart-XXXXXX"
121
- fi
122
-
123
- mktemp -d $pattern
119
+ # Check if tmp is mounted as noexec
120
+ if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts; then
121
+ pattern="$(pwd)/netdata-kickstart-XXXXXX"
122
+ else
123
+ pattern="/tmp/netdata-kickstart-XXXXXX"
124
+ fi
125
+
126
+ mktemp -d $pattern
127
}
128
129
download() {
127
- url="${1}"
128
- dest="${2}"
129
- if command -v curl >/dev/null 2>&1; then
130
- run curl -sSL --connect-timeout 10 --retry 3 "${url}" >"${dest}" || fatal "Cannot download ${url}"
131
- elif command -v wget >/dev/null 2>&1; then
132
- run wget -T 15 -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
133
- else
134
- fatal "I need curl or wget to proceed, but neither is available on this system."
135
- fi
130
+ url="${1}"
131
+ dest="${2}"
132
+ if command -v curl > /dev/null 2>&1; then
133
+ run curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${dest}" || fatal "Cannot download ${url}"
134
+ elif command -v wget > /dev/null 2>&1; then
135
+ run wget -T 15 -O - "${url}" > "${dest}" || fatal "Cannot download ${url}"
136
+ else
137
+ fatal "I need curl or wget to proceed, but neither is available on this system."
138
+ fi
139
}
140
141
set_tarball_urls() {
139
- if [ -n "${NETDATA_LOCAL_TARBALL_OVERRIDE}" ]; then
140
- progress "Not fetching remote tarballs, local override was given"
141
- return
142
- fi
143
-
144
- if [ "$1" = "stable" ]; then
145
- local latest
146
- # Simple version
147
- # latest="$(curl -sSL https://api.github.com/repos/netdata/netdata/releases/latest | grep tag_name | cut -d'"' -f4)"
148
- latest="$(download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4)"
149
- export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.gz.run"
150
- export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt"
151
- else
152
- export NETDATA_TARBALL_URL="https://storage.googleapis.com/netdata-nightlies/netdata-latest.gz.run"
153
- export NETDATA_TARBALL_CHECKSUM_URL="https://storage.googleapis.com/netdata-nightlies/sha256sums.txt"
154
- fi
142
+ if [ -n "${NETDATA_LOCAL_TARBALL_OVERRIDE}" ]; then
143
+ progress "Not fetching remote tarballs, local override was given"
144
+ return
145
+ fi
146
+
147
+ if [ "$1" = "stable" ]; then
148
+ local latest
149
+ # Simple version
150
+ # latest="$(curl -sSL https://api.github.com/repos/netdata/netdata/releases/latest | grep tag_name | cut -d'"' -f4)"
151
+ latest="$(download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4)"
152
+ export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.gz.run"
153
+ export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt"
154
+ else
155
+ export NETDATA_TARBALL_URL="https://storage.googleapis.com/netdata-nightlies/netdata-latest.gz.run"
156
+ export NETDATA_TARBALL_CHECKSUM_URL="https://storage.googleapis.com/netdata-nightlies/sha256sums.txt"
157
+ fi
158
}
159
160
safe_sha256sum() {
158
- # Within the context of the installer, we only use -c option that is common between the two commands
159
- # We will have to reconsider if we start using non-common options
160
- if command -v sha256sum >/dev/null 2>&1; then
161
- sha256sum "$@"
162
- elif command -v shasum >/dev/null 2>&1; then
163
- shasum -a 256 "$@"
164
- else
165
- fatal "I could not find a suitable checksum binary to use"
166
- fi
161
+ # Within the context of the installer, we only use -c option that is common between the two commands
162
+ # We will have to reconsider if we start using non-common options
163
+ if command -v sha256sum > /dev/null 2>&1; then
164
+ sha256sum "$@"
165
+ elif command -v shasum > /dev/null 2>&1; then
166
+ shasum -a 256 "$@"
167
+ else
168
+ fatal "I could not find a suitable checksum binary to use"
169
+ fi
170
}
171
172
# ---------------------------------------------------------------------------------------------------------------------
@@ -175,11 +178,11 @@ sudo=""
178
179
# ---------------------------------------------------------------------------------------------------------------------
180
if [ "$(uname -m)" != "x86_64" ]; then
178
- fatal "Static binary versions of netdata are available only for 64bit Intel/AMD CPUs (x86_64), but yours is: $(uname -m)."
181
+ fatal "Static binary versions of netdata are available only for 64bit Intel/AMD CPUs (x86_64), but yours is: $(uname -m)."
182
fi
183
184
if [ "$(uname -s)" != "Linux" ]; then
182
- fatal "Static binary versions of netdata are available only for Linux, but this system is $(uname -s)"
185
+ fatal "Static binary versions of netdata are available only for Linux, but this system is $(uname -s)"
186
fi
187
188
# ---------------------------------------------------------------------------------------------------------------------
@@ -188,64 +191,64 @@ NETDATA_INSTALLER_OPTIONS=""
191
NETDATA_UPDATES="--auto-update"
192
RELEASE_CHANNEL="nightly"
193
while [ -n "${1}" ]; do
191
- if [ "${1}" = "--dont-wait" ] || [ "${1}" = "--non-interactive" ] || [ "${1}" = "--accept" ]; then
192
- opts="${opts} --accept"
193
- shift 1
194
- elif [ "${1}" = "--dont-start-it" ]; then
195
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
196
- shift 1
197
- elif [ "${1}" = "--no-updates" ]; then
198
- NETDATA_UPDATES=""
199
- shift 1
200
- elif [ "${1}" = "--auto-update" ]; then
201
- true # This is the default behaviour, so ignore it.
202
- shift 1
203
- elif [ "${1}" = "--stable-channel" ]; then
204
- RELEASE_CHANNEL="stable"
205
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
206
- shift 1
207
- elif [ "${1}" = "--disable-telemetry" ]; then
208
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
209
- shift 1
210
- elif [ "${1}" = "--local-files" ]; then
211
- NETDATA_UPDATES="" # Disable autoupdates if using pre-downloaded files.
212
- shift 1
213
- if [ -z "${1}" ]; then
214
- fatal "Option --local-files requires extra information. The desired tarball full filename is needed"
215
- fi
216
-
217
- NETDATA_LOCAL_TARBALL_OVERRIDE="${1}"
218
- shift 1
219
- if [ -z "${1}" ]; then
220
- fatal "Option --local-files requires a pair of the tarball source and the checksum file"
221
- fi
222
-
223
- NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM="${1}"
224
- shift 1
225
- else
226
- echo >&2 "Unknown option '${1}' or invalid number of arguments. Please check the README for the available arguments of ${0} and try again"
227
- exit 1
228
- fi
194
+ if [ "${1}" = "--dont-wait" ] || [ "${1}" = "--non-interactive" ] || [ "${1}" = "--accept" ]; then
195
+ opts="${opts} --accept"
196
+ shift 1
197
+ elif [ "${1}" = "--dont-start-it" ]; then
198
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
199
+ shift 1
200
+ elif [ "${1}" = "--no-updates" ]; then
201
+ NETDATA_UPDATES=""
202
+ shift 1
203
+ elif [ "${1}" = "--auto-update" ]; then
204
+ true # This is the default behaviour, so ignore it.
205
+ shift 1
206
+ elif [ "${1}" = "--stable-channel" ]; then
207
+ RELEASE_CHANNEL="stable"
208
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
209
+ shift 1
210
+ elif [ "${1}" = "--disable-telemetry" ]; then
211
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
212
+ shift 1
213
+ elif [ "${1}" = "--local-files" ]; then
214
+ NETDATA_UPDATES="" # Disable autoupdates if using pre-downloaded files.
215
+ shift 1
216
+ if [ -z "${1}" ]; then
217
+ fatal "Option --local-files requires extra information. The desired tarball full filename is needed"
218
+ fi
219
+
220
+ NETDATA_LOCAL_TARBALL_OVERRIDE="${1}"
221
+ shift 1
222
+ if [ -z "${1}" ]; then
223
+ fatal "Option --local-files requires a pair of the tarball source and the checksum file"
224
+ fi
225
+
226
+ NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM="${1}"
227
+ shift 1
228
+ else
229
+ echo >&2 "Unknown option '${1}' or invalid number of arguments. Please check the README for the available arguments of ${0} and try again"
230
+ exit 1
231
+ fi
232
done
233
234
# ---------------------------------------------------------------------------------------------------------------------
235
TMPDIR=$(create_tmp_directory)
233
-cd "${TMPDIR}"
236
+cd "${TMPDIR}" || exit 1
237
238
if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE}" ]; then
236
- set_tarball_urls "${RELEASE_CHANNEL}"
237
- progress "Downloading static netdata binary: ${NETDATA_TARBALL_URL}"
239
+ set_tarball_urls "${RELEASE_CHANNEL}"
240
+ progress "Downloading static netdata binary: ${NETDATA_TARBALL_URL}"
241
239
- download "${NETDATA_TARBALL_CHECKSUM_URL}" "${TMPDIR}/sha256sum.txt"
240
- download "${NETDATA_TARBALL_URL}" "${TMPDIR}/netdata-latest.gz.run"
242
+ download "${NETDATA_TARBALL_CHECKSUM_URL}" "${TMPDIR}/sha256sum.txt"
243
+ download "${NETDATA_TARBALL_URL}" "${TMPDIR}/netdata-latest.gz.run"
244
else
242
- progress "Installation sources were given as input, running installation using \"${NETDATA_LOCAL_TARBALL_OVERRIDE}\""
243
- run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE}" "${TMPDIR}/netdata-latest.gz.run"
244
- run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM}" "${TMPDIR}/sha256sum.txt"
245
+ progress "Installation sources were given as input, running installation using \"${NETDATA_LOCAL_TARBALL_OVERRIDE}\""
246
+ run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE}" "${TMPDIR}/netdata-latest.gz.run"
247
+ run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM}" "${TMPDIR}/sha256sum.txt"
248
fi
249
247
-if ! grep netdata-latest.gz.run "${TMPDIR}/sha256sum.txt" | safe_sha256sum -c - >/dev/null 2>&1; then
248
- fatal "Static binary checksum validation failed. Stopping netdata installation and leaving binary in ${TMPDIR}"
250
+if ! grep netdata-latest.gz.run "${TMPDIR}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
251
+ fatal "Static binary checksum validation failed. Stopping netdata installation and leaving binary in ${TMPDIR}"
252
fi
253
254
# ---------------------------------------------------------------------------------------------------------------------
@@ -254,10 +257,10 @@ run ${sudo} sh "${TMPDIR}/netdata-latest.gz.run" ${opts} -- ${NETDATA_UPDATES} $
257
258
#shellcheck disable=SC2181
259
if [ $? -eq 0 ]; then
257
- run ${sudo} rm "${TMPDIR}/netdata-latest.gz.run"
258
- if [ ! "${TMPDIR}" = "/" ] && [ -d "${TMPDIR}" ]; then
259
- run ${sudo} rm -rf "${TMPDIR}"
260
- fi
260
+ run ${sudo} rm "${TMPDIR}/netdata-latest.gz.run"
261
+ if [ ! "${TMPDIR}" = "/" ] && [ -d "${TMPDIR}" ]; then
262
+ run ${sudo} rm -rf "${TMPDIR}"
263
+ fi
264
else
262
- echo >&2 "NOTE: did not remove: ${TMPDIR}/netdata-latest.gz.run"
265
+ echo >&2 "NOTE: did not remove: ${TMPDIR}/netdata-latest.gz.run"
266
fi
packaging/makeself/install-or-update.sh
+142
-157
@@ -1,26 +1,28 @@
1
#!/usr/bin/env bash
2
+
3
# SPDX-License-Identifier: GPL-3.0-or-later
4
4
-. $(dirname "${0}")/functions.sh
5
+# shellcheck source=./packaging/makeself/functions.sh
6
+. "$(dirname "${0}")"/functions.sh
7
8
export LC_ALL=C
9
umask 002
10
11
# Be nice on production environments
10
-renice 19 $$ >/dev/null 2>/dev/null
12
+renice 19 $$ > /dev/null 2> /dev/null
13
14
NETDATA_PREFIX="/opt/netdata"
15
NETDATA_USER_CONFIG_DIR="${NETDATA_PREFIX}/etc/netdata"
16
17
# -----------------------------------------------------------------------------
18
if [ -d /opt/netdata/etc/netdata.old ]; then
17
- progress "Found old etc/netdata directory, reinstating this"
18
- [ -d /opt/netdata/etc/netdata.new ] && rm -rf /opt/netdata/etc/netdata.new
19
- mv -f /opt/netdata/etc/netdata /opt/netdata/etc/netdata.new
20
- mv -f /opt/netdata/etc/netdata.old /opt/netdata/etc/netdata
19
+ progress "Found old etc/netdata directory, reinstating this"
20
+ [ -d /opt/netdata/etc/netdata.new ] && rm -rf /opt/netdata/etc/netdata.new
21
+ mv -f /opt/netdata/etc/netdata /opt/netdata/etc/netdata.new
22
+ mv -f /opt/netdata/etc/netdata.old /opt/netdata/etc/netdata
23
22
- progress "Trigger stock config clean up"
23
- rm -f /opt/netdata/etc/netdata/.installer-cleanup-of-stock-configs-done
24
+ progress "Trigger stock config clean up"
25
+ rm -f /opt/netdata/etc/netdata/.installer-cleanup-of-stock-configs-done
26
fi
27
28
STARTIT=1
@@ -29,75 +31,69 @@ REINSTALL_OPTIONS=""
31
RELEASE_CHANNEL="nightly" # check .travis/create_artifacts.sh before modifying
32
33
while [ "${1}" ]; do
32
- case "${1}" in
33
- "--dont-start-it")
34
- STARTIT=0
35
- REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
36
- ;;
37
- "--auto-update"|"-u")
38
- AUTOUPDATE=1
39
- REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
40
- ;;
41
- "--stable-channel")
42
- RELEASE_CHANNEL="stable"
43
- REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
44
- ;;
45
- "--nightly-channel")
46
- RELEASE_CHANNEL="nightly"
47
- REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
48
- ;;
49
- "--disable-telemetry")
50
- DISABLE_TELEMETRY=1
51
- REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
52
- ;;
53
-
54
- *) echo >&2 "Unknown option '${1}'. Ignoring it.";;
55
- esac
56
- shift 1
34
+ case "${1}" in
35
+ "--dont-start-it")
36
+ STARTIT=0
37
+ REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
38
+ ;;
39
+ "--auto-update" | "-u")
40
+ AUTOUPDATE=1
41
+ REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
42
+ ;;
43
+ "--stable-channel")
44
+ RELEASE_CHANNEL="stable"
45
+ REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
46
+ ;;
47
+ "--nightly-channel")
48
+ RELEASE_CHANNEL="nightly"
49
+ REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
50
+ ;;
51
+ "--disable-telemetry")
52
+ REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
53
+ ;;
54
+
55
+ *) echo >&2 "Unknown option '${1}'. Ignoring it." ;;
56
+ esac
57
+ shift 1
58
done
59
60
deleted_stock_configs=0
60
-if [ ! -f "etc/netdata/.installer-cleanup-of-stock-configs-done" ]
61
-then
62
-
63
- # -----------------------------------------------------------------------------
64
- progress "Deleting stock configuration files from user configuration directory"
65
-
66
- declare -A configs_signatures=()
67
- source "system/configs.signatures"
68
-
69
- if [ ! -d etc/netdata ]
70
- then
71
- run mkdir -p etc/netdata
61
+if [ ! -f "etc/netdata/.installer-cleanup-of-stock-configs-done" ]; then
62
+
63
+ # -----------------------------------------------------------------------------
64
+ progress "Deleting stock configuration files from user configuration directory"
65
+
66
+ declare -A configs_signatures=()
67
+ source "system/configs.signatures"
68
+
69
+ if [ ! -d etc/netdata ]; then
70
+ run mkdir -p etc/netdata
71
+ fi
72
+
73
+ md5sum="$(command -v md5sum 2> /dev/null || command -v md5 2> /dev/null)"
74
+ while IFS= read -r -d '' x; do
75
+ # find it relative filename
76
+ f="${x/etc\/netdata\//}"
77
+
78
+ # find the stock filename
79
+ t="${f/.conf.old/.conf}"
80
+ t="${t/.conf.orig/.conf}"
81
+
82
+ if [ -n "${md5sum}" ]; then
83
+ # find the checksum of the existing file
84
+ md5="$(${md5sum} < "${x}" | cut -d ' ' -f 1)"
85
+ #echo >&2 "md5: ${md5}"
86
+
87
+ # check if it matches
88
+ if [ "${configs_signatures[${md5}]}" = "${t}" ]; then
89
+ # it matches the default
90
+ run rm -f "${x}"
91
+ deleted_stock_configs=$((deleted_stock_configs + 1))
92
+ fi
93
fi
94
+ done < <(find etc -type f)
95
74
- md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null || command -v md5 2>/dev/null)"
75
- for x in $(find etc -type f)
76
- do
77
- # find it relative filename
78
- f="${x/etc\/netdata\//}"
79
-
80
- # find the stock filename
81
- t="${f/.conf.old/.conf}"
82
- t="${t/.conf.orig/.conf}"
83
-
84
- if [ ! -z "${md5sum}" ]
85
- then
86
- # find the checksum of the existing file
87
- md5="$( ${md5sum} <"${x}" | cut -d ' ' -f 1)"
88
- #echo >&2 "md5: ${md5}"
89
-
90
- # check if it matches
91
- if [ "${configs_signatures[${md5}]}" = "${t}" ]
92
- then
93
- # it matches the default
94
- run rm -f "${x}"
95
- deleted_stock_configs=$(( deleted_stock_configs + 1 ))
96
- fi
97
- fi
98
- done
99
-
100
- touch "etc/netdata/.installer-cleanup-of-stock-configs-done"
96
+ touch "etc/netdata/.installer-cleanup-of-stock-configs-done"
97
fi
98
99
# -----------------------------------------------------------------------------
@@ -110,44 +106,44 @@ NETDATA_USER="root"
106
NETDATA_GROUP="root"
107
108
if portable_add_group netdata; then
113
- if portable_add_user netdata "/opt/netdata"; then
114
- progress "Add user netdata to required user groups"
115
- for g in ${NETDATA_WANTED_GROUPS}; do
116
- # shellcheck disable=SC2086
117
- portable_add_user_to_group ${g} netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}" || run_failed "Failed to add netdata user to secondary groups"
118
- done
119
- NETDATA_USER="netdata"
120
- NETDATA_GROUP="netdata"
121
- else
122
- run_failed "I could not add user netdata, will be using root"
123
- fi
109
+ if portable_add_user netdata "/opt/netdata"; then
110
+ progress "Add user netdata to required user groups"
111
+ for g in ${NETDATA_WANTED_GROUPS}; do
112
+ # shellcheck disable=SC2086
113
+ if portable_add_user_to_group ${g} netdata; then
114
+ NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}"
115
+ else
116
+ run_failed "Failed to add netdata user to secondary groups"
117
+ fi
118
+ done
119
+ NETDATA_USER="netdata"
120
+ NETDATA_GROUP="netdata"
121
+ else
122
+ run_failed "I could not add user netdata, will be using root"
123
+ fi
124
else
125
- run_failed "I could not add group netdata, so no user netdata will be created as well. Netdata run as root:root"
125
+ run_failed "I could not add group netdata, so no user netdata will be created as well. Netdata run as root:root"
126
fi
127
128
# -----------------------------------------------------------------------------
129
progress "Check SSL certificates paths"
130
131
-if [ ! -f "/etc/ssl/certs/ca-certificates.crt" ]
132
-then
133
- if [ ! -f /opt/netdata/.curlrc ]
134
- then
135
- cacert=
136
-
137
- # CentOS
138
- [ -f "/etc/ssl/certs/ca-bundle.crt" ] && cacert="/etc/ssl/certs/ca-bundle.crt"
139
-
140
- if [ ! -z "${cacert}" ]
141
- then
142
- echo "Creating /opt/netdata/.curlrc with cacert=${cacert}"
143
- echo >/opt/netdata/.curlrc "cacert=${cacert}"
144
- else
145
- run_failed "Failed to find /etc/ssl/certs/ca-certificates.crt"
146
- fi
131
+if [ ! -f "/etc/ssl/certs/ca-certificates.crt" ]; then
132
+ if [ ! -f /opt/netdata/.curlrc ]; then
133
+ cacert=
134
+
135
+ # CentOS
136
+ [ -f "/etc/ssl/certs/ca-bundle.crt" ] && cacert="/etc/ssl/certs/ca-bundle.crt"
137
+
138
+ if [ -n "${cacert}" ]; then
139
+ echo "Creating /opt/netdata/.curlrc with cacert=${cacert}"
140
+ echo > /opt/netdata/.curlrc "cacert=${cacert}"
141
+ else
142
+ run_failed "Failed to find /etc/ssl/certs/ca-certificates.crt"
143
fi
144
+ fi
145
fi
146
150
-
147
# -----------------------------------------------------------------------------
148
progress "Install logrotate configuration for netdata"
149
@@ -160,7 +156,7 @@ progress "Telemetry configuration"
156
if [ -n "${NETDATA_DISABLE_TELEMETRY+x}" ]; then
157
run touch "${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics"
158
else
163
- printf "You can opt out from anonymous statistics via the --disable-telemetry option, or by creating an empty file ${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics \n\n"
159
+ 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"
160
fi
161
162
# -----------------------------------------------------------------------------
@@ -168,10 +164,8 @@ progress "Install netdata at system init"
164
165
install_netdata_service || run_failed "Cannot install netdata init service."
166
171
-
167
set_netdata_updater_channel || run_failed "Cannot set netdata updater tool release channel to '${RELEASE_CHANNEL}'"
168
174
-
169
# -----------------------------------------------------------------------------
170
progress "Install (but not enable) netdata updater tool"
171
cleanup_old_netdata_updater || run_failed "Cannot cleanup old netdata updater tool."
@@ -179,82 +173,73 @@ install_netdata_updater || run_failed "Cannot install netdata updater tool."
173
174
progress "Check if we must enable/disable the netdata updater tool"
175
if [ "${AUTOUPDATE}" = "1" ]; then
182
- enable_netdata_updater || run_failed "Cannot enable netdata updater tool"
176
+ enable_netdata_updater || run_failed "Cannot enable netdata updater tool"
177
else
184
- disable_netdata_updater || run_failed "Cannot disable netdata updater tool"
178
+ disable_netdata_updater || run_failed "Cannot disable netdata updater tool"
179
fi
180
187
-
181
# -----------------------------------------------------------------------------
182
progress "creating quick links"
183
184
dir_should_be_link() {
192
- local p="${1}" t="${2}" d="${3}" old
193
-
194
- old="${PWD}"
195
- cd "${p}" || return 0
196
-
197
- if [ -e "${d}" ]
198
- then
199
- if [ -h "${d}" ]
200
- then
201
- run rm "${d}"
202
- else
203
- run mv -f "${d}" "${d}.old.$$"
204
- fi
185
+ local p="${1}" t="${2}" d="${3}" old
186
+
187
+ old="${PWD}"
188
+ cd "${p}" || return 0
189
+
190
+ if [ -e "${d}" ]; then
191
+ if [ -h "${d}" ]; then
192
+ run rm "${d}"
193
+ else
194
+ run mv -f "${d}" "${d}.old.$$"
195
fi
196
+ fi
197
207
- run ln -s "${t}" "${d}"
208
- cd "${old}"
198
+ run ln -s "${t}" "${d}"
199
+ cd "${old}"
200
}
201
211
-dir_should_be_link . bin sbin
202
+dir_should_be_link . bin sbin
203
dir_should_be_link usr ../bin bin
204
dir_should_be_link usr ../bin sbin
214
-dir_should_be_link usr . local
205
+dir_should_be_link usr . local
206
216
-dir_should_be_link . etc/netdata netdata-configs
207
+dir_should_be_link . etc/netdata netdata-configs
208
dir_should_be_link . usr/share/netdata/web netdata-web-files
218
-dir_should_be_link . usr/libexec/netdata netdata-plugins
219
-dir_should_be_link . var/lib/netdata netdata-dbs
220
-dir_should_be_link . var/cache/netdata netdata-metrics
221
-dir_should_be_link . var/log/netdata netdata-logs
209
+dir_should_be_link . usr/libexec/netdata netdata-plugins
210
+dir_should_be_link . var/lib/netdata netdata-dbs
211
+dir_should_be_link . var/cache/netdata netdata-metrics
212
+dir_should_be_link . var/log/netdata netdata-logs
213
214
dir_should_be_link etc/netdata ../../usr/lib/netdata/conf.d orig
215
225
-if [ ${deleted_stock_configs} -gt 0 ]
226
-then
227
- dir_should_be_link etc/netdata ../../usr/lib/netdata/conf.d "000.-.USE.THE.orig.LINK.TO.COPY.AND.EDIT.STOCK.CONFIG.FILES"
216
+if [ ${deleted_stock_configs} -gt 0 ]; then
217
+ dir_should_be_link etc/netdata ../../usr/lib/netdata/conf.d "000.-.USE.THE.orig.LINK.TO.COPY.AND.EDIT.STOCK.CONFIG.FILES"
218
fi
219
230
-
220
# -----------------------------------------------------------------------------
221
progress "fix permissions"
222
223
run chmod g+rx,o+rx /opt
224
run chown -R ${NETDATA_USER}:${NETDATA_GROUP} /opt/netdata
225
237
-
226
# -----------------------------------------------------------------------------
227
228
progress "fix plugin permissions"
229
242
-for x in apps.plugin freeipmi.plugin ioping cgroup-network
243
-do
244
- f="usr/libexec/netdata/plugins.d/${x}"
230
+for x in apps.plugin freeipmi.plugin ioping cgroup-network; do
231
+ f="usr/libexec/netdata/plugins.d/${x}"
232
246
- if [ -f "${f}" ]
247
- then
248
- run chown root:${NETDATA_GROUP} "${f}"
249
- run chmod 4750 "${f}"
250
- fi
233
+ if [ -f "${f}" ]; then
234
+ run chown root:${NETDATA_GROUP} "${f}"
235
+ run chmod 4750 "${f}"
236
+ fi
237
done
238
239
# fix the fping binary
254
-if [ -f bin/fping ]
255
-then
256
- run chown root:${NETDATA_GROUP} bin/fping
257
- run chmod 4750 bin/fping
240
+if [ -f bin/fping ]; then
241
+ run chown root:${NETDATA_GROUP} bin/fping
242
+ run chmod 4750 bin/fping
243
fi
244
245
# -----------------------------------------------------------------------------
@@ -265,17 +250,17 @@ sed -i "s/REINSTALL_OPTIONS=\".*\"/REINSTALL_OPTIONS=\"${REINSTALL_OPTIONS}\"/"
250
251
# -----------------------------------------------------------------------------
252
if [ ${STARTIT} -eq 0 ]; then
268
- create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
269
- netdata_banner "is installed now!"
253
+ create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
254
+ netdata_banner "is installed now!"
255
else
271
- progress "starting netdata"
272
-
273
- if ! restart_netdata "${NETDATA_PREFIX}/bin/netdata"; then
274
- create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
275
- netdata_banner "is installed and running now!"
276
- else
277
- create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf"
278
- netdata_banner "is installed now!"
279
- fi
256
+ progress "starting netdata"
257
+
258
+ if ! restart_netdata "${NETDATA_PREFIX}/bin/netdata"; then
259
+ create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
260
+ netdata_banner "is installed and running now!"
261
+ else
262
+ create_netdata_conf "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf"
263
+ netdata_banner "is installed now!"
264
+ fi
265
fi
266
run chmod 0644 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"