4
# shellcheck disable=SC1117,SC2039,SC2059,SC2086
5
#
6
# Options to run
7
-# --dont-wait do not wait for input
8
-# --non-interactive do not wait for input
9
-# --dont-start-it do not start netdata after install
10
-# --stable-channel Use the stable release channel, rather than the nightly to fetch sources
11
-# --disable-telemetry Opt-out of anonymous telemetry program (DO_NOT_TRACK=1)
12
-# --local-files Use a manually provided tarball for the installation
7
+# --dont-wait do not wait for input
8
+# --non-interactive do not wait for input
9
+# --dont-start-it do not start netdata after install
10
+# --stable-channel Use the stable release channel, rather than the nightly to fetch sources
11
+# --disable-telemetry Opt-out of anonymous telemetry program (DO_NOT_TRACK=1)
12
+# --local-files Use a manually provided tarball for the installation
13
+# --allow-duplicate-install do not bail if we detect a duplicate install
14
#
15
# Environment options:
16
#
180
[ -z "${UID}" ] && UID="$(id -u)"
181
[ "${UID}" -ne "0" ] && sudo="sudo"
182
183
+# ---------------------------------------------------------------------------------------------------------------------
184
+# look for an existing install and try to update that instead if it exists
185
+
186
+ndpath="$(command -v netdata 2>/dev/null)"
187
+if [ -z "$ndpath" ] && [ -x /opt/netdata/bin/netdata ] ; then
188
+ ndpath="/opt/netdata/bin/netdata"
189
+fi
190
+
191
+if [ -n "$ndpath" ] ; then
192
+ ndprefix="$(dirname "$(dirname "${ndpath}")")"
193
+
194
+ if [ "${ndprefix}" = /usr ] ; then
195
+ ndprefix="/"
196
+ fi
197
+
198
+ progress "Found existing install of Netdata under: ${ndprefix}"
199
+
200
+ if [ -r "${ndprefix}/etc/netdata/.environment" ] ; then
201
+ if [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then
202
+ progress "Attempting to update existing install instead of creating a new one"
203
+ if run ${sudo} "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ; then
204
+ progress "Updated existing install at ${ndpath}"
205
+ exit 0
206
+ else
207
+ fatal "Failed to update existing Netdata install"
208
+ exit 1
209
+ fi
210
+ else
211
+ if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
212
+ fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue."
213
+ exit 1
214
+ else
215
+ progress "User explicitly requested duplicate install, proceeding."
216
+ fi
217
+ fi
218
+ else
219
+ progress "Existing install appears to be handled manually or through the system package manager."
220
+ if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
221
+ fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue."
222
+ exit 1
223
+ else
224
+ progress "User explicitly requested duplicate install, proceeding."
225
+ fi
226
+ fi
227
+fi
228
+
229
# ----------------------------------------------------------------------------
230
if [ "$(uname -m)" != "x86_64" ]; then
231
fatal "Static binary versions of netdata are available only for 64bit Intel/AMD CPUs (x86_64), but yours is: $(uname -m)."
275
276
NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM="${1}"
277
shift 1
278
+ elif [ "${1}" = "--allow-duplicate-install" ]; then
279
+ NETDATA_ALLOW_DUPLICATE_INSTALL=1
280
+ shift 1
281
else
282
echo >&2 "Unknown option '${1}' or invalid number of arguments. Please check the README for the available arguments of ${0} and try again"
283
exit 1