]> arthur.barton.de Git - netdata.git/blob - netdata-installer.sh
Merge remote-tracking branch 'upstream/master' into registry
[netdata.git] / netdata-installer.sh
1 #!/bin/bash
2
3 # reload the user profile
4 [ -f /etc/profile ] && . /etc/profile
5
6 # fix PKG_CHECK_MODULES error
7 if [ -d /usr/share/aclocal ]
8 then
9         ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
10         export ACLOCAL_PATH
11 fi
12
13 LC_ALL=C
14 umask 022
15
16 # you can set CFLAGS before running installer
17 CFLAGS="${CFLAGS--O3}"
18
19 # keep a log of this command
20 printf "\n# " >>netdata-installer.log
21 date >>netdata-installer.log
22 printf "CFLAGS=\"%s\" " "${CFLAGS}" >>netdata-installer.log
23 printf "%q " "$0" "${@}" >>netdata-installer.log
24 printf "\n" >>netdata-installer.log
25
26 ME="$0"
27 DONOTSTART=0
28 DONOTWAIT=0
29 NETDATA_PREFIX=
30 ZLIB_IS_HERE=0
31
32 usage() {
33         cat <<USAGE
34
35 ${ME} <installer options>
36
37 Valid <installer options> are:
38
39    --install /PATH/TO/INSTALL
40
41         If your give: --install /opt
42         netdata will be installed in /opt/netdata
43
44    --dont-start-it
45
46         Do not (re)start netdata.
47         Just install it.
48
49    --dont-wait
50
51         Do not wait for the user to press ENTER.
52         Start immediately building it.
53
54    --zlib-is-really-here
55
56         If you get errors about missing zlib,
57         but you know it is available,
58         you have a broken pkg-config.
59         Use this option to allow it continue
60         without checking pkg-config.
61
62 Netdata will by default be compiled with gcc optimization -O3
63 If you need to pass different CFLAGS, use something like this:
64
65   CFLAGS="<gcc options>" $ME <installer options>
66
67 For the installer to complete successfully, you will need
68 these packages installed:
69
70    gcc make autoconf automake pkg-config zlib1g-dev uuid-dev
71
72 For the plugins, you will at least need:
73
74    curl node
75
76 USAGE
77 }
78
79 while [ ! -z "${1}" ]
80 do
81         if [ "$1" = "--install" ]
82                 then
83                 NETDATA_PREFIX="${2}/netdata"
84                 shift 2
85         elif [ "$1" = "--zlib-is-really-here" ]
86                 then
87                 ZLIB_IS_HERE=1
88                 shift 1
89         elif [ "$1" = "--dont-start-it" ]
90                 then
91                 DONOTSTART=1
92                 shift 1
93         elif [ "$1" = "--dont-wait" ]
94                 then
95                 DONOTWAIT=1
96                 shift 1
97         elif [ "$1" = "--help" -o "$1" = "-h" ]
98                 then
99                 usage
100                 exit 1
101         else
102                 echo >&2
103                 echo >&2 "ERROR:"
104                 echo >&2 "I cannot understand option '$1'."
105                 usage
106                 exit 1
107         fi
108 done
109
110 cat <<BANNER
111
112 Welcome to netdata!
113 Nice to see you are giving it a try!
114
115 You are about to build and install netdata to your system.
116
117 It will be installed at these locations:
118
119   - the daemon    at ${NETDATA_PREFIX}/usr/sbin/netdata
120   - config files  at ${NETDATA_PREFIX}/etc/netdata
121   - web files     at ${NETDATA_PREFIX}/usr/share/netdata
122   - plugins       at ${NETDATA_PREFIX}/usr/libexec/netdata
123   - cache files   at ${NETDATA_PREFIX}/var/cache/netdata
124   - db files      at ${NETDATA_PREFIX}/var/lib/netdata
125   - log files     at ${NETDATA_PREFIX}/var/log/netdata
126   - pid file      at ${NETDATA_PREFIX}/var/run
127
128 This installer allows you to change the installation path.
129 Press Control-C and run the same command with --help for help.
130
131 BANNER
132
133 if [ "${UID}" -ne 0 ]
134         then
135         if [ -z "${NETDATA_PREFIX}" ]
136                 then
137                 cat <<NONROOTNOPREFIX
138
139 Sorry! This will fail!
140
141 You are attempting to install netdata as non-root, but you plan to install it
142 in system paths.
143
144 Please set an installation prefix, like this:
145
146     $0 ${@} --install /tmp
147
148 or, run the installer as root:
149
150     sudo $0 ${@}
151
152 We suggest to install it as root, or certain data collectors will not be able
153 to work. Netdata drops root privileges when running. So, if you plan to keep
154 it, install it as root to get the full functionality.
155
156 NONROOTNOPREFIX
157                 exit 1
158
159         else
160                 cat <<NONROOT
161
162 IMPORTANT:
163 You are about to install netdata as a non-root user.
164 Netdata will work, but a few data collection modules that
165 require root access will fail.
166
167 If you installing permanently on your system, run the
168 installer like this:
169
170     sudo $0 ${@}
171
172 NONROOT
173         fi
174 fi
175
176 have_autotools=
177 if [ "$(type autoreconf 2> /dev/null)" ]
178 then
179         autoconf_maj_min() {
180                 local maj min IFS=.-
181
182                 maj=$1
183                 min=$2
184
185                 set -- $(autoreconf -V | sed -ne '1s/.* \([^ ]*\)$/\1/p')
186                 eval $maj=\$1 $min=\$2
187         }
188         autoconf_maj_min AMAJ AMIN
189
190         if [ "$AMAJ" -gt 2 ]
191         then
192                 have_autotools=Y
193         elif [ "$AMAJ" -eq 2 -a "$AMIN" -ge 60 ]
194         then
195                 have_autotools=Y
196         else
197                 echo "Found autotools $AMAJ.$AMIN"
198         fi
199 else
200         echo "No autotools found"
201 fi
202
203 if [ ! "$have_autotools" ]
204 then
205         if [ -f configure ]
206         then
207                 echo "Will skip autoreconf step"
208         else
209                 cat <<-"EOF"
210
211         -------------------------------------------------------------------------------
212         autotools 2.60 or later is required
213
214         Sorry, you do not seem to have autotools 2.60 or later, which is
215         required to build from the git sources of netdata.
216
217         You can either install a suitable version of autotools and automake
218         or download a netdata package which does not have these dependencies.
219
220         Source packages where autotools have already been run are available
221         here:
222                https://firehol.org/download/netdata/
223
224         The unsigned/master folder tracks the head of the git tree and released
225         packages are also available.
226         EOF
227                 exit 1
228         fi
229 fi
230
231 if [ ${DONOTWAIT} -eq 0 ]
232         then
233         if [ ! -z "${NETDATA_PREFIX}" ]
234                 then
235                 read -p "Press ENTER to build and install netdata to '${NETDATA_PREFIX}' > "
236         else
237                 read -p "Press ENTER to build and install netdata to your system > "
238         fi
239 fi
240
241 build_error() {
242         cat <<EOF
243
244 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
245
246 Sorry! NetData failed to build...
247
248 You many need to check these:
249
250 1. The package zlib1g-dev has to be installed.
251
252    If your system cannot find ZLIB, although it is installed
253    run me with the option:  --zlib-is-really-here
254
255 2. The package uuid-dev has to be installed.
256
257 3. You need basic build tools installed, like:
258
259    gcc make autoconf automake pkg-config
260
261    Autoconf version 2.60 or higher is required.
262
263 If you still cannot get it to build, ask for help at github:
264
265    https://github.com/firehol/netdata/issues
266
267
268 EOF
269         trap - EXIT
270         exit 1
271 }
272
273 run() {
274         printf >&2 "\n"
275         printf >&2 ":-----------------------------------------------------------------------------\n"
276         printf >&2 "Running command:\n"
277         printf >&2 "\n"
278         printf >&2 "%q " "${@}"
279         printf >&2 "\n"
280         printf >&2 "\n"
281
282         "${@}"
283 }
284
285 if [ ${ZLIB_IS_HERE} -eq 1 ]
286         then
287         shift
288         echo >&2 "ok, assuming zlib is really installed."
289         export ZLIB_CFLAGS=" "
290         export ZLIB_LIBS="-lz"
291 fi
292
293 trap build_error EXIT
294
295 if [ "$have_autotools" ]
296 then
297         run ./autogen.sh || exit 1
298 fi
299
300 run ./configure \
301         --prefix="${NETDATA_PREFIX}/usr" \
302         --sysconfdir="${NETDATA_PREFIX}/etc" \
303         --localstatedir="${NETDATA_PREFIX}/var" \
304         --with-zlib --with-math --with-user=netdata \
305         CFLAGS="${CFLAGS}" || exit 1
306
307 # remove the build_error hook
308 trap - EXIT
309
310 if [ -f src/netdata ]
311         then
312         echo >&2 "Cleaning a possibly old compilation ..."
313         run make clean
314 fi
315
316 echo >&2 "Compiling netdata ..."
317 run make || exit 1
318
319 # backup user configurations
320 for x in apps_groups.conf charts.d.conf
321 do
322         if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}" ]
323                 then
324                 cp -p "${NETDATA_PREFIX}/etc/netdata/${x}" "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup"
325         fi
326 done
327
328 echo >&2 "Installing netdata ..."
329 run make install || exit 1
330
331 # restore user configurations
332 for x in apps_groups.conf charts.d.conf
333 do
334         if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup" ]
335                 then
336                 cp -p "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup" "${NETDATA_PREFIX}/etc/netdata/${x}"
337         fi
338 done
339
340 NETDATA_ADDED_TO_DOCKER=0
341 if [ ${UID} -eq 0 ]
342         then
343         getent group netdata > /dev/null
344         if [ $? -ne 0 ]
345                 then
346                 echo >&2 "Adding netdata user group ..."
347                 run groupadd -r netdata
348         fi
349
350         getent passwd netdata > /dev/null
351         if [ $? -ne 0 ]
352                 then
353                 echo >&2 "Adding netdata user account ..."
354                 run useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
355         fi
356
357         getent group docker > /dev/null
358         if [ $? -eq 0 ]
359                 then
360                 # find the users in the docker group
361                 docker=$(getent group docker | cut -d ':' -f 4)
362                 if [[ ",${docker}," =~ ,netdata, ]]
363                         then
364                         # netdata is already there
365                         :
366                 else
367                         # netdata is not in docker group
368                         echo >&2 "Adding netdata user to the docker group (needed to get container names) ..."
369                         run usermod -a -G docker netdata
370                 fi
371                 # let the uninstall script know
372                 NETDATA_ADDED_TO_DOCKER=1
373         fi
374 fi
375
376
377 # -----------------------------------------------------------------------------
378 # load options from the configuration file
379
380 # create an empty config if it does not exist
381 [ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
382
383 # function to extract values from the config file
384 config_option() {
385         local key="${1}" value="${2}" line=
386
387         if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
388                 then
389                 line="$( grep "^[[:space:]]*${key}[[:space:]]*=[[:space:]]*" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" | head -n 1 )"
390                 [ ! -z "${line}" ] && value="$( echo "${line}" | cut -d '=' -f 2 | sed -e "s/^[[:space:]]\+//g" -e "s/[[:space:]]\+$//g" )"
391         fi
392
393         echo "${value}"
394 }
395
396 # user
397 defuser="netdata"
398 [ ! "${UID}" = "0" ] && defuser="${USER}"
399 NETDATA_USER="$( config_option "run as user" "${defuser}" )"
400
401 NETDATA_WEB_USER="$( config_option "web files owner" "${defuser}" )"
402 NETDATA_WEB_GROUP="$( config_option "web files group" "${NETDATA_WEB_USER}" )"
403
404 # debug flags
405 defdebug=0
406 NETDATA_DEBUG="$( config_option "debug flags" ${defdebug} )"
407
408 # port
409 defport=19999
410 NETDATA_PORT="$( config_option "port" ${defport} )"
411
412 # directories
413 NETDATA_LIB_DIR="$( config_option "lib directory" "${NETDATA_PREFIX}/var/lib/netdata" )"
414 NETDATA_CACHE_DIR="$( config_option "cache directory" "${NETDATA_PREFIX}/var/cache/netdata" )"
415 NETDATA_WEB_DIR="$( config_option "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )"
416 NETDATA_LOG_DIR="$( config_option "log directory" "${NETDATA_PREFIX}/var/log/netdata" )"
417 NETDATA_CONF_DIR="$( config_option "config directory" "${NETDATA_PREFIX}/etc/netdata" )"
418 NETDATA_BIND="$( config_option "bind socket to IP" "*" )"
419 NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
420
421
422 # -----------------------------------------------------------------------------
423 # prepare the directories
424
425 # this is needed if NETDATA_PREFIX is not empty
426 if [ ! -d "${NETDATA_RUN_DIR}" ]
427         then
428         mkdir -p "${NETDATA_RUN_DIR}" || exit 1
429 fi
430
431 echo >&2 "Fixing directories (user: ${NETDATA_USER})..."
432 for x in "${NETDATA_WEB_DIR}" "${NETDATA_CONF_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}" "${NETDATA_LIB_DIR}"
433 do
434         if [ ! -d "${x}" ]
435                 then
436                 echo >&2 "Creating directory '${x}'"
437                 run mkdir -p "${x}" || exit 1
438         fi
439
440         if [ ${UID} -eq 0 ]
441                 then
442                 if [ "${x}" = "${NETDATA_WEB_DIR}" ]
443                         then
444                         run chown -R "${NETDATA_WEB_USER}:${NETDATA_WEB_GROUP}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_WEB_USER}:${NETDATA_WEB_GROUP}..."
445                 else
446                         run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_USER}..."
447                 fi
448         fi
449
450         run chmod 0755 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
451 done
452
453 if [ ${UID} -eq 0 ]
454         then
455         # fix apps.plugin to be setuid to root
456         run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
457         run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
458 fi
459
460 # -----------------------------------------------------------------------------
461 # check if we can re-start netdata
462
463 if [ ${DONOTSTART} -eq 1 ]
464         then
465         if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
466                 then
467                 echo >&2 "Generating empty config file in: ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
468                 echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
469
470                 if [ "${UID}" -eq 0 ]
471                         then
472                         chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
473                 fi
474                 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
475         fi
476         echo >&2 "OK. It is now installed and ready."
477         exit 0
478 fi
479
480 # -----------------------------------------------------------------------------
481 # stop a running netdata
482
483 isnetdata() {
484         [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
485         [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
486         return 1
487 }
488
489
490 printf >&2 "Stopping a (possibly) running netdata..."
491 ret=0
492 count=0
493 while [ $ret -eq 0 ]
494 do
495         if [ $count -gt 30 ]
496                 then
497                 echo >&2 "Cannot stop the running netdata."
498                 exit 1
499         fi
500
501         count=$((count + 1))
502
503         pid=$(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null)
504         # backwards compatibility
505         [ -z "${pid}" ] && pid=$(cat /var/run/netdata.pid 2>/dev/null)
506         [ -z "${pid}" ] && pid=$(cat /var/run/netdata/netdata.pid 2>/dev/null)
507         
508         isnetdata $pid || pid=
509         if [ ! -z "${pid}" ]
510                 then
511                 run kill $pid 2>/dev/null
512                 ret=$?
513         else
514                 run killall netdata 2>/dev/null
515                 ret=$?
516         fi
517
518         test $ret -eq 0 && printf >&2 "." && sleep 2
519 done
520 echo >&2
521 echo >&2
522
523
524 # -----------------------------------------------------------------------------
525 # run netdata
526
527 echo >&2 "Starting netdata..."
528 run ${NETDATA_PREFIX}/usr/sbin/netdata -pidfile ${NETDATA_RUN_DIR}/netdata.pid "${@}"
529
530 if [ $? -ne 0 ]
531         then
532         echo >&2
533         echo >&2 "SORRY! FAILED TO START NETDATA!"
534         exit 1
535 else
536         echo >&2 "OK. NetData Started!"
537 fi
538
539
540 # -----------------------------------------------------------------------------
541 # save a config file, if it is not already there
542
543 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
544         then
545         echo >&2 "Downloading default configuration from netdata..."
546         sleep 5
547
548         # remove a possibly obsolete download
549         [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
550
551         # disable a proxy to get data from the local netdata
552         export http_proxy=
553         export https_proxy=
554
555         # try wget
556         wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
557         ret=$?
558
559         # try curl
560         if [ $ret -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
561                 then
562                 curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
563                 ret=$?
564         fi
565
566         if [ $ret -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
567                 then
568                 mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
569                 echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
570
571                 if [ "${UID}" -eq 0 ]
572                         then
573                         chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
574                 fi
575                 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
576         else
577                 echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
578                 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
579         fi
580 fi
581
582 # -----------------------------------------------------------------------------
583 # Check for KSM
584
585 ksm_is_available_but_disabled() {
586         cat <<KSM1
587
588 -------------------------------------------------------------------------------
589 Memory de-duplication instructions
590
591 I see you have kernel memory de-duper (called Kernel Same-page Merging,
592 or KSM) available, but it is not currently enabled.
593
594 To enable it run:
595
596 echo 1 >/sys/kernel/mm/ksm/run
597 echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
598
599 If you enable it, you will save 40-60% of netdata memory.
600
601 KSM1
602 }
603
604 ksm_is_not_available() {
605         cat <<KSM2
606
607 -------------------------------------------------------------------------------
608 Memory de-duplication not present in your kernel
609
610 It seems you do not have kernel memory de-duper (called Kernel Same-page
611 Merging, or KSM) available.
612
613 To enable it, you need a kernel built with CONFIG_KSM=y
614
615 If you can have it, you will save 40-60% of netdata memory.
616
617 KSM2
618 }
619
620 if [ -f "/sys/kernel/mm/ksm/run" ]
621         then
622         if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
623                 then
624                 ksm_is_available_but_disabled
625         fi
626 else
627         ksm_is_not_available
628 fi
629
630 # -----------------------------------------------------------------------------
631 # Check for version.txt
632
633 if [ ! -s web/version.txt ]
634         then
635 cat <<VERMSG
636
637 -------------------------------------------------------------------------------
638 Version update check warning
639
640 The way you downloaded netdata, we cannot find its version. This means the
641 Update check on the dashboard, will not work.
642
643 If you want to have version update check, please re-install it
644 following the procedure in:
645
646 https://github.com/firehol/netdata/wiki/Installation
647
648 VERMSG
649 fi
650
651 # -----------------------------------------------------------------------------
652 # apps.plugin warning
653
654 if [ "${UID}" -ne 0 ]
655         then
656 cat <<SETUID_WARNING
657
658 -------------------------------------------------------------------------------
659 apps.plugin needs privileges
660
661 Since you have installed netdata as a normal user, to have apps.plugin collect
662 all the needed data, you have to give it the access rights it needs, by running
663 these commands:
664
665         sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
666         sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
667
668 The commands allow apps.plugin to run as root.
669
670 apps.plugin is performing a hard-coded function of data collection for all
671 running processes. It cannot be instructed from the netdata daemon to perform
672 any task, so it is pretty safe to do this.
673
674 SETUID_WARNING
675 fi
676
677 # -----------------------------------------------------------------------------
678 # Keep un-install info
679
680 cat >netdata-uninstaller.sh <<UNINSTALL
681 #!/bin/bash
682
683 # this script will uninstall netdata
684
685 if [ "\$1" != "--force" ]
686         then
687         echo >&2 "This script will REMOVE netdata from your system."
688         echo >&2 "Run it again with --force to do it."
689         exit 1
690 fi
691
692 echo >&2 "Stopping a possibly running netdata..."
693 killall netdata
694 sleep 2
695
696 deletedir() {
697         if [ ! -z "\$1" -a -d "\$1" ]
698                 then
699                 echo
700                 echo "Deleting directory '\$1' ..."
701                 rm -I -R "\$1"
702         fi
703 }
704
705 if [ ! -z "${NETDATA_PREFIX}" -a -d "${NETDATA_PREFIX}" ]
706         then
707         # installation prefix was given
708
709         deletedir "${NETDATA_PREFIX}"
710
711 else
712         # installation prefix was NOT given
713
714         if [ -f "${NETDATA_PREFIX}/usr/sbin/netdata" ]
715                 then
716                 echo "Deleting ${NETDATA_PREFIX}/usr/sbin/netdata ..."
717                 rm -i "${NETDATA_PREFIX}/usr/sbin/netdata"
718         fi
719
720         deletedir "${NETDATA_PREFIX}/etc/netdata"
721         deletedir "${NETDATA_PREFIX}/usr/share/netdata"
722         deletedir "${NETDATA_PREFIX}/usr/libexec/netdata"
723         deletedir "${NETDATA_PREFIX}/var/lib/netdata"
724         deletedir "${NETDATA_PREFIX}/var/cache/netdata"
725         deletedir "${NETDATA_PREFIX}/var/log/netdata"
726 fi
727
728 getent passwd netdata > /dev/null
729 if [ $? -eq 0 ]
730         then
731         echo
732         echo "You may also want to remove the user netdata"
733         echo "by running:"
734         echo "   userdel netdata"
735 fi
736
737 getent group netdata > /dev/null
738 if [ $? -eq 0 ]
739         then
740         echo
741         echo "You may also want to remove the group netdata"
742         echo "by running:"
743         echo "   groupdel netdata"
744 fi
745
746 getent group docker > /dev/null
747 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_DOCKER}" = "1" ]
748         then
749         echo
750         echo "You may also want to remove the netdata user from the docker group"
751         echo "by running:"
752         echo "   gpasswd -d netdata docker"
753 fi
754
755 UNINSTALL
756 chmod 750 netdata-uninstaller.sh
757
758 # -----------------------------------------------------------------------------
759
760 if [ "${NETDATA_BIND}" = "*" ]
761         then
762         access="localhost"
763 else
764         access="${NETDATA_BIND}"
765 fi
766
767 cat <<END
768
769
770 -------------------------------------------------------------------------------
771
772 OK. NetData is installed and it is running (listening to ${NETDATA_BIND}:${NETDATA_PORT}).
773
774 -------------------------------------------------------------------------------
775
776
777 Hit http://${access}:${NETDATA_PORT}/ from your browser.
778
779 To stop netdata, just kill it, with:
780
781   killall netdata
782
783 To start it, just run it:
784
785   ${NETDATA_PREFIX}/usr/sbin/netdata
786
787
788 Enjoy!
789
790                  Give netdata a Github Star, at:
791
792              https://github.com/firehol/netdata/wiki
793
794
795 END
796 echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"