colorful netdata-installer.sh; splitted certain functions for adding makeself; netdata-uninstaller.sh and netdata-updater.sh are now generated even when netdata-installer is called with --dont-start-it
Costa Tsaousis (ktsaou) committed
Feb 12, 2017 at 16:52 UTC
5d7a955f1ba6d6c6b1408a53eb628c60a6a3f519
3 files changed
+570
-453
Makefile.am
+1
@@ -60,4 +60,5 @@ dist_noinst_SCRIPTS= \
60
coverity-scan.sh \
61
docker-build.sh \
62
netdata-installer.sh \
63
+ installer/functions.sh \
64
$(NULL)
installer/functions.sh
new
+307
@@ -0,0 +1,307 @@
1
+# no shebang necessary - this is a library to be sourced
2
+
3
+# -----------------------------------------------------------------------------
4
+# checking the availability of commands
5
+
6
+which_cmd() {
7
+ which "${1}" 2>/dev/null || \
8
+ command -v "${1}" 2>/dev/null
9
+}
10
+
11
+check_cmd() {
12
+ which_cmd "${1}" >/dev/null 2>&1 && return 0
13
+ return 1
14
+}
15
+
16
+
17
+# -----------------------------------------------------------------------------
18
+
19
+setup_terminal() {
20
+ # Is stderr on the terminal? If not, then fail
21
+ test -t 2 || return 1
22
+
23
+ if [ ! -z "$TPUT_CMD" ]
24
+ then
25
+ if [ $[$($TPUT_CMD colors 2>/dev/null)] -ge 8 ]
26
+ then
27
+ # Enable colors
28
+ COLOR_RESET="\e[0m"
29
+ COLOR_BLACK="\e[30m"
30
+ COLOR_RED="\e[31m"
31
+ COLOR_GREEN="\e[32m"
32
+ COLOR_YELLOW="\e[33m"
33
+ COLOR_BLUE="\e[34m"
34
+ COLOR_PURPLE="\e[35m"
35
+ COLOR_CYAN="\e[36m"
36
+ COLOR_WHITE="\e[37m"
37
+ COLOR_BGBLACK="\e[40m"
38
+ COLOR_BGRED="\e[41m"
39
+ COLOR_BGGREEN="\e[42m"
40
+ COLOR_BGYELLOW="\e[43m"
41
+ COLOR_BGBLUE="\e[44m"
42
+ COLOR_BGPURPLE="\e[45m"
43
+ COLOR_BGCYAN="\e[46m"
44
+ COLOR_BGWHITE="\e[47m"
45
+ COLOR_BOLD="\e[1m"
46
+ COLOR_DIM="\e[2m"
47
+ COLOR_UNDERLINED="\e[4m"
48
+ COLOR_BLINK="\e[5m"
49
+ COLOR_INVERTED="\e[7m"
50
+ fi
51
+ fi
52
+
53
+ return 0
54
+}
55
+TPUT_CMD="$(which_cmd tput)"
56
+setup_terminal
57
+
58
+progress() {
59
+ printf >&2 " --- ${COLOR_DIM}${COLOR_BOLD}${*}${COLOR_RESET} --- \n"
60
+}
61
+
62
+# -----------------------------------------------------------------------------
63
+
64
+netdata_banner() {
65
+ local l1=" ^" \
66
+ l2=" |.-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-" \
67
+ l3=" | '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' " \
68
+ l4=" +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->" \
69
+ sp=" " \
70
+ netdata="netdata" start end msg="${*}" chartcolor="${COLOR_DIM}"
71
+
72
+ [ ${#msg} -lt ${#netdata} ] && msg="${msg}${sp:0:$(( ${#netdata} - ${#msg}))}"
73
+ [ ${#msg} -gt $(( ${#l2} - 20 )) ] && msg="${msg:0:$(( ${#l2} - 23 ))}..."
74
+
75
+ start="$(( ${#l2} / 2 - 4 ))"
76
+ [ $(( start + ${#msg} + 4 )) -gt ${#l2} ] && start=$((${#l2} - ${#msg} - 4))
77
+ end=$(( ${start} + ${#msg} + 4 ))
78
+
79
+ echo >&2
80
+ echo >&2 -e "${chartcolor}${l1}${COLOR_RESET}"
81
+ echo >&2 -e "${chartcolor}${l2:0:start}${sp:0:2}${COLOR_RESET}${COLOR_BOLD}${COLOR_GREEN}${netdata}${COLOR_RESET}${chartcolor}${sp:0:$((end - start - 2 - ${#netdata}))}${l2:end:$((${#l2} - end))}${COLOR_RESET}"
82
+ echo >&2 -e "${chartcolor}${l3:0:start}${sp:0:2}${COLOR_RESET}${COLOR_BOLD}${COLOR_CYAN}${msg}${COLOR_RESET}${chartcolor}${sp:0:2}${l3:end:$((${#l2} - end))}${COLOR_RESET}"
83
+ echo >&2 -e "${chartcolor}${l4}${COLOR_RESET}"
84
+ echo >&2
85
+}
86
+
87
+# -----------------------------------------------------------------------------
88
+# portable service command
89
+
90
+service_cmd="$(which_cmd service)"
91
+systemctl_cmd="$(which_cmd systemctl)"
92
+service() {
93
+ local cmd="${1}" action="${2}"
94
+
95
+ if [ ! -z "${service_cmd}" ]
96
+ then
97
+ run "${service_cmd}" "${cmd}" "${action}"
98
+ return $?
99
+ elif [ ! -z "${systemctl_cmd}" ]
100
+ then
101
+ run "${systemctl_cmd}" "${action}" "${cmd}"
102
+ return $?
103
+ fi
104
+ return 1
105
+}
106
+
107
+# -----------------------------------------------------------------------------
108
+
109
+run_logfile="/dev/null"
110
+run() {
111
+ local user="${USER}" dir="$(basename "${PWD}")" info info_console
112
+
113
+ if [ "${UID}" = "0" ]
114
+ then
115
+ info="[root ${dir}]# "
116
+ info_console="[${COLOR_DIM}${dir}${COLOR_RESET}]# "
117
+ else
118
+ info="[${user} ${dir}]$ "
119
+ info_console="[${COLOR_DIM}${dir}${COLOR_RESET}]$ "
120
+ fi
121
+
122
+ printf >> "${run_logfile}" "${info}"
123
+ printf >> "${run_logfile}" "%q " "${@}"
124
+ printf >> "${run_logfile}" " ... "
125
+
126
+ printf >&2 "${info_console}${COLOR_BOLD}${COLOR_YELLOW}"
127
+ printf >&2 "%q " "${@}"
128
+ printf >&2 "${COLOR_RESET}\n"
129
+
130
+ "${@}"
131
+
132
+ local ret=$?
133
+ if [ ${ret} -ne 0 ]
134
+ then
135
+ printf >&2 "${COLOR_BGRED}${COLOR_WHITE}${COLOR_BOLD} FAILED ${COLOR_RESET}\n\n"
136
+ printf >> "${run_logfile}" "FAILED with exit code ${ret}\n"
137
+ else
138
+ printf >&2 "${COLOR_BGGREEN}${COLOR_WHITE}${COLOR_BOLD} OK ${COLOR_RESET}\n\n"
139
+ printf >> "${run_logfile}" "OK\n"
140
+ fi
141
+
142
+ return ${ret}
143
+}
144
+
145
+portable_add_user() {
146
+ local username="${1}"
147
+
148
+ getent passwd "${username}" > /dev/null 2>&1
149
+ [ $? -eq 0 ] && return 0
150
+
151
+ echo >&2 "Adding ${username} user account ..."
152
+
153
+ local nologin="$(which nologin 2>/dev/null || command -v nologin 2>/dev/null || echo '/bin/false')"
154
+
155
+ # Linux
156
+ if check_cmd useradd
157
+ then
158
+ run useradd -r -g "${username}" -c "${username}" -s "${nologin}" -d / "${username}" && return 0
159
+ fi
160
+
161
+ # FreeBSD
162
+ if check_cmd pw
163
+ then
164
+ run pw useradd "${username}" -d / -g "${username}" -s "${nologin}" && return 0
165
+ fi
166
+
167
+ # BusyBox
168
+ if check_cmd adduser
169
+ then
170
+ run adduser -D -G "${username}" "${username}" && return 0
171
+ fi
172
+
173
+ echo >&2 "Failed to add ${username} user account !"
174
+
175
+ return 1
176
+}
177
+
178
+portable_add_group() {
179
+ local groupname="${1}"
180
+
181
+ getent group "${groupname}" > /dev/null 2>&1
182
+ [ $? -eq 0 ] && return 0
183
+
184
+ echo >&2 "Adding ${groupname} user group ..."
185
+
186
+ # Linux
187
+ if check_cmd groupadd
188
+ then
189
+ run groupadd -r "${groupname}" && return 0
190
+ fi
191
+
192
+ # FreeBSD
193
+ if check_cmd pw
194
+ then
195
+ run pw groupadd "${groupname}" && return 0
196
+ fi
197
+
198
+ # BusyBox
199
+ if check_cmd addgroup
200
+ then
201
+ run addgroup "${groupname}" && return 0
202
+ fi
203
+
204
+ echo >&2 "Failed to add ${groupname} user group !"
205
+ return 1
206
+}
207
+
208
+portable_add_user_to_group() {
209
+ local groupname="${1}" username="${2}"
210
+
211
+ getent group "${groupname}" > /dev/null 2>&1
212
+ [ $? -ne 0 ] && return 1
213
+
214
+ # find the user is already in the group
215
+ local users=$(getent group "${groupname}" | cut -d ':' -f 4)
216
+ if [[ ",${users}," =~ ,${username}, ]]
217
+ then
218
+ # username is already there
219
+ return 0
220
+ else
221
+ # username is not in group
222
+ echo >&2 "Adding ${username} user to the ${groupname} group ..."
223
+
224
+ # Linux
225
+ if check_cmd usermod
226
+ then
227
+ run usermod -a -G "${groupname}" "${username}" && return 0
228
+ fi
229
+
230
+ # FreeBSD
231
+ if check_cmd pw
232
+ then
233
+ run pw groupmod "${groupname}" -m "${username}" && return 0
234
+ fi
235
+
236
+ # BusyBox
237
+ if check_cmd addgroup
238
+ then
239
+ run addgroup "${username}" "${groupname}" && return 0
240
+ fi
241
+
242
+ echo >&2 "Failed to add user ${username} to group ${groupname} !"
243
+ return 1
244
+ fi
245
+}
246
+
247
+iscontainer() {
248
+ # man systemd-detect-virt
249
+ local cmd=$(which_cmd systemd-detect-virt)
250
+ if [ ! -z "${cmd}" -a -x "${cmd}" ]
251
+ then
252
+ "${cmd}" --container >/dev/null 2>&1 && return 0
253
+ fi
254
+
255
+ # /proc/1/sched exposes the host's pid of our init !
256
+ # http://stackoverflow.com/a/37016302
257
+ local pid=$( cat /proc/1/sched | head -n 1 | { IFS='(),#:' read name pid th threads; echo $pid; } )
258
+ local p=$(( pid + 0 ))
259
+ [ ${pid} -ne 1 ] && return 0
260
+
261
+ # lxc sets environment variable 'container'
262
+ [ ! -z "${container}" ] && return 0
263
+
264
+ # docker creates /.dockerenv
265
+ # http://stackoverflow.com/a/25518345
266
+ [ -f "/.dockerenv" ] && return 0
267
+
268
+ # ubuntu and debian supply /bin/running-in-container
269
+ # https://www.apt-browse.org/browse/ubuntu/trusty/main/i386/upstart/1.12.1-0ubuntu4/file/bin/running-in-container
270
+ if [ -x "/bin/running-in-container" ]
271
+ then
272
+ "/bin/running-in-container" >/dev/null 2>&1 && return 0
273
+ fi
274
+
275
+ return 1
276
+}
277
+
278
+issystemd() {
279
+ local pids p myns ns systemctl
280
+
281
+ # if the directory /etc/systemd/system does not exit, it is not systemd
282
+ [ ! -d /etc/systemd/system ] && return 1
283
+
284
+ # if there is no systemctl command, it is not systemd
285
+ systemctl=$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)
286
+ [ -z "${systemctl}" -o ! -x "${systemctl}" ] && return 1
287
+
288
+ # if pid 1 is systemd, it is systemd
289
+ [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
290
+
291
+ # if systemd is not running, it is not systemd
292
+ pids=$(pidof systemd 2>/dev/null)
293
+ [ -z "${pids}" ] && return 1
294
+
295
+ # check if the running systemd processes are not in our namespace
296
+ myns="$(readlink /proc/self/ns/pid 2>/dev/null)"
297
+ for p in ${pids}
298
+ do
299
+ ns="$(readlink /proc/${p}/ns/pid 2>/dev/null)"
300
+
301
+ # if pid of systemd is in our namespace, it is systemd
302
+ [ ! -z "${myns}" && "${myns}" = "${ns}" ] && return 0
303
+ done
304
+
305
+ # else, it is not systemd
306
+ return 1
307
+}
netdata-installer.sh
+262
-453
@@ -10,13 +10,33 @@ if [ "${netdata_source_dir}" != "${installer_dir}" -a "${installer_dir}" != "."
10
echo >&2 "Warninng: you are currently in '${netdata_source_dir}' but the installer is in '${installer_dir}'."
11
fi
12
13
+
14
+# -----------------------------------------------------------------------------
15
# reload the user profile
16
+
17
[ -f /etc/profile ] && . /etc/profile
18
19
# make sure /etc/profile does not change our current directory
20
cd "${netdata_source_dir}" || exit 1
21
22
+
23
+# -----------------------------------------------------------------------------
24
+# load the required functions
25
+
26
+if [ -f "${installer_dir}/installer/functions.sh" ]
27
+ then
28
+ source "${installer_dir}/installer/functions.sh" || exit 1
29
+else
30
+ source "${netdata_source_dir}/installer/functions.sh" || exit 1
31
+fi
32
+
33
+# make sure we save all commands we run
34
+run_logfile="netdata-installer.log"
35
+
36
+
37
+# -----------------------------------------------------------------------------
38
# fix PKG_CHECK_MODULES error
39
+
40
if [ -d /usr/share/aclocal ]
41
then
42
ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
@@ -46,46 +66,7 @@ printf "\n" >>netdata-installer.log
66
REINSTALL_PWD="${PWD}"
67
REINSTALL_COMMAND="$(printf "%q " "$0" "${@}"; printf "\n")"
68
49
-banner() {
50
- local l1=" ^" \
51
- l2=" |.-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-" \
52
- l3=" | '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' " \
53
- l4=" +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->" \
54
- sp=" " \
55
- netdata="netdata" start end msg="${*}"
56
-
57
- [ ${#msg} -lt ${#netdata} ] && msg="${msg}${sp:0:$(( ${#netdata} - ${#msg}))}"
58
- [ ${#msg} -gt $(( ${#l2} - 20 )) ] && msg="${msg:0:$(( ${#l2} - 23 ))}..."
59
-
60
- start="$(( ${#l2} / 2 - 4 ))"
61
- [ $(( start + ${#msg} + 4 )) -gt ${#l2} ] && start=$((${#l2} - ${#msg} - 4))
62
- end=$(( ${start} + ${#msg} + 4 ))
63
-
64
- echo >&2
65
- echo >&2 "${l1}"
66
- echo >&2 "${l2:0:start}${sp:0:2}${netdata}${sp:0:$((end - start - 2 - ${#netdata}))}${l2:end:$((${#l2} - end))}"
67
- echo >&2 "${l3:0:start}${sp:0:2}${msg}${sp:0:2}${l3:end:$((${#l2} - end))}"
68
- echo >&2 "${l4}"
69
- echo >&2
70
-}
71
-
69
setcap="$(which setcap 2>/dev/null || command -v setcap 2>/dev/null)"
73
-service="$(which service 2>/dev/null || command -v service 2>/dev/null)"
74
-systemctl="$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)"
75
-service() {
76
- local cmd="${1}" action="${2}"
77
-
78
- if [ ! -z "${service}" ]
79
- then
80
- run "${service}" "${cmd}" "${action}"
81
- return $?
82
- elif [ ! -z "${systemctl}" ]
83
- then
84
- run "${systemctl}" "${action}" "${cmd}"
85
- return $?
86
- fi
87
- return 1
88
-}
70
71
ME="$0"
72
DONOTSTART=0
@@ -94,7 +75,7 @@ NETDATA_PREFIX=
75
LIBS_ARE_HERE=0
76
77
usage() {
97
- banner "installer command line options"
78
+ netdata_banner "installer command line options"
79
cat <<USAGE
80
81
${ME} <installer options>
@@ -220,7 +201,7 @@ do
201
fi
202
done
203
223
-banner "real-time performance monitoring, done right!"
204
+netdata_banner "real-time performance monitoring, done right!"
205
cat <<BANNER
206
207
You are about to build and install netdata to your system.
@@ -245,41 +226,42 @@ if [ "${UID}" -ne 0 ]
226
then
227
if [ -z "${NETDATA_PREFIX}" ]
228
then
248
- banner "wrong command line options!"
229
+ netdata_banner "wrong command line options!"
230
cat <<NONROOTNOPREFIX
250
-
251
-Sorry! This will fail!
252
-
253
-You are attempting to install netdata as non-root, but you plan to install it
254
-in system paths.
255
-
256
-Please set an installation prefix, like this:
257
-
258
- $0 ${@} --install /tmp
259
-
260
-or, run the installer as root:
261
-
262
- sudo $0 ${@}
263
-
264
-We suggest to install it as root, or certain data collectors will not be able
265
-to work. Netdata drops root privileges when running. So, if you plan to keep
266
-it, install it as root to get the full functionality.
267
-
231
+
232
+ Sorry! This will fail!
233
+
234
+ You are attempting to install netdata as non-root, but you plan
235
+ to install it in system paths.
236
+
237
+ Please set an installation prefix, like this:
238
+
239
+ $0 ${@} --install /tmp
240
+
241
+ or, run the installer as root:
242
+
243
+ sudo $0 ${@}
244
+
245
+ We suggest to install it as root, or certain data collectors will
246
+ not be able to work. Netdata drops root privileges when running.
247
+ So, if you plan to keep it, install it as root to get the full
248
+ functionality.
249
+
250
NONROOTNOPREFIX
251
exit 1
252
253
else
254
cat <<NONROOT
273
-
274
-IMPORTANT:
275
-You are about to install netdata as a non-root user.
276
-Netdata will work, but a few data collection modules that
277
-require root access will fail.
278
-
279
-If you installing permanently on your system, run the
280
-installer like this:
281
-
282
- sudo $0 ${@}
255
+
256
+ IMPORTANT:
257
+ You are about to install netdata as a non-root user.
258
+ Netdata will work, but a few data collection modules that
259
+ require root access will fail.
260
+
261
+ If you installing netdata permanently on your system, run
262
+ the installer like this:
263
+
264
+ sudo $0 ${@}
265
266
NONROOT
267
fi
@@ -318,7 +300,7 @@ then
300
then
301
echo "Will skip autoreconf step"
302
else
321
- banner "autotools v2.60 required"
303
+ netdata_banner "autotools v2.60 required"
304
cat <<"EOF"
305
306
-------------------------------------------------------------------------------
@@ -345,14 +327,14 @@ if [ ${DONOTWAIT} -eq 0 ]
327
then
328
if [ ! -z "${NETDATA_PREFIX}" ]
329
then
348
- read -p "Press ENTER to build and install netdata to '${NETDATA_PREFIX}' > "
330
+ eval "read >&2 -ep \$'\001${COLOR_BOLD}${COLOR_GREEN}\002Press ENTER to build and install netdata to \'\001${COLOR_CYAN}\002${NETDATA_PREFIX}\001${COLOR_YELLOW}\002\'\001${COLOR_RESET}\002 > ' -e -r REPLY"
331
else
350
- read -p "Press ENTER to build and install netdata to your system > "
332
+ eval "read >&2 -ep \$'\001${COLOR_BOLD}${COLOR_GREEN}\002Press ENTER to build and install netdata to your system\001${COLOR_RESET}\002 > ' -e -r REPLY"
333
fi
334
fi
335
336
build_error() {
355
- banner "sorry, it failed to build..."
337
+ netdata_banner "sorry, it failed to build..."
338
cat <<EOF
339
340
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -387,31 +369,6 @@ EOF
369
exit 1
370
}
371
390
-run() {
391
- printf >>netdata-installer.log "# "
392
- printf >>netdata-installer.log "%q " "${@}"
393
- printf >>netdata-installer.log " ... "
394
-
395
- printf >&2 "\n"
396
- printf >&2 ":-----------------------------------------------------------------------------\n"
397
- printf >&2 "Running command (in $(pwd)):\n"
398
- printf >&2 "\n"
399
- printf >&2 "%q " "${@}"
400
- printf >&2 "\n"
401
-
402
- "${@}"
403
-
404
- local ret=$?
405
- if [ ${ret} -ne 0 ]
406
- then
407
- printf >>netdata-installer.log "FAILED!\n"
408
- else
409
- printf >>netdata-installer.log "OK\n"
410
- fi
411
-
412
- return ${ret}
413
-}
414
-
372
if [ ${LIBS_ARE_HERE} -eq 1 ]
373
then
374
shift
@@ -424,6 +381,11 @@ fi
381
382
trap build_error EXIT
383
384
+
385
+# -----------------------------------------------------------------------------
386
+echo >&2
387
+progress "Run autotools to configure the build environment"
388
+
389
if [ "$have_autotools" ]
390
then
391
run ./autogen.sh || exit 1
@@ -439,23 +401,19 @@ run ./configure \
401
# remove the build_error hook
402
trap - EXIT
403
442
-if [ -f src/netdata ]
443
- then
444
- echo >&2 "Cleaning a possibly old compilation ..."
445
- run make clean
446
-fi
404
+# -----------------------------------------------------------------------------
405
+progress "Cleanup compilation directory"
406
+
407
+[ -f src/netdata ] && run make clean
408
+
409
+# -----------------------------------------------------------------------------
410
+progress "Compile netdata"
411
448
-echo >&2 "Compiling netdata ..."
412
run make -j${processors} || exit 1
413
451
-if [ "${BASH_VERSINFO[0]}" -ge "4" ]
452
-then
453
- declare -A configs_signatures=()
454
- if [ -f "configs.signatures" ]
455
- then
456
- source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !"
457
- fi
458
-fi
414
+
415
+# -----------------------------------------------------------------------------
416
+progress "Migrate configuration files for node.d.plugin and charts.d.plugin"
417
418
# migrate existing configuration files
419
# for node.d and charts.d
@@ -498,6 +456,18 @@ if [ -d "${NETDATA_PREFIX}/etc/netdata" ]
456
done
457
fi
458
459
+# -----------------------------------------------------------------------------
460
+progress "Backup existing netdata configuration before installing it"
461
+
462
+if [ "${BASH_VERSINFO[0]}" -ge "4" ]
463
+then
464
+ declare -A configs_signatures=()
465
+ if [ -f "configs.signatures" ]
466
+ then
467
+ source "configs.signatures" || echo >&2 "ERROR: Failed to load configs.signatures !"
468
+ fi
469
+fi
470
+
471
# backup user configurations
472
installer_backup_suffix="${PID}.${RANDOM}"
473
for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
@@ -547,10 +517,16 @@ do
517
fi
518
done
519
550
-echo >&2 "Installing netdata ..."
520
+
521
+# -----------------------------------------------------------------------------
522
+progress "Install netdata"
523
+
524
run make install || exit 1
525
553
-# restore user configurations
526
+
527
+# -----------------------------------------------------------------------------
528
+progress "Restore netdata configuration files"
529
+
530
for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
531
do
532
if [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
@@ -560,148 +536,15 @@ do
536
fi
537
done
538
563
-echo >&2 "Fixing permissions ..."
564
-
565
-check_cmd() {
566
- which "${1}" >/dev/null 2>&1 && return 0
567
- command -v "${1}" >/dev/null 2>&1 && return 0
568
- return 1
569
-}
570
-
571
-portable_add_user() {
572
- local username="${1}"
573
-
574
- getent passwd "${username}" > /dev/null 2>&1
575
- [ $? -eq 0 ] && return 0
576
-
577
- echo >&2 "Adding ${username} user account ..."
578
-
579
- local nologin="$(which nologin 2>/dev/null || command -v nologin 2>/dev/null || echo '/bin/false')"
580
-
581
- # Linux
582
- if check_cmd useradd
583
- then
584
- run useradd -r -g "${username}" -c "${username}" -s "${nologin}" -d / "${username}" && return 0
585
- fi
586
-
587
- # FreeBSD
588
- if check_cmd pw
589
- then
590
- run pw useradd "${username}" -d / -g "${username}" -s "${nologin}" && return 0
591
- fi
592
-
593
- # BusyBox
594
- if check_cmd adduser
595
- then
596
- run adduser -D -G "${username}" "${username}" && return 0
597
- fi
598
-
599
- echo >&2 "Failed to add ${username} user account !"
600
-
601
- return 1
602
-}
603
-
604
-portable_add_group() {
605
- local groupname="${1}"
606
-
607
- getent group "${groupname}" > /dev/null 2>&1
608
- [ $? -eq 0 ] && return 0
609
-
610
- echo >&2 "Adding ${groupname} user group ..."
611
-
612
- # Linux
613
- if check_cmd groupadd
614
- then
615
- run groupadd -r "${groupname}" && return 0
616
- fi
617
-
618
- # FreeBSD
619
- if check_cmd pw
620
- then
621
- run pw groupadd "${groupname}" && return 0
622
- fi
623
-
624
- # BusyBox
625
- if check_cmd addgroup
626
- then
627
- run addgroup "${groupname}" && return 0
628
- fi
629
-
630
- echo >&2 "Failed to add ${groupname} user group !"
631
- return 1
632
-}
633
-
634
-portable_add_user_to_group() {
635
- local groupname="${1}" username="${2}"
636
-
637
- getent group "${groupname}" > /dev/null 2>&1
638
- [ $? -ne 0 ] && return 1
639
-
640
- # find the user is already in the group
641
- local users=$(getent group "${groupname}" | cut -d ':' -f 4)
642
- if [[ ",${users}," =~ ,${username}, ]]
643
- then
644
- # username is already there
645
- return 0
646
- else
647
- # username is not in group
648
- echo >&2 "Adding ${username} user to the ${groupname} group ..."
649
-
650
- # Linux
651
- if check_cmd usermod
652
- then
653
- run usermod -a -G "${groupname}" "${username}" && return 0
654
- fi
655
-
656
- # FreeBSD
657
- if check_cmd pw
658
- then
659
- run pw groupmod "${groupname}" -m "${username}" && return 0
660
- fi
661
-
662
- # BusyBox
663
- if check_cmd addgroup
664
- then
665
- run addgroup "${username}" "${groupname}" && return 0
666
- fi
667
-
668
- echo >&2 "Failed to add user ${username} to group ${groupname} !"
669
- return 1
670
- fi
671
-}
672
-
673
-iscontainer() {
674
- # man systemd-detect-virt
675
- local cmd=$(which systemd-detect-virt 2>/dev/null || command -v systemd-detect-virt 2>/dev/null)
676
- if [ ! -z "${cmd}" -a -x "${cmd}" ]
677
- then
678
- "${cmd}" --container >/dev/null 2>&1 && return 0
679
- fi
680
-
681
- # /proc/1/sched exposes the host's pid of our init !
682
- # http://stackoverflow.com/a/37016302
683
- local pid=$( cat /proc/1/sched | head -n 1 | { IFS='(),#:' read name pid th threads; echo $pid; } )
684
- local p=$(( pid + 0 ))
685
- [ ${pid} -ne 1 ] && return 0
686
-
687
- # lxc sets environment variable 'container'
688
- [ ! -z "${container}" ] && return 0
539
690
- # docker creates /.dockerenv
691
- # http://stackoverflow.com/a/25518345
692
- [ -f "/.dockerenv" ] && return 0
540
+# -----------------------------------------------------------------------------
541
+progress "Fix generated files permissions"
542
694
- # ubuntu and debian supply /bin/running-in-container
695
- # https://www.apt-browse.org/browse/ubuntu/trusty/main/i386/upstart/1.12.1-0ubuntu4/file/bin/running-in-container
696
- if [ -x "/bin/running-in-container" ]
697
- then
698
- "/bin/running-in-container" >/dev/null 2>&1 && return 0
699
- fi
543
+run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.logrotate -exec chmod 755 {} \;
544
701
- return 1
702
-}
545
704
-run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.logrotate -exec chmod 755 {} \;
546
+# -----------------------------------------------------------------------------
547
+progress "Add user netdata to required user groups"
548
549
NETDATA_ADDED_TO_DOCKER=0
550
NETDATA_ADDED_TO_NGINX=0
@@ -712,31 +555,37 @@ if [ ${UID} -eq 0 ]
555
then
556
portable_add_group netdata
557
portable_add_user netdata
715
- portable_add_user_to_group docker netdata && NETDATA_ADDED_TO_DOCKER=1
716
- portable_add_user_to_group nginx netdata && NETDATA_ADDED_TO_NGINX=1
558
+ portable_add_user_to_group docker netdata && NETDATA_ADDED_TO_DOCKER=1
559
+ portable_add_user_to_group nginx netdata && NETDATA_ADDED_TO_NGINX=1
560
portable_add_user_to_group varnish netdata && NETDATA_ADDED_TO_VARNISH=1
561
portable_add_user_to_group haproxy netdata && NETDATA_ADDED_TO_HAPROXY=1
719
- portable_add_user_to_group adm netdata && NETDATA_ADDED_TO_ADM=1
562
+ portable_add_user_to_group adm netdata && NETDATA_ADDED_TO_ADM=1
563
+fi
564
+
565
566
+# -----------------------------------------------------------------------------
567
+progress "Install logrotate configuration for netdata"
568
+
569
+if [ ${UID} -eq 0 ]
570
+ then
571
if [ -d /etc/logrotate.d -a ! -f /etc/logrotate.d/netdata ]
572
then
723
- echo >&2 "Adding netdata logrotate configuration ..."
573
run cp system/netdata.logrotate /etc/logrotate.d/netdata
574
fi
575
576
if [ -f /etc/logrotate.d/netdata ]
577
then
729
- echo >&2 "Fixing netdata logrotate permissions ..."
578
run chmod 644 /etc/logrotate.d/netdata
579
fi
580
fi
581
582
583
# -----------------------------------------------------------------------------
736
-# load options from the configuration file
584
+progress "Read installation options from netdata.conf"
585
586
# create an empty config if it does not exist
739
-[ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
587
+[ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && \
588
+ touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
589
590
# function to extract values from the config file
591
config_option() {
@@ -789,17 +638,14 @@ NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
638
639
640
# -----------------------------------------------------------------------------
792
-# prepare the directories
641
+progress "Fix permissions of netdata directories (using user '${NETDATA_USER}')"
642
794
-# this is needed if NETDATA_PREFIX is not empty
643
if [ ! -d "${NETDATA_RUN_DIR}" ]
644
then
797
- mkdir -p "${NETDATA_RUN_DIR}" || exit 1
645
+ # this is needed if NETDATA_PREFIX is not empty
646
+ run mkdir -p "${NETDATA_RUN_DIR}" || exit 1
647
fi
648
800
-echo >&2
801
-echo >&2 "Fixing directories (user: ${NETDATA_USER})..."
802
-
649
# --- conf dir ----
650
651
for x in "python.d" "charts.d" "node.d"
@@ -887,33 +733,82 @@ fi
733
734
# --- fix #1292 bug ---
735
890
-[ -d "${NETDATA_PREFIX}/usr/libexec" ] && run chmod a+rX "${NETDATA_PREFIX}/usr/libexec"
736
+[ -d "${NETDATA_PREFIX}/usr/libexec" ] && run chmod a+rX "${NETDATA_PREFIX}/usr/libexec"
737
[ -d "${NETDATA_PREFIX}/usr/share/netdata" ] && run chmod a+rX "${NETDATA_PREFIX}/usr/share/netdata"
738
739
740
+
741
# -----------------------------------------------------------------------------
895
-# check if we can re-start netdata
742
+progress "Install netdata at system init"
743
897
-if [ ${DONOTSTART} -eq 1 ]
898
- then
899
- if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
744
+installed_init_d=0
745
+install_non_systemd_init() {
746
+ [ "${UID}" != 0 ] && return 1
747
+
748
+ local key="unknown"
749
+ if [ -f /etc/os-release ]
750
then
901
- echo >&2 "Generating empty config file in: ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
902
- echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
751
+ source /etc/os-release || return 1
752
+ key="${ID}-${VERSION_ID}"
753
904
- if [ "${UID}" -eq 0 ]
754
+ elif [ -f /etc/centos-release ]
755
+ then
756
+ key=$(</etc/centos-release)
757
+ fi
758
+
759
+ if [ -d /etc/init.d -a ! -f /etc/init.d/netdata ]
760
+ then
761
+ if [ "${key}" = "gentoo" ]
762
then
906
- chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
763
+ run cp system/netdata-openrc /etc/init.d/netdata && \
764
+ run chmod 755 /etc/init.d/netdata && \
765
+ run rc-update add netdata default && \
766
+ installed_init_d=1
767
+
768
+ elif [ "${key}" = "ubuntu-12.04" -o "${key}" = "ubuntu-14.04" -o "${key}" = "debian-7" ]
769
+ then
770
+ run cp system/netdata-lsb /etc/init.d/netdata && \
771
+ run chmod 755 /etc/init.d/netdata && \
772
+ run update-rc.d netdata defaults && \
773
+ run update-rc.d netdata enable && \
774
+ installed_init_d=1
775
+
776
+ elif [ "${key}" = "CentOS release 6.8 (Final)" -o "${key}" = "amzn-2016.09" ]
777
+ then
778
+ run cp system/netdata-init-d /etc/init.d/netdata && \
779
+ run chmod 755 /etc/init.d/netdata && \
780
+ run chkconfig netdata on && \
781
+ installed_init_d=1
782
fi
908
- chmod 0644 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
783
fi
910
- banner "is installed now!"
911
- echo >&2 " enjoy real-time performance and health monitoring..."
912
- exit 0
784
+
785
+ return 0
786
+}
787
+
788
+if [ "${UID}" -eq 0 ]
789
+ then
790
+
791
+ if issystemd
792
+ then
793
+ # systemd is running on this system
794
+
795
+ if [ ! -f /etc/systemd/system/netdata.service ]
796
+ then
797
+ echo >&2 "Installing systemd service..."
798
+ run cp system/netdata.service /etc/systemd/system/netdata.service && \
799
+ run systemctl daemon-reload && \
800
+ run systemctl enable netdata
801
+ fi
802
+ else
803
+ install_non_systemd_init
804
+ fi
805
fi
806
807
+
808
# -----------------------------------------------------------------------------
916
-# stop a running netdata
809
+# check if we can re-start netdata
810
+
811
+started=0
812
813
isnetdata() {
814
if [ -d /proc/self ]
@@ -979,111 +874,25 @@ stop_all_netdata() {
874
done
875
}
876
982
-# -----------------------------------------------------------------------------
983
-# check for systemd
984
-
985
-issystemd() {
986
- local pids p myns ns systemctl
987
-
988
- # if the directory /etc/systemd/system does not exit, it is not systemd
989
- [ ! -d /etc/systemd/system ] && return 1
990
-
991
- # if there is no systemctl command, it is not systemd
992
- systemctl=$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)
993
- [ -z "${systemctl}" -o ! -x "${systemctl}" ] && return 1
994
-
995
- # if pid 1 is systemd, it is systemd
996
- [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
997
-
998
- # if systemd is not running, it is not systemd
999
- pids=$(pidof systemd 2>/dev/null)
1000
- [ -z "${pids}" ] && return 1
1001
-
1002
- # check if the running systemd processes are not in our namespace
1003
- myns="$(readlink /proc/self/ns/pid 2>/dev/null)"
1004
- for p in ${pids}
1005
- do
1006
- ns="$(readlink /proc/${p}/ns/pid 2>/dev/null)"
1007
-
1008
- # if pid of systemd is in our namespace, it is systemd
1009
- [ ! -z "${myns}" && "${myns}" = "${ns}" ] && return 0
1010
- done
1011
-
1012
- # else, it is not systemd
1013
- return 1
1014
-}
1015
-
1016
-installed_init_d=0
1017
-install_non_systemd_init() {
1018
- [ "${UID}" != 0 ] && return 1
1019
-
1020
- local key="unknown"
1021
- if [ -f /etc/os-release ]
1022
- then
1023
- source /etc/os-release || return 1
1024
- key="${ID}-${VERSION_ID}"
1025
-
1026
- elif [ -f /etc/centos-release ]
1027
- then
1028
- key=$(</etc/centos-release)
1029
- fi
1030
-
1031
- if [ -d /etc/init.d -a ! -f /etc/init.d/netdata ]
877
+if [ ${DONOTSTART} -eq 1 ]
878
+ then
879
+ if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
880
then
1033
- if [ "${key}" = "gentoo" ]
1034
- then
1035
- run cp system/netdata-openrc /etc/init.d/netdata && \
1036
- run chmod 755 /etc/init.d/netdata && \
1037
- run rc-update add netdata default && \
1038
- installed_init_d=1
1039
-
1040
- elif [ "${key}" = "ubuntu-12.04" -o "${key}" = "ubuntu-14.04" -o "${key}" = "debian-7" ]
1041
- then
1042
- run cp system/netdata-lsb /etc/init.d/netdata && \
1043
- run chmod 755 /etc/init.d/netdata && \
1044
- run update-rc.d netdata defaults && \
1045
- run update-rc.d netdata enable && \
1046
- installed_init_d=1
881
+ echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
882
1048
- elif [ "${key}" = "CentOS release 6.8 (Final)" -o "${key}" = "amzn-2016.09" ]
883
+ if [ "${UID}" -eq 0 ]
884
then
1050
- run cp system/netdata-init-d /etc/init.d/netdata && \
1051
- run chmod 755 /etc/init.d/netdata && \
1052
- run chkconfig netdata on && \
1053
- installed_init_d=1
885
+ chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
886
fi
887
+ chmod 0644 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
888
fi
889
1057
- return 0
1058
-}
1059
-
1060
-started=0
1061
-if [ "${UID}" -eq 0 ]
1062
- then
890
+else
891
1064
- if issystemd
1065
- then
1066
- # systemd is running on this system
892
+ progress "Start netdata"
893
1068
- if [ ! -f /etc/systemd/system/netdata.service ]
894
+ if [ "${UID}" -eq 0 ]
895
then
1070
- echo >&2 "Installing systemd service..."
1071
- run cp system/netdata.service /etc/systemd/system/netdata.service && \
1072
- run systemctl daemon-reload && \
1073
- run systemctl enable netdata
1074
- else
1075
- service netdata stop
1076
- fi
1077
-
1078
- stop_all_netdata
1079
- service netdata restart && started=1
1080
- else
1081
- install_non_systemd_init
1082
- fi
1083
-
1084
- if [ ${started} -eq 0 ]
1085
- then
1086
- # check if we can use the system service
896
service netdata stop
897
stop_all_netdata
898
service netdata restart && started=1
@@ -1092,80 +901,79 @@ if [ "${UID}" -eq 0 ]
901
service netdata start && started=1
902
fi
903
fi
1095
-fi
904
1097
-if [ ${started} -eq 0 ]
1098
-then
1099
- # still not started...
905
+ if [ ${started} -eq 0 ]
906
+ then
907
+ # still not started...
908
1101
- stop_all_netdata
909
+ stop_all_netdata
910
+
911
+ echo >&2 "Starting netdata..."
912
+ run ${NETDATA_PREFIX}/usr/sbin/netdata -P ${NETDATA_RUN_DIR}/netdata.pid "${@}"
913
+ if [ $? -ne 0 ]
914
+ then
915
+ echo >&2
916
+ echo >&2 "SORRY! FAILED TO START NETDATA!"
917
+ exit 1
918
+ else
919
+ echo >&2 "OK. NetData Started!"
920
+ fi
921
1103
- echo >&2 "Starting netdata..."
1104
- run ${NETDATA_PREFIX}/usr/sbin/netdata -P ${NETDATA_RUN_DIR}/netdata.pid "${@}"
1105
- if [ $? -ne 0 ]
1106
- then
922
echo >&2
1108
- echo >&2 "SORRY! FAILED TO START NETDATA!"
1109
- exit 1
1110
- else
1111
- echo >&2 "OK. NetData Started!"
923
fi
924
1114
- echo >&2
1115
-fi
1116
-
1117
-# -----------------------------------------------------------------------------
1118
-# save a config file, if it is not already there
1119
-
1120
-if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
1121
- then
1122
- echo >&2
1123
- echo >&2 "-------------------------------------------------------------------------------"
1124
- echo >&2
1125
- echo >&2 "Downloading default configuration from netdata..."
1126
- sleep 5
925
+ # -----------------------------------------------------------------------------
926
+ # save a config file, if it is not already there
927
1128
- # remove a possibly obsolete download
1129
- [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
928
+ if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
929
+ then
930
+ echo >&2
931
+ echo >&2 "-------------------------------------------------------------------------------"
932
+ echo >&2
933
+ echo >&2 "Downloading default configuration from netdata..."
934
+ sleep 5
935
1131
- # disable a proxy to get data from the local netdata
1132
- export http_proxy=
1133
- export https_proxy=
936
+ # remove a possibly obsolete download
937
+ [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
938
1135
- # try wget
1136
- wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
1137
- ret=$?
939
+ # disable a proxy to get data from the local netdata
940
+ export http_proxy=
941
+ export https_proxy=
942
1139
- # try curl
1140
- if [ ${ret} -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
1141
- then
1142
- curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
943
+ # try wget
944
+ wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
945
ret=$?
1144
- fi
946
1146
- if [ ${ret} -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
1147
- then
1148
- mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
1149
- echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
947
+ # try curl
948
+ if [ ${ret} -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
949
+ then
950
+ curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
951
+ ret=$?
952
+ fi
953
1151
- if [ "${UID}" -eq 0 ]
954
+ if [ ${ret} -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
955
then
1153
- chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
956
+ mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
957
+ echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
958
+
959
+ if [ "${UID}" -eq 0 ]
960
+ then
961
+ chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
962
+ fi
963
+ chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
964
+ else
965
+ echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
966
+ [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
967
fi
1155
- chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
1156
- else
1157
- echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
1158
- [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
968
fi
969
fi
970
971
# -----------------------------------------------------------------------------
1163
-# Check for KSM
972
+progress "Check KSM (kernel memory deduper)"
973
974
ksm_is_available_but_disabled() {
975
cat <<KSM1
976
1168
--------------------------------------------------------------------------------
977
Memory de-duplication instructions
978
979
You have kernel memory de-duper (called Kernel Same-page Merging,
@@ -1173,8 +981,8 @@ or KSM) available, but it is not currently enabled.
981
982
To enable it run:
983
1176
-echo 1 >/sys/kernel/mm/ksm/run
1177
-echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
984
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}echo 1 >/sys/kernel/mm/ksm/run${COLOR_RESET}")
985
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs${COLOR_RESET}")
986
987
If you enable it, you will save 40-60% of netdata memory.
988
@@ -1184,7 +992,6 @@ KSM1
992
ksm_is_not_available() {
993
cat <<KSM2
994
1187
--------------------------------------------------------------------------------
995
Memory de-duplication not present in your kernel
996
997
It seems you do not have kernel memory de-duper (called Kernel Same-page
@@ -1208,13 +1015,12 @@ else
1015
fi
1016
1017
# -----------------------------------------------------------------------------
1211
-# Check for version.txt
1018
+progress "Check version.txt"
1019
1020
if [ ! -s web/version.txt ]
1021
then
1022
cat <<VERMSG
1023
1217
--------------------------------------------------------------------------------
1024
Version update check warning
1025
1026
The way you downloaded netdata, we cannot find its version. This means the
@@ -1229,13 +1035,12 @@ VERMSG
1035
fi
1036
1037
# -----------------------------------------------------------------------------
1232
-# apps.plugin warning
1038
+progress "Check apps.plugin"
1039
1040
if [ "${UID}" -ne 0 ]
1041
then
1042
cat <<SETUID_WARNING
1043
1238
--------------------------------------------------------------------------------
1044
apps.plugin needs privileges
1045
1046
Since you have installed netdata as a normal user, to have apps.plugin collect
@@ -1244,14 +1049,14 @@ either of the following sets of commands:
1049
1050
To run apps.plugin with escalated capabilities:
1051
1247
- sudo chown root:${NETDATA_USER} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
1248
- sudo chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
1249
- sudo setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
1052
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}sudo chown root:${NETDATA_USER} \"${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin\"${COLOR_RESET}")
1053
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}sudo chmod 0750 \"${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin\"${COLOR_RESET}")
1054
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}sudo setcap cap_dac_read_search,cap_sys_ptrace+ep \"${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin\"${COLOR_RESET}")
1055
1056
or, to run apps.plugin as root:
1057
1253
- sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
1254
- sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
1058
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}sudo chown root \"${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin\"${COLOR_RESET}")
1059
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}sudo chmod 4755 \"${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin\"${COLOR_RESET}")
1060
1061
apps.plugin is performing a hard-coded function of data collection for all
1062
running processes. It cannot be instructed from the netdata daemon to perform
@@ -1261,7 +1066,7 @@ SETUID_WARNING
1066
fi
1067
1068
# -----------------------------------------------------------------------------
1264
-# Keep un-install info
1069
+progress "Generate netdata-uninstaller.sh"
1070
1071
cat >netdata-uninstaller.sh <<UNINSTALL
1072
#!/usr/bin/env bash
@@ -1397,32 +1202,26 @@ UNINSTALL
1202
chmod 750 netdata-uninstaller.sh
1203
1204
# -----------------------------------------------------------------------------
1205
+progress "Basic netdata instructions"
1206
1207
cat <<END
1208
1403
-
1404
--------------------------------------------------------------------------------
1405
-
1406
-OK. NetData is installed and it is running.
1407
-
1408
--------------------------------------------------------------------------------
1409
-
1410
-By default netdata listens on all IPs on port ${NETDATA_PORT},
1209
+netdata by default netdata listens on all IPs on port ${NETDATA_PORT},
1210
so you can access it with:
1211
1212
http://this.machine.ip:${NETDATA_PORT}/
1213
1214
To stop netdata, just kill it, with:
1215
1417
- killall netdata
1216
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}killall netdata${COLOR_RESET}")
1217
1218
To start it, just run it:
1219
1421
- ${NETDATA_PREFIX}/usr/sbin/netdata
1220
+ $(printf "${COLOR_YELLOW}${COLOR_BOLD}${NETDATA_PREFIX}/usr/sbin/netdata${COLOR_RESET}")
1221
1222
1223
END
1425
-echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"
1224
+echo >&2 -e "Uninstall script generated: ${COLOR_YELLOW}${COLOR_BOLD}./netdata-uninstaller.sh${COLOR_RESET}"
1225
1226
if [ -d .git ]
1227
then
@@ -1538,13 +1337,23 @@ update && exit 0
1337
REINSTALL
1338
chmod 755 netdata-updater.sh.new
1339
mv -f netdata-updater.sh.new netdata-updater.sh
1541
- echo >&2 "Update script generated : ./netdata-updater.sh"
1340
+ echo >&2 -e "Update script generated : ${COLOR_YELLOW}${COLOR_BOLD}./netdata-updater.sh${COLOR_RESET}"
1341
elif [ -f "netdata-updater.sh" ]
1342
then
1343
rm "netdata-updater.sh"
1344
fi
1345
1547
-banner "is installed and running now!"
1346
+# -----------------------------------------------------------------------------
1347
+echo >&2
1348
+progress "We are done!"
1349
+
1350
+if [ ${started} -eq 1 ]
1351
+ then
1352
+ netdata_banner "is installed and running now!"
1353
+else
1354
+ netdata_banner "is installed now!"
1355
+fi
1356
+
1357
echo >&2 " enjoy real-time performance and health monitoring..."
1358
echo >&2
1359
exit 0