diff options
-rwxr-xr-x | netdata-installer.sh | 36 | ||||
-rw-r--r-- | packaging/installer/UNINSTALL.md | 2 | ||||
-rwxr-xr-x | packaging/installer/netdata-updater.sh | 16 |
3 files changed, 39 insertions, 15 deletions
diff --git a/netdata-installer.sh b/netdata-installer.sh index ff7b9c8d90..a79f41c159 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -985,8 +985,13 @@ fi # ----------------------------------------------------------------------------- progress "Copy uninstaller" -sed "s|ENVIRONMENT_FILE=\"/etc/netdata/.environment\"|ENVIRONMENT_FILE=\"${NETDATA_PREFIX}/etc/netdata/.environment\"|" packaging/installer/netdata-uninstaller.sh > ${NETDATA_PREFIX}/usr/libexec/netdata-uninstaller.sh -chmod 750 ${NETDATA_PREFIX}/usr/libexec/netdata-uninstaller.sh +if [ -f "${NETDATA_PREFIX}"/usr/libexec/netdata-uninstaller.sh ]; then + echo >&2 "Removing uninstaller from old location" + rm -f "${NETDATA_PREFIX}"/usr/libexec/netdata-uninstaller.sh; +fi + +sed "s|ENVIRONMENT_FILE=\"/etc/netdata/.environment\"|ENVIRONMENT_FILE=\"${NETDATA_PREFIX}/etc/netdata/.environment\"|" packaging/installer/netdata-uninstaller.sh > ${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh +chmod 750 ${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh # ----------------------------------------------------------------------------- progress "Basic netdata instructions" @@ -1007,19 +1012,24 @@ To start netdata run: ${TPUT_YELLOW}${TPUT_BOLD}${NETDATA_START_CMD}${TPUT_RESET} END -echo >&2 "Uninstall script copied to: ${TPUT_RED}${TPUT_BOLD}${NETDATA_PREFIX}/usr/libexec/netdata-uninstaller.sh${TPUT_RESET}" +echo >&2 "Uninstall script copied to: ${TPUT_RED}${TPUT_BOLD}${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh${TPUT_RESET}" echo >&2 progress "Install netdata updater tool" +if [ -f "${NETDATA_PREFIX}"/usr/libexec/netdata-updater.sh ]; then + echo >&2 "Removing updater from previous location" + rm -f "${NETDATA_PREFIX}"/usr/libexec/netdata-updater.sh +fi + if [ -f "${INSTALLER_DIR}/packaging/installer/netdata-updater.sh" ]; then - sed "s|THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT|${NETDATA_USER_CONFIG_DIR}/.environment|" "${INSTALLER_DIR}/packaging/installer/netdata-updater.sh" > "${NETDATA_PREFIX}/usr/libexec/netdata-updater.sh" || exit 1 + sed "s|THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT|${NETDATA_USER_CONFIG_DIR}/.environment|" "${INSTALLER_DIR}/packaging/installer/netdata-updater.sh" > "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-updater.sh" || exit 1 else - sed "s|THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT|${NETDATA_USER_CONFIG_DIR}/.environment|" "${NETDATA_SOURCE_DIR}/packaging/installer/netdata-updater.sh" > "${NETDATA_PREFIX}/usr/libexec/netdata-updater.sh" || exit 1 + sed "s|THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT|${NETDATA_USER_CONFIG_DIR}/.environment|" "${NETDATA_SOURCE_DIR}/packaging/installer/netdata-updater.sh" > "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-updater.sh" || exit 1 fi -chmod 0755 ${NETDATA_PREFIX}/usr/libexec/netdata-updater.sh -echo >&2 "Update script is located at ${TPUT_GREEN}${TPUT_BOLD}${NETDATA_PREFIX}/usr/libexec/netdata-updater.sh${TPUT_RESET}" +chmod 0755 ${NETDATA_PREFIX}/usr/libexec/netdata/netdata-updater.sh +echo >&2 "Update script is located at ${TPUT_GREEN}${TPUT_BOLD}${NETDATA_PREFIX}/usr/libexec/netdata/netdata-updater.sh${TPUT_RESET}" echo >&2 # Figure out the cron directory for the distro @@ -1043,7 +1053,7 @@ else echo >&2 "Adding to cron" rm -f "${crondir}/netdata-updater" - ln -sf "${NETDATA_PREFIX}/usr/libexec/netdata-updater.sh" "${crondir}/netdata-updater" + ln -sf "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-updater.sh" "${crondir}/netdata-updater" echo >&2 "Auto-updating has been enabled. Updater script linked to: ${TPUT_RED}${TPUT_BOLD}${crondir}/netdata-update${TPUT_RESET}" echo >&2 @@ -1062,7 +1072,10 @@ else fi fi +progress "Wrap up environment set up" + # Save environment variables +echo >&2 "Preparing .environment file" cat <<EOF > "${NETDATA_USER_CONFIG_DIR}/.environment" # Created by installer PATH="${PATH}" @@ -1075,10 +1088,13 @@ NETDATA_GROUP="${NETDATA_GROUP}" REINSTALL_COMMAND="${REINSTALL_COMMAND}" RELEASE_CHANNEL="${RELEASE_CHANNEL}" IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY}" -# This value is meant to be populated by autoupdater (if enabled) -NETDATA_TARBALL_CHECKSUM="new_installation" +NETDATA_LIB_DIR="${NETDATA_LIB_DIR}" EOF +echo >&2 "Setting netdata.tarball.checksum to 'new_installation'" +cat <<EOF > "${NETDATA_LIB_DIR}/netdata.tarball.checksum" +new_installation +EOF # ----------------------------------------------------------------------------- echo >&2 diff --git a/packaging/installer/UNINSTALL.md b/packaging/installer/UNINSTALL.md index 765184d395..43d03b0020 100644 --- a/packaging/installer/UNINSTALL.md +++ b/packaging/installer/UNINSTALL.md @@ -16,7 +16,7 @@ NETDATA_ADDED_TO_GROUPS="<additional groups>" # Additional groups for a user ru ``` 3. Run `netdata-uninstaller.sh` as follows ``` -${NETDATA_PREFIX}/usr/libexec/netdata-uninstaller.sh --yes --env <environment_file> +${NETDATA_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh --yes --env <environment_file> ``` Note: Existing installations may still need to download the file if it's not present. diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index bb5f371879..6609edd5a8 100755 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -11,7 +11,7 @@ # - NETDATA_TARBALL_URL # - NETDATA_TARBALL_CHECKSUM_URL # - NETDATA_TARBALL_CHECKSUM -# +# - NETDATA_PREFIX / NETDATA_LIB_DIR (After 1.16.1 we will only depend on lib dir) # # Copyright: SPDX-License-Identifier: GPL-3.0-or-later # @@ -142,10 +142,12 @@ update() { info "Re-installing netdata..." eval "${REINSTALL_COMMAND} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA" + + # We no longer store checksum info here. but leave this so that we clean up all environment files upon next update. sed -i '/NETDATA_TARBALL/d' "${ENVIRONMENT_FILE}" - cat <<EOF >>"${ENVIRONMENT_FILE}" -NETDATA_TARBALL_CHECKSUM="$NEW_CHECKSUM" -EOF + + info "Updating tarball checksum info" + echo "${NEW_CHECKSUM}" > "${NETDATA_LIB_DIR}/netdata.tarball.checksum" fi rm -rf "${tmpdir}" >&3 2>&3 @@ -159,6 +161,12 @@ EOF # shellcheck source=/dev/null source "${ENVIRONMENT_FILE}" || exit 1 +# We dont expect to find lib dir variable on older installations, so load this path if none found +export NETDATA_LIB_DIR="${NETDATA_LIB_DIR:-${NETDATA_PREFIX}/var/lib/netdata}" + +# Source the tarbal checksum, if not already available from environment (for existing installations with the old logic) +[[ -z "${NETDATA_TARBALL_CHECKSUM}" ]] && [[ -f ${NETDATA_LIB_DIR}/netdata.tarball.checksum ]] && NETDATA_TARBALL_CHECKSUM="$(cat "${NETDATA_LIB_DIR}/netdata.tarball.checksum")" + if [ "${INSTALL_UID}" != "$(id -u)" ]; then fatal "You are running this script as user with uid $(id -u). We recommend to run this script as root (user with uid 0)" fi |