summaryrefslogtreecommitdiffstats
path: root/netdata-installer.sh
diff options
context:
space:
mode:
Diffstat (limited to 'netdata-installer.sh')
-rwxr-xr-xnetdata-installer.sh61
1 files changed, 9 insertions, 52 deletions
diff --git a/netdata-installer.sh b/netdata-installer.sh
index 4c3aeee71..bf7ac4048 100755
--- a/netdata-installer.sh
+++ b/netdata-installer.sh
@@ -1050,63 +1050,20 @@ END
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
+# -----------------------------------------------------------------------------
+progress "Install (but not enable) netdata updater tool"
+cleanup_old_netdata_updater || run_failed "Cannot cleanup old netdata updater tool."
+install_netdata_updater || run_failed "Cannot install netdata updater tool."
-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/netdata-updater.sh" || exit 1
+progress "Check if we must enable/disable the netdata updater tool"
+if [ "${AUTOUPDATE}" = "1" ]; then
+ enable_netdata_updater || run_failed "Cannot enable netdata updater tool"
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/netdata-updater.sh" || exit 1
+ disable_netdata_updater || run_failed "Cannot disable netdata updater tool"
fi
-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
-crondir=
-[ -d "/etc/periodic/daily" ] && crondir="/etc/periodic/daily"
-[ -d "/etc/cron.daily" ] && crondir="/etc/cron.daily"
-
-if [ -z "${crondir}" ]; then
- echo >&2 "Cannot figure out the cron directory to handle netdata-updater.sh activation/deactivation"
-elif [ "${UID}" -ne "0" ]; then
- # We cant touch cron if we are not running as root
- echo >&2 "You need to run the installer as root for auto-updating via cron."
-else
- progress "Check if we must enable/disable the netdata updater"
- if [ "${AUTOUPDATE}" = "1" ]; then
- if [ -f "${crondir}/netdata-updater.sh" ]; then
- progress "Removing incorrect netdata-updater filename in cron"
- rm -f "${crondir}/netdata-updater.sh"
- fi
-
- echo >&2 "Adding to cron"
-
- rm -f "${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
- echo >&2 "${TPUT_DIM}${TPUT_BOLD}netdata-updater.sh${TPUT_RESET}${TPUT_DIM} works from cron. It will trigger an email from cron"
- echo >&2 "only if it fails (it should not print anything when it can update netdata).${TPUT_RESET}"
- else
- echo >&2 "You chose *NOT* to enable auto-update, removing any links to the updater from cron (it may have happened if you are reinstalling)"
- echo >&2
-
- if [ -f "${crondir}/netdata-updater" ]; then
- echo >&2 "Removing cron reference: ${crondir}/netdata-updater"
- rm -f "${crondir}/netdata-updater"
- else
- echo >&2 "Did not find any cron entries to remove"
- fi
- fi
-fi
+# -----------------------------------------------------------------------------
progress "Wrap up environment set up"
# Save environment variables