]> arthur.barton.de Git - netdata.git/blob - netdata-installer.sh
colorful netdata-installer.sh; splitted certain functions for adding makeself; netdat...
[netdata.git] / netdata-installer.sh
1 #!/usr/bin/env bash
2
3 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
4
5 netdata_source_dir="$(pwd)"
6 installer_dir="$(dirname "${0}")"
7
8 if [ "${netdata_source_dir}" != "${installer_dir}" -a "${installer_dir}" != "." ]
9     then
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}
43         export ACLOCAL_PATH
44 fi
45
46 LC_ALL=C
47 umask 002
48
49 # Be nice on production environments
50 renice 19 $$ >/dev/null 2>/dev/null
51
52 processors=$(grep ^processor </proc/cpuinfo 2>/dev/null | wc -l)
53 [ $(( processors )) -lt 1 ] && processors=1
54
55 # you can set CFLAGS before running installer
56 CFLAGS="${CFLAGS--O2}"
57 [ "z${CFLAGS}" = "z-O3" ] && CFLAGS="-O2"
58
59 # keep a log of this command
60 printf "\n# " >>netdata-installer.log
61 date >>netdata-installer.log
62 printf "CFLAGS=\"%s\" " "${CFLAGS}" >>netdata-installer.log
63 printf "%q " "$0" "${@}" >>netdata-installer.log
64 printf "\n" >>netdata-installer.log
65
66 REINSTALL_PWD="${PWD}"
67 REINSTALL_COMMAND="$(printf "%q " "$0" "${@}"; printf "\n")"
68
69 setcap="$(which setcap 2>/dev/null || command -v setcap 2>/dev/null)"
70
71 ME="$0"
72 DONOTSTART=0
73 DONOTWAIT=0
74 NETDATA_PREFIX=
75 LIBS_ARE_HERE=0
76
77 usage() {
78     netdata_banner "installer command line options"
79     cat <<USAGE
80
81 ${ME} <installer options>
82
83 Valid <installer options> are:
84
85    --install /PATH/TO/INSTALL
86
87         If your give: --install /opt
88         netdata will be installed in /opt/netdata
89
90    --dont-start-it
91
92         Do not (re)start netdata.
93         Just install it.
94
95    --dont-wait
96
97         Do not wait for the user to press ENTER.
98         Start immediately building it.
99
100    --zlib-is-really-here
101    --libs-are-really-here
102
103         If you get errors about missing zlib,
104         or libuuid but you know it is available,
105         you have a broken pkg-config.
106         Use this option to allow it continue
107         without checking pkg-config.
108
109 Netdata will by default be compiled with gcc optimization -O2
110 If you need to pass different CFLAGS, use something like this:
111
112   CFLAGS="<gcc options>" ${ME} <installer options>
113
114 For the installer to complete successfully, you will need
115 these packages installed:
116
117    gcc make autoconf automake pkg-config zlib1g-dev (or zlib-devel)
118    uuid-dev (or libuuid-devel)
119
120 For the plugins, you will at least need:
121
122    curl nodejs
123
124 USAGE
125 }
126
127 md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null)"
128 get_git_config_signatures() {
129     local x s file md5
130
131     [ ! -d "conf.d" ] && echo >&2 "Wrong directory." && return 1
132     [ -z "${md5sum}" -o ! -x "${md5sum}" ] && echo >&2 "No md5sum command." && return 1
133
134     echo >configs.signatures.tmp
135
136     for x in $(find conf.d -name \*.conf)
137     do
138             x="${x/conf.d\//}"
139             echo "${x}"
140             for c in $(git log --follow "conf.d/${x}" | grep ^commit | cut -d ' ' -f 2)
141             do
142                     git checkout ${c} "conf.d/${x}" || continue
143                     s="$(cat "conf.d/${x}" | md5sum | cut -d ' ' -f 1)"
144                     echo >>configs.signatures.tmp "${s}:${x}"
145                     echo "    ${s}"
146             done
147             git checkout HEAD "conf.d/${x}" || break
148     done
149
150     cat configs.signatures.tmp |\
151         grep -v "^$" |\
152         sort -u |\
153         {
154             echo "declare -A configs_signatures=("
155             IFS=":"
156             while read md5 file
157             do
158                 echo "  ['${md5}']='${file}'"
159             done
160             echo ")"
161         } >configs.signatures
162
163     rm configs.signatures.tmp
164
165     return 0
166 }
167
168
169 while [ ! -z "${1}" ]
170 do
171     if [ "$1" = "--install" ]
172         then
173         NETDATA_PREFIX="${2}/netdata"
174         shift 2
175     elif [ "$1" = "--zlib-is-really-here" -o "$1" = "--libs-are-really-here" ]
176         then
177         LIBS_ARE_HERE=1
178         shift 1
179     elif [ "$1" = "--dont-start-it" ]
180         then
181         DONOTSTART=1
182         shift 1
183     elif [ "$1" = "--dont-wait" ]
184         then
185         DONOTWAIT=1
186         shift 1
187     elif [ "$1" = "--help" -o "$1" = "-h" ]
188         then
189         usage
190         exit 1
191     elif [ "$1" = "get_git_config_signatures" ]
192         then
193         get_git_config_signatures && exit 0
194         exit 1
195     else
196         echo >&2
197         echo >&2 "ERROR:"
198         echo >&2 "I cannot understand option '$1'."
199         usage
200         exit 1
201     fi
202 done
203
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.
208
209   It will be installed at these locations:
210
211    - the daemon    at ${NETDATA_PREFIX}/usr/sbin/netdata
212    - config files  at ${NETDATA_PREFIX}/etc/netdata
213    - web files     at ${NETDATA_PREFIX}/usr/share/netdata
214    - plugins       at ${NETDATA_PREFIX}/usr/libexec/netdata
215    - cache files   at ${NETDATA_PREFIX}/var/cache/netdata
216    - db files      at ${NETDATA_PREFIX}/var/lib/netdata
217    - log files     at ${NETDATA_PREFIX}/var/log/netdata
218    - pid file      at ${NETDATA_PREFIX}/var/run
219
220   This installer allows you to change the installation path.
221   Press Control-C and run the same command with --help for help.
222
223 BANNER
224
225 if [ "${UID}" -ne 0 ]
226     then
227     if [ -z "${NETDATA_PREFIX}" ]
228         then
229         netdata_banner "wrong command line options!"
230         cat <<NONROOTNOPREFIX
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
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
268 fi
269
270 have_autotools=
271 if [ "$(type autoreconf 2> /dev/null)" ]
272 then
273     autoconf_maj_min() {
274         local maj min IFS=.-
275
276         maj=$1
277         min=$2
278
279         set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
280         eval $maj=\$1 $min=\$2
281     }
282     autoconf_maj_min AMAJ AMIN
283
284     if [ "$AMAJ" -gt 2 ]
285     then
286         have_autotools=Y
287     elif [ "$AMAJ" -eq 2 -a "$AMIN" -ge 60 ]
288     then
289         have_autotools=Y
290     else
291         echo "Found autotools $AMAJ.$AMIN"
292     fi
293 else
294     echo "No autotools found"
295 fi
296
297 if [ ! "$have_autotools" ]
298 then
299     if [ -f configure ]
300     then
301         echo "Will skip autoreconf step"
302     else
303         netdata_banner "autotools v2.60 required"
304         cat <<"EOF"
305
306 -------------------------------------------------------------------------------
307 autotools 2.60 or later is required
308
309 Sorry, you do not seem to have autotools 2.60 or later, which is
310 required to build from the git sources of netdata.
311
312 You can either install a suitable version of autotools and automake
313 or download a netdata package which does not have these dependencies.
314
315 Source packages where autotools have already been run are available
316 here:
317        https://firehol.org/download/netdata/
318
319 The unsigned/master folder tracks the head of the git tree and released
320 packages are also available.
321 EOF
322         exit 1
323     fi
324 fi
325
326 if [ ${DONOTWAIT} -eq 0 ]
327     then
328     if [ ! -z "${NETDATA_PREFIX}" ]
329         then
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
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() {
337     netdata_banner "sorry, it failed to build..."
338     cat <<EOF
339
340 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
341
342 Sorry! netdata failed to build...
343
344 You many need to check these:
345
346 1. The package uuid-dev (or libuuid-devel) has to be installed.
347
348    If your system cannot find libuuid, although it is installed
349    run me with the option:  --libs-are-really-here
350
351 2. The package zlib1g-dev (or zlib-devel) has to be installed.
352
353    If your system cannot find zlib, although it is installed
354    run me with the option:  --libs-are-really-here
355
356 3. You need basic build tools installed, like:
357
358    gcc make autoconf automake pkg-config
359
360    Autoconf version 2.60 or higher is required.
361
362 If you still cannot get it to build, ask for help at github:
363
364    https://github.com/firehol/netdata/issues
365
366
367 EOF
368     trap - EXIT
369     exit 1
370 }
371
372 if [ ${LIBS_ARE_HERE} -eq 1 ]
373     then
374     shift
375     echo >&2 "ok, assuming libs are really installed."
376     export ZLIB_CFLAGS=" "
377     export ZLIB_LIBS="-lz"
378     export UUID_CFLAGS=" "
379     export UUID_LIBS="-luuid"
380 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
392 fi
393
394 run ./configure \
395     --prefix="${NETDATA_PREFIX}/usr" \
396     --sysconfdir="${NETDATA_PREFIX}/etc" \
397     --localstatedir="${NETDATA_PREFIX}/var" \
398     --with-zlib --with-math --with-user=netdata \
399     CFLAGS="${CFLAGS}" || exit 1
400
401 # remove the build_error hook
402 trap - EXIT
403
404 # -----------------------------------------------------------------------------
405 progress "Cleanup compilation directory"
406
407 [ -f src/netdata ] && run make clean
408
409 # -----------------------------------------------------------------------------
410 progress "Compile netdata"
411
412 run make -j${processors} || exit 1
413
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
420 if [ -d "${NETDATA_PREFIX}/etc/netdata" ]
421     then
422     # the configuration directory exists
423
424     if [ ! -d "${NETDATA_PREFIX}/etc/netdata/charts.d" ]
425         then
426         run mkdir "${NETDATA_PREFIX}/etc/netdata/charts.d"
427     fi
428
429     # move the charts.d config files
430     for x in apache ap cpu_apps cpufreq example exim hddtemp load_average mem_apps mysql nginx nut opensips phpfpm postfix sensors squid tomcat
431     do
432         for y in "" ".old" ".orig"
433         do
434             if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}" ]
435                 then
436                 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/charts.d/${x}.conf${y}"
437             fi
438         done
439     done
440
441     if [ ! -d "${NETDATA_PREFIX}/etc/netdata/node.d" ]
442         then
443         run mkdir "${NETDATA_PREFIX}/etc/netdata/node.d"
444     fi
445
446     # move the node.d config files
447     for x in named sma_webbox snmp
448     do
449         for y in "" ".old" ".orig"
450         do
451             if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" -a ! -f "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}" ]
452                 then
453                 run mv -f "${NETDATA_PREFIX}/etc/netdata/${x}.conf${y}" "${NETDATA_PREFIX}/etc/netdata/node.d/${x}.conf${y}"
454             fi
455         done
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)
474 do
475     if [ -f "${x}" ]
476         then
477         # make a backup of the configuration file
478         cp -p "${x}" "${x}.old"
479
480         if [ -z "${md5sum}" -o ! -x "${md5sum}" ]
481             then
482             # we don't have md5sum - keep it
483             cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
484         else
485             # find it relative filename
486             f="${x/*\/etc\/netdata\//}"
487
488             # find its checksum
489             md5="$(cat "${x}" | ${md5sum} | cut -d ' ' -f 1)"
490
491             # copy the original
492             if [ -f "conf.d/${f}" ]
493                 then
494                 cp "conf.d/${f}" "${x}.orig"
495             fi
496
497             if [ "${BASH_VERSINFO[0]}" -ge "4" ]
498             then
499                 if [ "${configs_signatures[${md5}]}" = "${f}" ]
500                 then
501                     # it is a stock version - don't keep it
502                     echo >&2 "File '${x}' is stock version."
503                 else
504                     # edited by user - keep it
505                     echo >&2 "File '${x}' has been edited by user."
506                     cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
507                 fi
508             else
509                 echo >&2 "File '${x}' cannot be check for custom edits."
510                 cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
511             fi
512         fi
513
514     elif [ -f "${x}.installer_backup.${installer_backup_suffix}" ]
515         then
516         rm -f "${x}.installer_backup.${installer_backup_suffix}"
517     fi
518 done
519
520
521 # -----------------------------------------------------------------------------
522 progress "Install netdata"
523
524 run make install || exit 1
525
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}" ]
533         then
534         cp -p "${x}.installer_backup.${installer_backup_suffix}" "${x}"
535         rm -f "${x}.installer_backup.${installer_backup_suffix}"
536     fi
537 done
538
539
540 # -----------------------------------------------------------------------------
541 progress "Fix generated files permissions"
542
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
545
546 # -----------------------------------------------------------------------------
547 progress "Add user netdata to required user groups"
548
549 NETDATA_ADDED_TO_DOCKER=0
550 NETDATA_ADDED_TO_NGINX=0
551 NETDATA_ADDED_TO_VARNISH=0
552 NETDATA_ADDED_TO_HAPROXY=0
553 NETDATA_ADDED_TO_ADM=0
554 if [ ${UID} -eq 0 ]
555     then
556     portable_add_group netdata
557     portable_add_user netdata
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
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
573         run cp system/netdata.logrotate /etc/logrotate.d/netdata
574     fi
575     
576     if [ -f /etc/logrotate.d/netdata ]
577         then
578         run chmod 644 /etc/logrotate.d/netdata
579     fi
580 fi
581
582
583 # -----------------------------------------------------------------------------
584 progress "Read installation options from netdata.conf"
585
586 # create an empty config if it does not exist
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() {
592     local key="${1}" value="${2}" line=
593
594     if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
595         then
596         line="$( grep "^[[:space:]]*${key}[[:space:]]*=[[:space:]]*" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" | head -n 1 )"
597         [ ! -z "${line}" ] && value="$( echo "${line}" | cut -d '=' -f 2 | sed -e "s/^[[:space:]]\+//g" -e "s/[[:space:]]\+$//g" )"
598     fi
599
600     echo "${value}"
601 }
602
603 # the user netdata will run as
604 if [ "${UID}" = "0" ]
605     then
606     NETDATA_USER="$( config_option "run as user" "netdata" )"
607 else
608     NETDATA_USER="${USER}"
609 fi
610
611 # the owners of the web files
612 NETDATA_WEB_USER="$(  config_option "web files owner" "${NETDATA_USER}" )"
613 NETDATA_WEB_GROUP="$( config_option "web files group" "${NETDATA_WEB_USER}" )"
614
615 # debug flags
616 NETDATA_DEBUG="$( config_option "debug flags" 0 )"
617
618 # port
619 defport=19999
620 NETDATA_PORT="$( config_option "default port" ${defport} )"
621 NETDATA_PORT2="$( config_option "port" ${defport} )"
622
623 if [ "${NETDATA_PORT}" != "${NETDATA_PORT2}" ]
624 then
625     if [ "${NETDATA_PORT2}" != "${defport}" ]
626     then
627         NETDATA_PORT="${NETDATA_PORT2}"
628     fi
629 fi
630
631 # directories
632 NETDATA_LIB_DIR="$( config_option "lib directory" "${NETDATA_PREFIX}/var/lib/netdata" )"
633 NETDATA_CACHE_DIR="$( config_option "cache directory" "${NETDATA_PREFIX}/var/cache/netdata" )"
634 NETDATA_WEB_DIR="$( config_option "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )"
635 NETDATA_LOG_DIR="$( config_option "log directory" "${NETDATA_PREFIX}/var/log/netdata" )"
636 NETDATA_CONF_DIR="$( config_option "config directory" "${NETDATA_PREFIX}/etc/netdata" )"
637 NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
638
639
640 # -----------------------------------------------------------------------------
641 progress "Fix permissions of netdata directories (using user '${NETDATA_USER}')"
642
643 if [ ! -d "${NETDATA_RUN_DIR}" ]
644     then
645     # this is needed if NETDATA_PREFIX is not empty
646     run mkdir -p "${NETDATA_RUN_DIR}" || exit 1
647 fi
648
649 # --- conf dir ----
650
651 for x in "python.d" "charts.d" "node.d"
652 do
653     if [ ! -d "${NETDATA_CONF_DIR}/${x}" ]
654         then
655         echo >&2 "Creating directory '${NETDATA_CONF_DIR}/${x}'"
656         run mkdir -p "${NETDATA_CONF_DIR}/${x}" || exit 1
657     fi
658 done
659 run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${NETDATA_CONF_DIR}"
660 run find "${NETDATA_CONF_DIR}" -type f -exec chmod 0660 {} \;
661 run find "${NETDATA_CONF_DIR}" -type d -exec chmod 0775 {} \;
662
663 # --- web dir ----
664
665 if [ ! -d "${NETDATA_WEB_DIR}" ]
666     then
667     echo >&2 "Creating directory '${NETDATA_WEB_DIR}'"
668     run mkdir -p "${NETDATA_WEB_DIR}" || exit 1
669 fi
670 run chown -R "${NETDATA_WEB_USER}:${NETDATA_WEB_GROUP}" "${NETDATA_WEB_DIR}"
671 run find "${NETDATA_WEB_DIR}" -type f -exec chmod 0664 {} \;
672 run find "${NETDATA_WEB_DIR}" -type d -exec chmod 0775 {} \;
673
674 # --- data dirs ----
675
676 for x in "${NETDATA_LIB_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}"
677 do
678     if [ ! -d "${x}" ]
679         then
680         echo >&2 "Creating directory '${x}'"
681         run mkdir -p "${x}" || exit 1
682     fi
683
684     run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${x}"
685     #run find "${x}" -type f -exec chmod 0660 {} \;
686     #run find "${x}" -type d -exec chmod 0770 {} \;
687 done
688
689 run chmod 755 "${NETDATA_LOG_DIR}"
690
691 # --- plugins ----
692
693 if [ ${UID} -eq 0 ]
694     then
695     run chown "${NETDATA_USER}:root" "${NETDATA_LOG_DIR}"
696     run chown -R root "${NETDATA_PREFIX}/usr/libexec/netdata"
697     run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
698     run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0644 {} \;
699     run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.plugin -exec chmod 0755 {} \;
700     run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.sh -exec chmod 0755 {} \;
701
702     setcap_ret=1
703     if ! iscontainer
704         then
705         if [ ! -z "${setcap}" ]
706             then
707             run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
708             setcap_ret=$?
709         fi
710
711         if [ ${setcap_ret} -eq 0 ]
712             then
713             # if we managed to setcap
714             # but we fail to execute apps.plugin
715             # trigger setuid to root
716             "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" -v >/dev/null 2>&1
717             setcap_ret=$?
718         fi
719     fi
720
721     if [ ${setcap_ret} -ne 0 ]
722         then
723         # fix apps.plugin to be setuid to root
724         run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
725         run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
726     fi
727 else
728     run chown "${NETDATA_USER}:${NETDATA_USER}" "${NETDATA_LOG_DIR}"
729     run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${NETDATA_PREFIX}/usr/libexec/netdata"
730     run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0755 {} \;
731     run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
732 fi
733
734 # --- fix #1292 bug ---
735
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 # -----------------------------------------------------------------------------
742 progress "Install netdata at system init"
743
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
751         source /etc/os-release || return 1
752         key="${ID}-${VERSION_ID}"
753
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
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
783     fi
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 # -----------------------------------------------------------------------------
809 # check if we can re-start netdata
810
811 started=0
812
813 isnetdata() {
814     if [ -d /proc/self ]
815     then
816         [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
817         [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
818         return 1
819     fi
820     return 0
821 }
822
823 stop_netdata_on_pid() {
824     local pid="${1}" ret=0 count=0
825
826     isnetdata ${pid} || return 0
827
828     printf >&2 "Stopping netdata on pid ${pid} ..."
829     while [ ! -z "$pid" -a ${ret} -eq 0 ]
830     do
831         if [ ${count} -gt 45 ]
832             then
833             echo >&2 "Cannot stop the running netdata on pid ${pid}."
834             return 1
835         fi
836
837         count=$(( count + 1 ))
838
839         run kill ${pid} 2>/dev/null
840         ret=$?
841
842         test ${ret} -eq 0 && printf >&2 "." && sleep 2
843     done
844
845     echo >&2
846     if [ ${ret} -eq 0 ]
847     then
848         echo >&2 "SORRY! CANNOT STOP netdata ON PID ${pid} !"
849         return 1
850     fi
851
852     echo >&2 "netdata on pid ${pid} stopped."
853     return 0
854 }
855
856 stop_all_netdata() {
857     local p myns ns
858
859     myns="$(readlink /proc/self/ns/pid 2>/dev/null)"
860
861     echo >&2 "Stopping a (possibly) running netdata..."
862
863     for p in $(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null) \
864         $(cat /var/run/netdata.pid 2>/dev/null) \
865         $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
866         $(pidof netdata 2>/dev/null)
867     do
868         ns="$(readlink /proc/${p}/ns/pid 2>/dev/null)"
869
870         if [ -z "${myns}" -o -z "${ns}" -o "${myns}" = "${ns}" ]
871             then
872             stop_netdata_on_pid ${p}
873         fi
874     done
875 }
876
877 if [ ${DONOTSTART} -eq 1 ]
878     then
879     if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
880         then
881         echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
882
883         if [ "${UID}" -eq 0 ]
884             then
885             chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
886         fi
887         chmod 0644 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
888     fi
889
890 else
891
892     progress "Start netdata"
893
894     if [ "${UID}" -eq 0 ]
895         then
896         service netdata stop
897         stop_all_netdata
898         service netdata restart && started=1
899         if [ ${started} -eq 0 ]
900         then
901             service netdata start && started=1
902         fi
903     fi
904
905     if [ ${started} -eq 0 ]
906     then
907         # still not started...
908
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
922         echo >&2
923     fi
924
925     # -----------------------------------------------------------------------------
926     # save a config file, if it is not already there
927
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
936         # remove a possibly obsolete download
937         [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
938
939         # disable a proxy to get data from the local netdata
940         export http_proxy=
941         export https_proxy=
942
943         # try wget
944         wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
945         ret=$?
946
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
954         if [ ${ret} -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
955             then
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
968     fi
969 fi
970
971 # -----------------------------------------------------------------------------
972 progress "Check KSM (kernel memory deduper)"
973
974 ksm_is_available_but_disabled() {
975     cat <<KSM1
976
977 Memory de-duplication instructions
978
979 You have kernel memory de-duper (called Kernel Same-page Merging,
980 or KSM) available, but it is not currently enabled.
981
982 To enable it run:
983
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
989 KSM1
990 }
991
992 ksm_is_not_available() {
993     cat <<KSM2
994
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
998 Merging, or KSM) available.
999
1000 To enable it, you need a kernel built with CONFIG_KSM=y
1001
1002 If you can have it, you will save 40-60% of netdata memory.
1003
1004 KSM2
1005 }
1006
1007 if [ -f "/sys/kernel/mm/ksm/run" ]
1008     then
1009     if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
1010         then
1011         ksm_is_available_but_disabled
1012     fi
1013 else
1014     ksm_is_not_available
1015 fi
1016
1017 # -----------------------------------------------------------------------------
1018 progress "Check version.txt"
1019
1020 if [ ! -s web/version.txt ]
1021     then
1022     cat <<VERMSG
1023
1024 Version update check warning
1025
1026 The way you downloaded netdata, we cannot find its version. This means the
1027 Update check on the dashboard, will not work.
1028
1029 If you want to have version update check, please re-install it
1030 following the procedure in:
1031
1032 https://github.com/firehol/netdata/wiki/Installation
1033
1034 VERMSG
1035 fi
1036
1037 # -----------------------------------------------------------------------------
1038 progress "Check apps.plugin"
1039
1040 if [ "${UID}" -ne 0 ]
1041     then
1042     cat <<SETUID_WARNING
1043
1044 apps.plugin needs privileges
1045
1046 Since you have installed netdata as a normal user, to have apps.plugin collect
1047 all the needed data, you have to give it the access rights it needs, by running
1048 either of the following sets of commands:
1049
1050 To run apps.plugin with escalated capabilities:
1051
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
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
1063 any task, so it is pretty safe to do this.
1064
1065 SETUID_WARNING
1066 fi
1067
1068 # -----------------------------------------------------------------------------
1069 progress "Generate netdata-uninstaller.sh"
1070
1071 cat >netdata-uninstaller.sh <<UNINSTALL
1072 #!/usr/bin/env bash
1073
1074 # this script will uninstall netdata
1075
1076 if [ "\$1" != "--force" ]
1077     then
1078     echo >&2 "This script will REMOVE netdata from your system."
1079     echo >&2 "Run it again with --force to do it."
1080     exit 1
1081 fi
1082
1083 echo >&2 "Stopping a possibly running netdata..."
1084 for p in \$(pidof netdata); do kill \$p; done
1085 sleep 2
1086
1087 deletedir() {
1088     if [ ! -z "\$1" -a -d "\$1" ]
1089         then
1090         echo
1091         echo "Deleting directory '\$1' ..."
1092         rm -I -R "\$1"
1093     fi
1094 }
1095
1096 if [ ! -z "${NETDATA_PREFIX}" -a -d "${NETDATA_PREFIX}" ]
1097     then
1098     # installation prefix was given
1099
1100     deletedir "${NETDATA_PREFIX}"
1101
1102 else
1103     # installation prefix was NOT given
1104
1105     if [ -f "${NETDATA_PREFIX}/usr/sbin/netdata" ]
1106         then
1107         echo "Deleting ${NETDATA_PREFIX}/usr/sbin/netdata ..."
1108         rm -i "${NETDATA_PREFIX}/usr/sbin/netdata"
1109     fi
1110
1111     deletedir "${NETDATA_PREFIX}/etc/netdata"
1112     deletedir "${NETDATA_PREFIX}/usr/share/netdata"
1113     deletedir "${NETDATA_PREFIX}/usr/libexec/netdata"
1114     deletedir "${NETDATA_PREFIX}/var/lib/netdata"
1115     deletedir "${NETDATA_PREFIX}/var/cache/netdata"
1116     deletedir "${NETDATA_PREFIX}/var/log/netdata"
1117 fi
1118
1119 if [ -f /etc/logrotate.d/netdata ]
1120     then
1121     echo "Deleting /etc/logrotate.d/netdata ..."
1122     rm -i /etc/logrotate.d/netdata
1123 fi
1124
1125 if [ -f /etc/systemd/system/netdata.service ]
1126     then
1127     echo "Deleting /etc/systemd/system/netdata.service ..."
1128     rm -i /etc/systemd/system/netdata.service
1129 fi
1130
1131 if [ -f /etc/init.d/netdata ]
1132     then
1133     echo "Deleting /etc/init.d/netdata ..."
1134     rm -i /etc/init.d/netdata
1135 fi
1136
1137 getent passwd netdata > /dev/null
1138 if [ $? -eq 0 ]
1139     then
1140     echo
1141     echo "You may also want to remove the user netdata"
1142     echo "by running:"
1143     echo "   userdel netdata"
1144 fi
1145
1146 getent group netdata > /dev/null
1147 if [ $? -eq 0 ]
1148     then
1149     echo
1150     echo "You may also want to remove the group netdata"
1151     echo "by running:"
1152     echo "   groupdel netdata"
1153 fi
1154
1155 getent group docker > /dev/null
1156 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_DOCKER}" = "1" ]
1157     then
1158     echo
1159     echo "You may also want to remove the netdata user from the docker group"
1160     echo "by running:"
1161     echo "   gpasswd -d netdata docker"
1162 fi
1163
1164 getent group nginx > /dev/null
1165 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_NGINX}" = "1" ]
1166     then
1167     echo
1168     echo "You may also want to remove the netdata user from the nginx group"
1169     echo "by running:"
1170     echo "   gpasswd -d netdata nginx"
1171 fi
1172
1173 getent group varnish > /dev/null
1174 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_VARNISH}" = "1" ]
1175     then
1176     echo
1177     echo "You may also want to remove the netdata user from the varnish group"
1178     echo "by running:"
1179     echo "   gpasswd -d netdata varnish"
1180 fi
1181
1182 getent group haproxy > /dev/null
1183 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_HAPROXY}" = "1" ]
1184     then
1185     echo
1186     echo "You may also want to remove the netdata user from the haproxy group"
1187     echo "by running:"
1188     echo "   gpasswd -d netdata haproxy"
1189 fi
1190
1191 getent group adm > /dev/null
1192 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_ADM}" = "1" ]
1193     then
1194     echo
1195     echo "You may also want to remove the netdata user from the adm group"
1196     echo "by running:"
1197     echo "   gpasswd -d netdata adm"
1198 fi
1199
1200
1201 UNINSTALL
1202 chmod 750 netdata-uninstaller.sh
1203
1204 # -----------------------------------------------------------------------------
1205 progress "Basic netdata instructions"
1206
1207 cat <<END
1208
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
1216   $(printf "${COLOR_YELLOW}${COLOR_BOLD}killall netdata${COLOR_RESET}")
1217
1218 To start it, just run it:
1219
1220   $(printf "${COLOR_YELLOW}${COLOR_BOLD}${NETDATA_PREFIX}/usr/sbin/netdata${COLOR_RESET}")
1221
1222
1223 END
1224 echo >&2 -e "Uninstall script generated: ${COLOR_YELLOW}${COLOR_BOLD}./netdata-uninstaller.sh${COLOR_RESET}"
1225
1226 if [ -d .git ]
1227     then
1228     cat >netdata-updater.sh.new <<REINSTALL
1229 #!/usr/bin/env bash
1230
1231 force=0
1232 [ "\${1}" = "-f" ] && force=1
1233
1234 export PATH="\${PATH}:${PATH}"
1235 export CFLAGS="${CFLAGS}"
1236
1237 INSTALL_UID="${UID}"
1238 if [ "\${INSTALL_UID}" != "\${UID}" ]
1239     then
1240     echo >&2 "This script should be run as user with uid \${INSTALL_UID} but it now runs with uid \${UID}"
1241     exit 1
1242 fi
1243
1244 # make sure we cd to the working directory
1245 cd "${REINSTALL_PWD}" || exit 1
1246
1247 # make sure there is .git here
1248 [ \${force} -eq 0 -a ! -d .git ] && echo >&2 "No git structures found at: ${REINSTALL_PWD} (use -f for force re-install)" && exit 1
1249
1250 # signal netdata to start saving its database
1251 # this is handy if your database is big
1252 pids=\$(pidof netdata)
1253 [ ! -z "\${pids}" ] && kill -USR1 \${pids}
1254
1255 tmp=
1256 if [ -t 2 ]
1257     then
1258     # we are running on a terminal
1259     # open fd 3 and send it to stderr
1260     exec 3>&2
1261 else
1262     # we are headless
1263     # create a temporary file for the log
1264     tmp=\$(mktemp /tmp/netdata-updater-log-XXXXXX.log)
1265     # open fd 3 and send it to tmp
1266     exec 3>\${tmp}
1267 fi
1268
1269 info() {
1270     echo >&3 "\$(date) : INFO: " "\${@}"
1271 }
1272
1273 emptyline() {
1274     echo >&3
1275 }
1276
1277 error() {
1278     echo >&3 "\$(date) : ERROR: " "\${@}"
1279 }
1280
1281 # this is what we will do if it fails (head-less only)
1282 failed() {
1283     error "FAILED TO UPDATE NETDATA : \${1}"
1284
1285     if [ ! -z "\${tmp}" ]
1286     then
1287         cat >&2 "\${tmp}"
1288         rm "\${tmp}"
1289     fi
1290     exit 1
1291 }
1292
1293 get_latest_commit_id() {
1294     git log -1           2>&3 |\\
1295         grep ^commit     2>&3 |\\
1296         head -n 1        2>&3 |\\
1297         cut -d ' ' -f 2  2>&3
1298 }
1299
1300 update() {
1301     [ -z "\${tmp}" ] && info "Running on a terminal - (this script also supports running headless from crontab)"
1302
1303     emptyline
1304
1305     if [ -d .git ]
1306         then
1307         info "Updating netdata source from github..."
1308
1309         last_commit="\$(get_latest_commit_id)"
1310         [ \${force} -eq 0 -a -z "\${last_commit}" ] && failed "CANNOT GET LAST COMMIT ID (use -f for force re-install)"
1311
1312         git pull >&3 2>&3 || failed "CANNOT FETCH LATEST SOURCE (use -f for force re-install)"
1313
1314         new_commit="\$(get_latest_commit_id)"
1315         if [ \${force} -eq 0 ]
1316             then
1317             [ -z "\${new_commit}" ] && failed "CANNOT GET NEW LAST COMMIT ID (use -f for force re-install)"
1318             [ "\${new_commit}" = "\${last_commit}" ] && info "Nothing to be done! (use -f to force re-install)" && exit 0
1319         fi
1320     elif [ \${force} -eq 0 ]
1321         then
1322         failed "CANNOT FIND GIT STRUCTURES IN \$(pwd) (use -f for force re-install)"
1323     fi
1324
1325     emptyline
1326     info "Re-installing netdata..."
1327     ${REINSTALL_COMMAND// --dont-wait/} --dont-wait >&3 2>&3 || failed "FAILED TO COMPILE/INSTALL NETDATA"
1328
1329     [ ! -z "\${tmp}" ] && rm "\${tmp}" && tmp=
1330     return 0
1331 }
1332
1333 # the installer updates this script - so we run and exit in a single line
1334 update && exit 0
1335 ###############################################################################
1336 ###############################################################################
1337 REINSTALL
1338     chmod 755 netdata-updater.sh.new
1339     mv -f netdata-updater.sh.new 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
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