]> arthur.barton.de Git - netdata.git/blob - netdata-installer.sh
registry: working prototype with load/save
[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
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 2. You need basic build tools installed, like:
252
253    gcc make autoconf automake pkg-config
254
255    Autoconf version 2.60 or higher is required
256
257 3. If your system cannot find ZLIB, although it is installed
258    run me with the option:  --zlib-is-really-here
259
260
261 If you still cannot get it to build, ask for help at github:
262
263    https://github.com/firehol/netdata/issues
264
265
266 EOF
267         trap - EXIT
268         exit 1
269 }
270
271 run() {
272         printf >&2 "\n"
273         printf >&2 ":-----------------------------------------------------------------------------\n"
274         printf >&2 "Running command:\n"
275         printf >&2 "\n"
276         printf >&2 "%q " "${@}"
277         printf >&2 "\n"
278         printf >&2 "\n"
279
280         "${@}"
281 }
282
283 if [ ${ZLIB_IS_HERE} -eq 1 ]
284         then
285         shift
286         echo >&2 "ok, assuming zlib is really installed."
287         export ZLIB_CFLAGS=" "
288         export ZLIB_LIBS="-lz"
289 fi
290
291 trap build_error EXIT
292
293 if [ "$have_autotools" ]
294 then
295         run ./autogen.sh || exit 1
296 fi
297
298 run ./configure \
299         --prefix="${NETDATA_PREFIX}/usr" \
300         --sysconfdir="${NETDATA_PREFIX}/etc" \
301         --localstatedir="${NETDATA_PREFIX}/var" \
302         --with-zlib --with-math --with-user=netdata \
303         CFLAGS="${CFLAGS}" || exit 1
304
305 # remove the build_error hook
306 trap - EXIT
307
308 if [ -f src/netdata ]
309         then
310         echo >&2 "Cleaning a possibly old compilation ..."
311         run make clean
312 fi
313
314 echo >&2 "Compiling netdata ..."
315 run make || exit 1
316
317 # backup user configurations
318 for x in apps_groups.conf charts.d.conf
319 do
320         if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}" ]
321                 then
322                 cp -p "${NETDATA_PREFIX}/etc/netdata/${x}" "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup"
323         fi
324 done
325
326 echo >&2 "Installing netdata ..."
327 run make install || exit 1
328
329 # restore user configurations
330 for x in apps_groups.conf charts.d.conf
331 do
332         if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup" ]
333                 then
334                 cp -p "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup" "${NETDATA_PREFIX}/etc/netdata/${x}"
335         fi
336 done
337
338 NETDATA_ADDED_TO_DOCKER=0
339 if [ ${UID} -eq 0 ]
340         then
341         getent group netdata > /dev/null
342         if [ $? -ne 0 ]
343                 then
344                 echo >&2 "Adding netdata user group ..."
345                 run groupadd -r netdata
346         fi
347
348         getent passwd netdata > /dev/null
349         if [ $? -ne 0 ]
350                 then
351                 echo >&2 "Adding netdata user account ..."
352                 run useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
353         fi
354
355         getent group docker > /dev/null
356         if [ $? -eq 0 ]
357                 then
358                 # find the users in the docker group
359                 docker=$(getent group docker | cut -d ':' -f 4)
360                 if [[ ",${docker}," =~ ,netdata, ]]
361                         then
362                         # netdata is already there
363                         :
364                 else
365                         # netdata is not in docker group
366                         echo >&2 "Adding netdata user to the docker group (needed to get container names) ..."
367                         run usermod -a -G docker netdata
368                 fi
369                 # let the uninstall script know
370                 NETDATA_ADDED_TO_DOCKER=1
371         fi
372 fi
373
374
375 # -----------------------------------------------------------------------------
376 # load options from the configuration file
377
378 # create an empty config if it does not exist
379 [ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
380
381 # function to extract values from the config file
382 config_option() {
383         local key="${1}" value="${2}" line=
384
385         if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
386                 then
387                 line="$( grep "^[[:space:]]*${key}[[:space:]]*=[[:space:]]*" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" | head -n 1 )"
388                 [ ! -z "${line}" ] && value="$( echo "${line}" | cut -d '=' -f 2 | sed -e "s/^[[:space:]]\+//g" -e "s/[[:space:]]\+$//g" )"
389         fi
390
391         echo "${value}"
392 }
393
394 # user
395 defuser="netdata"
396 [ ! "${UID}" = "0" ] && defuser="${USER}"
397 NETDATA_USER="$( config_option "run as user" "${defuser}" )"
398
399 NETDATA_WEB_USER="$( config_option "web files owner" "${defuser}" )"
400 NETDATA_WEB_GROUP="$( config_option "web files group" "${NETDATA_WEB_USER}" )"
401
402 # debug flags
403 defdebug=0
404 NETDATA_DEBUG="$( config_option "debug flags" ${defdebug} )"
405
406 # port
407 defport=19999
408 NETDATA_PORT="$( config_option "port" ${defport} )"
409
410 # directories
411 NETDATA_LIB_DIR="$( config_option "lib directory" "${NETDATA_PREFIX}/var/lib/netdata" )"
412 NETDATA_CACHE_DIR="$( config_option "cache directory" "${NETDATA_PREFIX}/var/cache/netdata" )"
413 NETDATA_WEB_DIR="$( config_option "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )"
414 NETDATA_LOG_DIR="$( config_option "log directory" "${NETDATA_PREFIX}/var/log/netdata" )"
415 NETDATA_CONF_DIR="$( config_option "config directory" "${NETDATA_PREFIX}/etc/netdata" )"
416 NETDATA_BIND="$( config_option "bind socket to IP" "*" )"
417 NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
418
419
420 # -----------------------------------------------------------------------------
421 # prepare the directories
422
423 # this is needed if NETDATA_PREFIX is not empty
424 if [ ! -d "${NETDATA_RUN_DIR}" ]
425         then
426         mkdir -p "${NETDATA_RUN_DIR}" || exit 1
427 fi
428
429 echo >&2 "Fixing directories (user: ${NETDATA_USER})..."
430 for x in "${NETDATA_WEB_DIR}" "${NETDATA_CONF_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}" "${NETDATA_LIB_DIR}"
431 do
432         if [ ! -d "${x}" ]
433                 then
434                 echo >&2 "Creating directory '${x}'"
435                 run mkdir -p "${x}" || exit 1
436         fi
437
438         if [ ${UID} -eq 0 ]
439                 then
440                 if [ "${x}" = "${NETDATA_WEB_DIR}" ]
441                         then
442                         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}..."
443                 else
444                         run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_USER}..."
445                 fi
446         fi
447
448         run chmod 0755 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
449 done
450
451 if [ ${UID} -eq 0 ]
452         then
453         # fix apps.plugin to be setuid to root
454         run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
455         run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
456 fi
457
458 # -----------------------------------------------------------------------------
459 # check if we can re-start netdata
460
461 if [ ${DONOTSTART} -eq 1 ]
462         then
463         if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
464                 then
465                 echo >&2 "Generating empty config file in: ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
466                 echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
467
468                 if [ "${UID}" -eq 0 ]
469                         then
470                         chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
471                 fi
472                 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
473         fi
474         echo >&2 "OK. It is now installed and ready."
475         exit 0
476 fi
477
478 # -----------------------------------------------------------------------------
479 # stop a running netdata
480
481 isnetdata() {
482         [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
483         [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
484         return 1
485 }
486
487
488 printf >&2 "Stopping a (possibly) running netdata..."
489 ret=0
490 count=0
491 while [ $ret -eq 0 ]
492 do
493         if [ $count -gt 30 ]
494                 then
495                 echo >&2 "Cannot stop the running netdata."
496                 exit 1
497         fi
498
499         count=$((count + 1))
500
501         pid=$(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null)
502         # backwards compatibility
503         [ -z "${pid}" ] && pid=$(cat /var/run/netdata.pid 2>/dev/null)
504         [ -z "${pid}" ] && pid=$(cat /var/run/netdata/netdata.pid 2>/dev/null)
505         
506         isnetdata $pid || pid=
507         if [ ! -z "${pid}" ]
508                 then
509                 run kill $pid 2>/dev/null
510                 ret=$?
511         else
512                 run killall netdata 2>/dev/null
513                 ret=$?
514         fi
515
516         test $ret -eq 0 && printf >&2 "." && sleep 2
517 done
518 echo >&2
519 echo >&2
520
521
522 # -----------------------------------------------------------------------------
523 # run netdata
524
525 echo >&2 "Starting netdata..."
526 run ${NETDATA_PREFIX}/usr/sbin/netdata -pidfile ${NETDATA_RUN_DIR}/netdata.pid "${@}"
527
528 if [ $? -ne 0 ]
529         then
530         echo >&2
531         echo >&2 "SORRY! FAILED TO START NETDATA!"
532         exit 1
533 else
534         echo >&2 "OK. NetData Started!"
535 fi
536
537
538 # -----------------------------------------------------------------------------
539 # save a config file, if it is not already there
540
541 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
542         then
543         echo >&2 "Downloading default configuration from netdata..."
544         sleep 5
545
546         # remove a possibly obsolete download
547         [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
548
549         # disable a proxy to get data from the local netdata
550         export http_proxy=
551         export https_proxy=
552
553         # try wget
554         wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
555         ret=$?
556
557         # try curl
558         if [ $ret -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
559                 then
560                 curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
561                 ret=$?
562         fi
563
564         if [ $ret -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
565                 then
566                 mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
567                 echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
568
569                 if [ "${UID}" -eq 0 ]
570                         then
571                         chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
572                 fi
573                 chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
574         else
575                 echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
576                 [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
577         fi
578 fi
579
580 # -----------------------------------------------------------------------------
581 # Check for KSM
582
583 ksm_is_available_but_disabled() {
584         cat <<KSM1
585
586 -------------------------------------------------------------------------------
587 Memory de-duplication instructions
588
589 I see you have kernel memory de-duper (called Kernel Same-page Merging,
590 or KSM) available, but it is not currently enabled.
591
592 To enable it run:
593
594 echo 1 >/sys/kernel/mm/ksm/run
595 echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs
596
597 If you enable it, you will save 40-60% of netdata memory.
598
599 KSM1
600 }
601
602 ksm_is_not_available() {
603         cat <<KSM2
604
605 -------------------------------------------------------------------------------
606 Memory de-duplication not present in your kernel
607
608 It seems you do not have kernel memory de-duper (called Kernel Same-page
609 Merging, or KSM) available.
610
611 To enable it, you need a kernel built with CONFIG_KSM=y
612
613 If you can have it, you will save 40-60% of netdata memory.
614
615 KSM2
616 }
617
618 if [ -f "/sys/kernel/mm/ksm/run" ]
619         then
620         if [ $(cat "/sys/kernel/mm/ksm/run") != "1" ]
621                 then
622                 ksm_is_available_but_disabled
623         fi
624 else
625         ksm_is_not_available
626 fi
627
628 # -----------------------------------------------------------------------------
629 # Check for version.txt
630
631 if [ ! -s web/version.txt ]
632         then
633 cat <<VERMSG
634
635 -------------------------------------------------------------------------------
636 Version update check warning
637
638 The way you downloaded netdata, we cannot find its version. This means the
639 Update check on the dashboard, will not work.
640
641 If you want to have version update check, please re-install it
642 following the procedure in:
643
644 https://github.com/firehol/netdata/wiki/Installation
645
646 VERMSG
647 fi
648
649 # -----------------------------------------------------------------------------
650 # apps.plugin warning
651
652 if [ "${UID}" -ne 0 ]
653         then
654 cat <<SETUID_WARNING
655
656 -------------------------------------------------------------------------------
657 apps.plugin needs privileges
658
659 Since you have installed netdata as a normal user, to have apps.plugin collect
660 all the needed data, you have to give it the access rights it needs, by running
661 these commands:
662
663         sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
664         sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
665
666 The commands allow apps.plugin to run as root.
667
668 apps.plugin is performing a hard-coded function of data collection for all
669 running processes. It cannot be instructed from the netdata daemon to perform
670 any task, so it is pretty safe to do this.
671
672 SETUID_WARNING
673 fi
674
675 # -----------------------------------------------------------------------------
676 # Keep un-install info
677
678 cat >netdata-uninstaller.sh <<UNINSTALL
679 #!/bin/bash
680
681 # this script will uninstall netdata
682
683 if [ "\$1" != "--force" ]
684         then
685         echo >&2 "This script will REMOVE netdata from your system."
686         echo >&2 "Run it again with --force to do it."
687         exit 1
688 fi
689
690 echo >&2 "Stopping a possibly running netdata..."
691 killall netdata
692 sleep 2
693
694 deletedir() {
695         if [ ! -z "\$1" -a -d "\$1" ]
696                 then
697                 echo
698                 echo "Deleting directory '\$1' ..."
699                 rm -I -R "\$1"
700         fi
701 }
702
703 if [ ! -z "${NETDATA_PREFIX}" -a -d "${NETDATA_PREFIX}" ]
704         then
705         # installation prefix was given
706
707         deletedir "${NETDATA_PREFIX}"
708
709 else
710         # installation prefix was NOT given
711
712         if [ -f "${NETDATA_PREFIX}/usr/sbin/netdata" ]
713                 then
714                 echo "Deleting ${NETDATA_PREFIX}/usr/sbin/netdata ..."
715                 rm -i "${NETDATA_PREFIX}/usr/sbin/netdata"
716         fi
717
718         deletedir "${NETDATA_PREFIX}/etc/netdata"
719         deletedir "${NETDATA_PREFIX}/usr/share/netdata"
720         deletedir "${NETDATA_PREFIX}/usr/libexec/netdata"
721         deletedir "${NETDATA_PREFIX}/var/lib/netdata"
722         deletedir "${NETDATA_PREFIX}/var/cache/netdata"
723         deletedir "${NETDATA_PREFIX}/var/log/netdata"
724 fi
725
726 getent passwd netdata > /dev/null
727 if [ $? -eq 0 ]
728         then
729         echo
730         echo "You may also want to remove the user netdata"
731         echo "by running:"
732         echo "   userdel netdata"
733 fi
734
735 getent group netdata > /dev/null
736 if [ $? -eq 0 ]
737         then
738         echo
739         echo "You may also want to remove the group netdata"
740         echo "by running:"
741         echo "   groupdel netdata"
742 fi
743
744 getent group docker > /dev/null
745 if [ $? -eq 0 -a "${NETDATA_ADDED_TO_DOCKER}" = "1" ]
746         then
747         echo
748         echo "You may also want to remove the netdata user from the docker group"
749         echo "by running:"
750         echo "   gpasswd -d netdata docker"
751 fi
752
753 UNINSTALL
754 chmod 750 netdata-uninstaller.sh
755
756 # -----------------------------------------------------------------------------
757
758 if [ "${NETDATA_BIND}" = "*" ]
759         then
760         access="localhost"
761 else
762         access="${NETDATA_BIND}"
763 fi
764
765 cat <<END
766
767
768 -------------------------------------------------------------------------------
769
770 OK. NetData is installed and it is running (listening to ${NETDATA_BIND}:${NETDATA_PORT}).
771
772 -------------------------------------------------------------------------------
773
774
775 Hit http://${access}:${NETDATA_PORT}/ from your browser.
776
777 To stop netdata, just kill it, with:
778
779   killall netdata
780
781 To start it, just run it:
782
783   ${NETDATA_PREFIX}/usr/sbin/netdata
784
785
786 Enjoy!
787
788                  Give netdata a Github Star, at:
789
790              https://github.com/firehol/netdata/wiki
791
792
793 END
794 echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"