@cryptotaxi247 / netdata-1 / commits / 23225bee1

added more installer options (--dont-wait, --dont-start-it, --help) and info

Costa Tsaousis (ktsaou) committed Feb 2, 2016 at 03:13 UTC 23225bee1951988b729909f77a531e0e580b4b2e
1 file changed +134 -20
netdata-installer.sh
+134 -20
@@ -2,21 +2,123 @@
2
3 LC_ALL=C
4
5 +# you can set CFLAGS before running installer
6 +CFLAGS="${CFLAGS--O3}"
7 +
8 +ME="$0"
9 +DONOTSTART=0
10 +DONOTWAIT=0
11 +NETDATA_PREFIX=
12 +ZLIB_IS_HERE=0
13 +
14 +usage() {
15 + cat <<USAGE
16 +
17 +${ME} <installer options>
18 +
19 +Valid <installer options> are:
20 +
21 + --install /PATH/TO/INSTALL
22 +
23 + If your give: --install /opt
24 + netdata will be installed in /opt/netdata
25 +
26 + --dont-start-it
27 +
28 + Do not (re)start netdata.
29 + Just install it.
30 +
31 + --dont-wait
32 +
33 + Do not wait for the user to press ENTER.
34 + Start immediately building it.
35 +
36 + --zlib-is-really-here
37 +
38 + If you get errors about missing zlib,
39 + but you know it is available,
40 + you have a broken pkg-config.
41 + Use this option to allow it continue
42 + without checking pkg-config.
43 +
44 +Netdata will by default be compiled with gcc optimization -O3
45 +If you need to pass different CFLAGS, use something like this:
46 +
47 + CFLAGS="<gcc options>" $ME <installer options>
48 +
49 +For the installer to complete successfully, you will need
50 +these packages installed:
51 +
52 + gcc make autoconf automake pkg-config zlib1g-dev
53 +
54 +For the plugins, you will at least need:
55 +
56 + curl node
57 +
58 +USAGE
59 +}
60 +
61 +while [ ! -z "${1}" ]
62 +do
63 + if [ "$1" = "--install" ]
64 + then
65 + NETDATA_PREFIX="${2}/netdata"
66 + shift 2
67 + elif [ "$1" = "--zlib-is-really-here" ]
68 + then
69 + ZLIB_IS_HERE=1
70 + shift 1
71 + elif [ "$1" = "--dont-start-it" ]
72 + then
73 + DONOTSTART=1
74 + shift 1
75 + elif [ "$1" = "--dont-wait" ]
76 + then
77 + DONOTWAIT=1
78 + shift 1
79 + elif [ "$1" = "--help" -o "$1" = "-h" ]
80 + then
81 + usage
82 + exit 1
83 + else
84 + echo >&2
85 + echo >&2 "ERROR:"
86 + echo >&2 "I cannot understand option '$1'."
87 + usage
88 + exit 1
89 + fi
90 +done
91 +
92 cat <<BANNER
93
94 +Welcome to netdata!
95 +Nice to see you are giving it a try!
96
8 -This script will build and install netdata to your system.
97 +You are about to build and install netdata to your system.
98
10 -By default netdata will be installed as any other package.
11 -If you want to install it to another directory, run me
12 -with the option:
99 +By default netdata will be installed as any other package:
100
14 -$0 --install /path/to/install
101 + - the daemon at /usr/sbin/netdata
102 + - config files at /etc/netdata
103 + - web files at /usr/share/web/netdata
104 + - plugins at /usr/libexec/netdata
105 + - cache files at /var/cache/netdata
106 + - log files at /var/log/netdata
107 +
108 +If you want to install it to another directory, run the
109 +installer like this:
110 +
111 + $ME --install /path/to/install
112
113 A new directory called netdata will be created as
114
18 -/path/to/install/netdata
115 + /path/to/install/netdata
116
117 +and all of netdata will be installed into it.
118 +Nothing will be touched on your system.
119 +
120 +This installer accepts more options.
121 +Run it with --help for help.
122
123 BANNER
124
@@ -30,18 +132,14 @@ if [ ! "${UID}" = 0 -o "$1" = "-h" -o "$1" = "--help" ]
132 exit 1
133 fi
134
33 -NETDATA_PREFIX=
34 -if [ "$1" = "--install" ]
35 - then
36 - NETDATA_PREFIX="${2}/netdata"
37 - shift 2
38 -fi
39 -
40 -if [ ! -z "${NETDATA_PREFIX}" ]
135 +if [ ${DONOTWAIT} -eq 0 ]
136 then
42 - read -p "Press ENTER to build and install netdata to '${NETDATA_PREFIX}' > "
43 -else
44 - read -p "Press ENTER to build and install netdata to your system > "
137 + if [ ! -z "${NETDATA_PREFIX}" ]
138 + then
139 + read -p "Press ENTER to build and install netdata to '${NETDATA_PREFIX}' > "
140 + else
141 + read -p "Press ENTER to build and install netdata to your system > "
142 + fi
143 fi
144
145 # reload the profile
@@ -52,7 +150,7 @@ build_error() {
150
151 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152
55 -We are very sorry! NetData failed to build...
153 +Sorry! NetData failed to build...
154
155 You many need to check these:
156
@@ -86,7 +184,7 @@ run() {
184 "${@}"
185 }
186
89 -if [ "$1" = "--zlib-is-really-here" ]
187 +if [ ${ZLIB_IS_HERE} -eq 1 ]
188 then
189 shift
190 echo >&2 "ok, assuming zlib is really installed."
@@ -105,7 +203,7 @@ run ./configure \
203 --sysconfdir="${NETDATA_PREFIX}/etc" \
204 --localstatedir="${NETDATA_PREFIX}/var" \
205 --with-zlib --with-math --with-user=netdata \
108 - CFLAGS="-O3" || exit 1
206 + CFLAGS="${CFLAGS}" || exit 1
207
208 # remove the build_error hook
209 trap - EXIT
@@ -189,6 +287,22 @@ run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
287 run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
288
289
290 +# -----------------------------------------------------------------------------
291 +# check if we can re-start netdata
292 +
293 +if [ ${DONOTSTART} -eq 1 ]
294 + then
295 + if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
296 + then
297 + echo >&2 "Generating empty config file in: ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
298 + echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
299 + chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
300 + chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
301 + fi
302 + echo >&2 "OK. It is now installed and ready."
303 + exit 0
304 +fi
305 +
306 # -----------------------------------------------------------------------------
307 # stop a running netdata
308