@cryptotaxi247 / netdata-1 / commits / fd1f86c8f

moved netdata.start to netdata-installer.sh

Costa Tsaousis (ktsaou) committed Nov 17, 2015 at 02:26 UTC fd1f86c8f5c6b513ebbca19a9f378be37873cdfe
2 files changed +130 -36
README.md
+19 -6
@@ -154,18 +154,33 @@ To install it in Ubuntu, you need to run:
154 apt-get install zlib1g-dev
155 ```
156
157 +You also need to have a basic build environment in place. You will need packages like
158 +`pgk-config`, `autoconf`, `gcc`, etc.
159 +
160 Then do this to install and run netdata:
161
162 ```sh
163 +
164 +# download it
165 git clone https://github.com/ktsaou/netdata.git netdata.git
166 cd netdata.git
162 -./netdata.start
167 +
168 +# build it
169 +./netdata-installer.sh
170 +
171 ```
172
165 -Once you run it, the file conf.d/netdata.conf will be created. You can edit this file to set options for each graph.
173 +The script `netdata-installer.sh` will build netdata and install it to your system.
174 +
175 +Once the installer completes, the file `/etc/netdata/netdata.conf` will be created.
176 +You can edit this file to set options.
177 To apply the changes you made, you have to run netdata.start again.
178
168 -If you run `netdata.start` as `root`, netdata will start by default as `nobody`. Otherwise it will run as the user that started it. If you run it as `root`, you can set the user you want it to run in the config file `conf.d/netdata.conf`.
179 +- You can start netdata by executing it with `netdata` (the installer will also start it).
180 +
181 +- You can stop netdata by killing it with `killall netdata`.
182 + You can stop and start netdata at any point. Netdata saves on exit its round robbin
183 + database to `/var/cache/netdata` so that it will continue from where it stopped the last time.
184
185 To access the web site for all graphs, go to:
186
@@ -175,6 +190,4 @@ To access the web site for all graphs, go to:
190
191 You can get the running config file at any time, by accessing `http://127.0.0.1:19999/netdata.conf`.
192
178 -To start it at boot, just run `/path/to/netdata.git/netdata.start` from your `/etc/rc.local` or equivalent.
179 -
180 -You can stop and start netdata at any point. Netdata saves on exit its round robbin database to `cache/` so that it will continue from where it stopped the last time.
193 +To start it at boot, just run `netdata` from your `/etc/rc.local` or equivalent.
netdata-installer.sh renamed
+111 -30
@@ -1,43 +1,109 @@
1 #!/bin/bash
2
3 -netdata=$(which netdata)
3 +if [ ! "${UID}" = 0 -o "$1" = "-h" -o "$1" = "--help" ]
4 + then
5 + echo >&2
6 + echo >&2 "You have to run netdata are root."
7 + echo >&2 "The netdata daemon will drop priviliges"
8 + echo >&2 "but you have to start it as root."
9 + echo >&2
10 + echo >&2 "If netdata is not already installed,"
11 + echo >&2 "this script will also build and install"
12 + echo >&2 "netdata to your system."
13 + echo >&2
14 + exit 1
15 +fi
16 +
17 +# reload the profile
18 +[ -f /etc/profile ] && . /etc/profile
19 +
20 +build_error() {
21 + cat <<EOF
22 +
23 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24 +
25 +We are very sorry! NetData failed to build...
26 +
27 +You many need to check these:
28 +
29 +1. The package zlib1g-dev has to be installed.
30
5 -if [ -z "${netdata}" -o ! -f src/netdata ]
6 -then
7 - echo >&2 "Running ./autogen.sh ..."
8 - ./autogen.sh || exit 1
31 +2. You need basic build tools installed, like: gcc, autoconf,
32 + pgk-config, automake, etc.
33
10 - echo >&2 "Running ./configure ..."
11 - ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-zlib --with-math --with-user=netdata CFLAGS="-march=native -O3 -Wall -Wextra" || exit 1
34 +3. If your system cannot find ZLIB, although it is installed
35 + run me with the option: --zlib-is-really-here
36
13 - echo >&2 "Cleaning a possibly old compilation ..."
14 - make clean || exit 1
37 +If you still cannot get it to build, ask for help at github:
38
39 + https://github.com/firehol/netdata/issues
40 +
41 +
42 +EOF
43 + trap - EXIT
44 + exit 1
45 +}
46 +
47 +run() {
48 + printf >&2 ":-----------------------------------------------------------------------------\n"
49 + printf >&2 "Running command:\n"
50 + printf >&2 "\n"
51 + printf >&2 "%q " "${@}"
52 + printf >&2 "\n"
53 + printf >&2 "\n"
54 +
55 + "${@}"
56 +}
57 +
58 +if [ "$1" = "--zlib-is-really-here" ]
59 + then
60 + shift
61 + echo >&2 "ok, assuming zlib is really installed."
62 + export ZLIB_CFLAGS=" "
63 + export ZLIB_LIBS="-lz"
64 fi
65
18 -echo >&2 "Compiling netdata ..."
19 -make || exit 1
66 +if [ ! -f src/Makefile ]
67 + then
68 + read -p "Netdata is not configured. Press ENTER to configure it > "
69
21 -if [ -z "${netdata}" -o src/netdata -nt "${netdata}" ]
22 -then
23 - echo >&2 "Installing netdata ..."
24 - make install
70 + trap build_error EXIT
71
26 - echo >&2 "Adding netdata group ..."
27 - getent group netdata > /dev/null || groupadd -r netdata
72 + echo >&2 "Running ./autogen.sh ..."
73 + run ./autogen.sh || exit 1
74
29 - echo >&2 "Adding netdata user ..."
30 - getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
75 + echo >&2 "Running ./configure ..."
76 + run ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-zlib --with-math --with-user=netdata CFLAGS="-march=native -O3" || exit 1
77 +
78 + # remove the build_error hook
79 + trap - EXIT
80 +
81 + if [ -f src/netdata ]
82 + then
83 + echo >&2 "Cleaning a possibly old compilation ..."
84 + make clean
85 + fi
86 fi
87
33 -netdata=$(which netdata)
88 +echo >&2 "Compiling netdata ..."
89 +run make || exit 1
90 +
91 +echo >&2 "Installing netdata ..."
92 +run make install
93 +
94 +echo >&2 "Adding netdata user group ..."
95 +getent group netdata > /dev/null || run groupadd -r netdata
96 +
97 +echo >&2 "Adding netdata user account ..."
98 +getent passwd netdata > /dev/null || run useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
99 +
100
101
102 # -----------------------------------------------------------------------------
103 # load options from the configuration file
104
105 # create an empty config if it does not exist
40 -[ ! -f conf.d/netdata.conf ] && touch conf.d/netdata.conf
106 +[ ! -f /etc/netdata/netdata.conf ] && touch /etc/netdata/netdata.conf
107
108 # function to extract values from the config file
109 config_option() {
@@ -81,14 +147,14 @@ do
147 if [ ! -d "${x}" ]
148 then
149 echo >&2 "Creating directory '${x}'"
84 - mkdir -p "${x}" || exit 1
150 + run mkdir -p "${x}" || exit 1
151 fi
86 - chown -R "${NETDATA_USER}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_USER}..."
87 - chmod 0775 "${x}" "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
152 + run chown -R "${NETDATA_USER}" "${x}" || echo >&2 "WARNING: Cannot change the ownership of the files in directory ${x} to ${NETDATA_USER}..."
153 + run chmod 0775 "${x}" || echo >&2 "WARNING: Cannot change the permissions of the directory ${x} to 0755..."
154 done
155
156 # fix apps.plugin to be setuid to root
91 -chown root '/usr/libexec/netdata/plugins.d/apps.plugin' && chmod 4755 '/usr/libexec/netdata/plugins.d/apps.plugin'
157 +run chown root '/usr/libexec/netdata/plugins.d/apps.plugin' && run chmod 4755 '/usr/libexec/netdata/plugins.d/apps.plugin'
158
159
160 # -----------------------------------------------------------------------------
@@ -164,8 +230,23 @@ if [ ! -s /etc/netdata/netdata.conf ]
230 fi
231 fi
232
167 -echo >&2
168 -echo >&2 "Hit http://localhost:${NETDATA_PORT}/ from your browser."
169 -echo >&2
170 -echo >&2 "Enjoy..."
171 -echo >&2
233 +cat <<END
234 +
235 +
236 +-------------------------------------------------------------------------------
237 +
238 +ok. NetData is installed and is running.
239 +
240 +Hit http://localhost:${NETDATA_PORT}/ from your browser.
241 +
242 +To stop netdata, just kill it, with:
243 +
244 + killall netdata
245 +
246 +To start it, just run it:
247 +
248 + netdata
249 +
250 +Enjoy!
251 +
252 +END