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