@cryptotaxi247 / netdata-1 / commits / cd5cfc9b0

add --reinstall-clean flag and update documentation (#12548)

maneamarius committed Apr 11, 2022 at 14:41 UTC cd5cfc9b0819a7977078fcb62d537a5b742c80bb
2 files changed +67 -32
packaging/installer/kickstart.sh
+64 -32
@@ -59,6 +59,53 @@ else
59 INTERACTIVE=1
60 fi
61
62 +main() {
63 + if [ "${ACTION}" = "uninstall" ]; then
64 + uninstall
65 + cleanup
66 + trap - EXIT
67 + exit 0
68 + fi
69 +
70 + if [ "${ACTION}" = "reinstall-clean" ]; then
71 + NEW_INSTALL_PREFIX="${INSTALL_PREFIX}"
72 + uninstall
73 + cleanup
74 +
75 + ACTION=
76 + INSTALL_PREFIX="${NEW_INSTALL_PREFIX}"
77 + # shellcheck disable=SC2086
78 + main
79 +
80 + trap - EXIT
81 + exit 0
82 + fi
83 +
84 + tmpdir="$(create_tmp_directory)"
85 + progress "Using ${tmpdir} as a temporary directory."
86 + cd "${tmpdir}" || fatal "Failed to change current working directory to ${tmpdir}." F000A
87 +
88 + case "${SYSTYPE}" in
89 + Linux) install_on_linux ;;
90 + Darwin) install_on_macos ;;
91 + FreeBSD) install_on_freebsd ;;
92 + esac
93 +
94 + if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then
95 + claim
96 + elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ]; then
97 + soft_disable_cloud
98 + fi
99 +
100 + set_auto_updates
101 +
102 + printf >&2 "%s\n\n" "Successfully installed the Netdata Agent."
103 + success_banner
104 + telemetry_event INSTALL_SUCCESS "" ""
105 + cleanup
106 + trap - EXIT
107 +}
108 +
109 # ======================================================================
110 # Usage info
111
@@ -85,12 +132,14 @@ USAGE: kickstart.sh [options]
132 --disable-cloud Disable support for Netdata Cloud (default: detect)
133 --require-cloud Only install if Netdata Cloud can be enabled. Overrides --disable-cloud.
134 --install <path> Specify an installation prefix for local builds (default: autodetect based on system type).
135 + --old-install-prefix <path> Specify an old local builds installation prefix for uninstall/reinstall (if it's not default).
136 --claim-token Use a specified token for claiming to Netdata Cloud.
137 --claim-rooms When claiming, add the node to the specified rooms.
138 --claim-only If there is an existing install, only try to claim it, not update it.
139 --claim-* Specify other options for the claiming script.
140 --no-cleanup Don't do any cleanup steps. This is intended to help with debugging the installer.
141 --uninstall Uninstall an existing installation of Netdata.
142 + --reinstall-clean Clean reinstall Netdata.
143
144 Additionally, this script may use the following environment variables:
145
@@ -602,7 +651,11 @@ uninstall() {
651 get_system_info
652 detect_existing_install
653
605 - export INSTALL_PREFIX="${ndprefix}"
654 + if [ -n "${OLD_INSTALL_PREFIX}" ]; then
655 + INSTALL_PREFIX="$(echo "${OLD_INSTALL_PREFIX}/" | sed 's/$/netdata/g')"
656 + else
657 + INSTALL_PREFIX="${ndprefix}"
658 + fi
659
660 uninstaller="${INSTALL_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh"
661 uninstaller_url="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/netdata-uninstaller.sh"
@@ -1654,9 +1707,16 @@ while [ -n "${1}" ]; do
1707 INSTALL_PREFIX="${2}"
1708 shift 1
1709 ;;
1710 + "--old-install-prefix")
1711 + OLD_INSTALL_PREFIX="${2}"
1712 + shift 1
1713 + ;;
1714 "--uninstall")
1715 ACTION="uninstall"
1716 ;;
1717 + "--reinstall-clean")
1718 + ACTION="reinstall-clean"
1719 + ;;
1720 "--native-only")
1721 NETDATA_ONLY_NATIVE=1
1722 NETDATA_ONLY_STATIC=0
@@ -1715,36 +1775,8 @@ confirm_root_support
1775 get_system_info
1776 confirm_install_prefix
1777
1718 -tmpdir="$(create_tmp_directory)"
1719 -progress "Using ${tmpdir} as a temporary directory."
1720 -cd "${tmpdir}" || fatal "Failed to change current working directory to ${tmpdir}." F000A
1721 -
1722 -if [ "${ACTION}" = "uninstall" ]; then
1723 - uninstall
1724 - printf >&2 "Finished uninstalling the Netdata Agent."
1725 - cleanup
1726 - trap - EXIT
1727 - exit 0
1728 -fi
1729 -
1730 -handle_existing_install
1731 -
1732 -case "${SYSTYPE}" in
1733 - Linux) install_on_linux ;;
1734 - Darwin) install_on_macos ;;
1735 - FreeBSD) install_on_freebsd ;;
1736 -esac
1737 -
1738 -if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then
1739 - claim
1740 -elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ]; then
1741 - soft_disable_cloud
1778 +if [ -z "${ACTION}" ]; then
1779 + handle_existing_install
1780 fi
1781
1744 -set_auto_updates
1745 -
1746 -printf >&2 "%s\n\n" "Successfully installed the Netdata Agent."
1747 -success_banner
1748 -telemetry_event INSTALL_SUCCESS "" ""
1749 -cleanup
1750 -trap - EXIT
1782 +main
packaging/installer/methods/kickstart.md
+3
@@ -64,6 +64,9 @@ The `kickstart.sh` script accepts a number of optional parameters to control how
64 use runtime configuration to disable cloud support.
65 - `--require-cloud`: Only install if Netdata Cloud can be enabled. Overrides `--disable-cloud`.
66 - `--install`: Specify an installation prefix for local builds (by default, we use a sane prefix based on the type of system).
67 +- `--old-install-prefix`: Specify the custom local build's installation prefix that should be removed.
68 +- `--uninstall`: Uninstall an existing installation of Netdata.
69 +- `--reinstall-clean`: Performs an uninstall of Netdata and clean installation.
70
71 Additionally, the following environment variables may be used to further customize how the script runs (most users
72 should not need to use special values for any of these):