summaryrefslogtreecommitdiffstats
path: root/packaging/installer
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2020-07-20 07:25:04 -0400
committerGitHub <noreply@github.com>2020-07-20 07:25:04 -0400
commiteb42d2ad43680e0aa71dca21adb40cfcf2b505e8 (patch)
treeb3fe416bf1e6e130dbe38b4f3a187ebb2d769faf /packaging/installer
parentc0a0c081f31a08c1747bc250b1413da5a4926fc6 (diff)
Add better checks for existing installs to the kickstart scripts. (#9408)
* Added better checks for existing installs to the kickstart scripts. This adds more robust checks to our Kickstart install scripts to prevent users from accidentally installing Netdata over top of an existing install (which can lead to all kinds of problematic situations). The logic for these checks works as follows: - See if `netdata` is located somewhere in `$PATH` (using `command -v`), and if present assume there's an existing install. - Otherwise, check if `/opt/netdata/bin/netdata` exists, if so assume there's an existing install, otherwise continue under the assumption there isn't. - If there is an existing install, check if it's one done through our install scripts, if not stop the installation process. - If it is one of our installs, look for and attempt to use the updater script to update the existing install (exiting with an error message if that fails). This also adds a switch called '--allow-duplicate-install' which will cause the install to continue if it would normally refuse to continue due to an existing install. * Update checksums. * Address feedback from @prologic.
Diffstat (limited to 'packaging/installer')
-rwxr-xr-xpackaging/installer/kickstart-static64.sh62
-rwxr-xr-xpackaging/installer/kickstart.sh60
-rw-r--r--packaging/installer/methods/kickstart-64.md2
-rw-r--r--packaging/installer/methods/kickstart.md2
4 files changed, 104 insertions, 22 deletions
diff --git a/packaging/installer/kickstart-static64.sh b/packaging/installer/kickstart-static64.sh
index 13cba51470..790986bf92 100755
--- a/packaging/installer/kickstart-static64.sh
+++ b/packaging/installer/kickstart-static64.sh
@@ -4,12 +4,13 @@
# shellcheck disable=SC1117,SC2039,SC2059,SC2086
#
# Options to run
-# --dont-wait do not wait for input
-# --non-interactive do not wait for input
-# --dont-start-it do not start netdata after install
-# --stable-channel Use the stable release channel, rather than the nightly to fetch sources
-# --disable-telemetry Opt-out of anonymous telemetry program (DO_NOT_TRACK=1)
-# --local-files Use a manually provided tarball for the installation
+# --dont-wait do not wait for input
+# --non-interactive do not wait for input
+# --dont-start-it do not start netdata after install
+# --stable-channel Use the stable release channel, rather than the nightly to fetch sources
+# --disable-telemetry Opt-out of anonymous telemetry program (DO_NOT_TRACK=1)
+# --local-files Use a manually provided tarball for the installation
+# --allow-duplicate-install do not bail if we detect a duplicate install
#
# Environment options:
#
@@ -179,6 +180,52 @@ sudo=""
[ -z "${UID}" ] && UID="$(id -u)"
[ "${UID}" -ne "0" ] && sudo="sudo"
+# ---------------------------------------------------------------------------------------------------------------------
+# look for an existing install and try to update that instead if it exists
+
+ndpath="$(command -v netdata 2>/dev/null)"
+if [ -z "$ndpath" ] && [ -x /opt/netdata/bin/netdata ] ; then
+ ndpath="/opt/netdata/bin/netdata"
+fi
+
+if [ -n "$ndpath" ] ; then
+ ndprefix="$(dirname "$(dirname "${ndpath}")")"
+
+ if [ "${ndprefix}" = /usr ] ; then
+ ndprefix="/"
+ fi
+
+ progress "Found existing install of Netdata under: ${ndprefix}"
+
+ if [ -r "${ndprefix}/etc/netdata/.environment" ] ; then
+ if [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then
+ progress "Attempting to update existing install instead of creating a new one"
+ if run ${sudo} "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ; then
+ progress "Updated existing install at ${ndpath}"
+ exit 0
+ else
+ fatal "Failed to update existing Netdata install"
+ exit 1
+ fi
+ else
+ if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
+ fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue."
+ exit 1
+ else
+ progress "User explicitly requested duplicate install, proceeding."
+ fi
+ fi
+ else
+ progress "Existing install appears to be handled manually or through the system package manager."
+ if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
+ fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue."
+ exit 1
+ else
+ progress "User explicitly requested duplicate install, proceeding."
+ fi
+ fi
+fi
+
# ----------------------------------------------------------------------------
if [ "$(uname -m)" != "x86_64" ]; then
fatal "Static binary versions of netdata are available only for 64bit Intel/AMD CPUs (x86_64), but yours is: $(uname -m)."
@@ -228,6 +275,9 @@ while [ -n "${1}" ]; do
NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM="${1}"
shift 1
+ elif [ "${1}" = "--allow-duplicate-install" ]; then
+ NETDATA_ALLOW_DUPLICATE_INSTALL=1
+ shift 1
else
echo >&2 "Unknown option '${1}' or invalid number of arguments. Please check the README for the available arguments of ${0} and try again"
exit 1
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index a6779174da..1adfaca754 100755
--- a/packaging/installer/kickstart.sh
+++ b/packaging/installer/kickstart.sh
@@ -14,6 +14,7 @@
# --non-interactive do not prompt for user input
# --no-updates do not install script for daily updates
# --local-files set the full path of the desired tarball to run install with
+# --allow-duplicate-install do not bail if we detect a duplicate install
#
# Environment options:
#
@@ -278,21 +279,49 @@ sudo=""
export PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
# ---------------------------------------------------------------------------------------------------------------------
-# try to update using autoupdater in the first place
-
-updater=""
-[ -x /etc/periodic/daily/netdata-updater ] && updater=/etc/periodic/daily/netdata-updater
-[ -x /etc/cron.daily/netdata-updater ] && updater=/etc/cron.daily/netdata-updater
-if [ -L "${updater}" ]; then
- # remove old updater (symlink)
- run ${sudo} rm -f "${updater}"
- updater=""
+# look for an existing install and try to update that instead if it exists
+
+ndpath="$(command -v netdata 2>/dev/null)"
+if [ -z "$ndpath" ] && [ -x /opt/netdata/bin/netdata ] ; then
+ ndpath="/opt/netdata/bin/netdata"
fi
-if [ -n "${updater}" ]; then
- # attempt to run the updater, to respect any compilation settings already in place
- progress "Re-installing netdata..."
- run ${sudo} "${updater}" -f || fatal "Failed to forcefully update netdata"
- exit 0
+
+if [ -n "$ndpath" ] ; then
+ ndprefix="$(dirname "$(dirname "${ndpath}")")"
+
+ if [ "${ndprefix}" = /usr ] ; then
+ ndprefix="/"
+ fi
+
+ progress "Found existing install of Netdata under: ${ndprefix}"
+
+ if [ -r "${ndprefix}/etc/netdata/.environment" ] ; then
+ if [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then
+ progress "Attempting to update existing install instead of creating a new one"
+ if run ${sudo} "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ; then
+ progress "Updated existing install at ${ndpath}"
+ exit 0
+ else
+ fatal "Failed to update existing Netdata install"
+ exit 1
+ fi
+ else
+ if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
+ fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue."
+ exit 1
+ else
+ progress "User explicitly requested duplicate install, proceeding."
+ fi
+ fi
+ else
+ progress "Existing install appears to be handled manually or through the system package manager."
+ if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then
+ fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue."
+ exit 1
+ else
+ progress "User explicitly requested duplicate install, proceeding."
+ fi
+ fi
fi
# ---------------------------------------------------------------------------------------------------------------------
@@ -318,6 +347,9 @@ while [ -n "${1}" ]; do
RELEASE_CHANNEL="stable"
NETDATA_INSTALLER_OPTIONS="$NETDATA_INSTALLER_OPTIONS --stable-channel"
shift 1
+ elif [ "${1}" = "--allow-duplicate-install" ]; then
+ NETDATA_ALLOW_DUPLICATE_INSTALL=1
+ shift 1
elif [ "${1}" = "--local-files" ]; then
shift 1
if [ -z "${1}" ]; then
diff --git a/packaging/installer/methods/kickstart-64.md b/packaging/installer/methods/kickstart-64.md
index 7a9e7ff6eb..f5e146dfc8 100644
--- a/packaging/installer/methods/kickstart-64.md
+++ b/packaging/installer/methods/kickstart-64.md
@@ -77,7 +77,7 @@ To use `md5sum` to verify the intregity of the `kickstart-static64.sh` script yo
command above, run the following:
```bash
-[ "ff717737ccc2212a3363dad7fa8bd20d" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
+[ "f47630f78c0c5e651cb6788301d8e05c" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
```
If the script is valid, this command will return `OK, VALID`.
diff --git a/packaging/installer/methods/kickstart.md b/packaging/installer/methods/kickstart.md
index 5c26b349d8..9519aff8de 100644
--- a/packaging/installer/methods/kickstart.md
+++ b/packaging/installer/methods/kickstart.md
@@ -58,7 +58,7 @@ To use `md5sum` to verify the intregity of the `kickstart.sh` script you will do
run the following:
```bash
-[ "2057599f8b11ce56f85aa7f26ce7b15b" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
+[ "05e3a23be90de1c2c62b2dbd8a3fb682" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
```
If the script is valid, this command will return `OK, VALID`.