@cryptotaxi247 / netdata-1 / commits / da7f215ad

Overhaul handling of auto-updates in the installer code. (#12076)

* Bundle updater script in native packages. * Move code for enabling/disabling auto-updates to netdata-updater.sh This lets us handle the logic sanely from the kickstart script regardless of the install method, and allows users to more reliably toggle auto-updates themselves without having to understand what is being done. * Add proper case-agnosticism to auto-update type selection. * Move auto-updater handling code to kickstart script. * Properly handle running against an older source tree. * First part of updater docmentation updates. * Fixed handling of updater in DEB packages. * Further documentation updates. * Minor typo fixes.

Austin S. Hemmelgarn committed Feb 18, 2022 at 10:08 UTC da7f215ad6c98cbf54ab93dbc1d2457ac01dbb08
9 files changed +268 -124
contrib/debian/rules
+8
@@ -75,6 +75,10 @@ override_dh_install:
75 mkdir -p "$(TOP)/var/cache/netdata"
76 mkdir -p "$(TOP)/var/run/netdata"
77
78 + # Copy the updater script
79 + #
80 + cp -v packaging/installer/netdata-updater.sh $(TOP)/usr/libexec/netdata/netdata-updater.sh
81 +
82 # Move files that local user shouldn't be editing to /usr/share/netdata
83 #
84 mkdir -p "$(TOP)/usr/share/netdata/www"
@@ -108,6 +112,10 @@ override_dh_installdocs:
112 override_dh_fixperms:
113 dh_fixperms
114
115 + # Updater script should be executable
116 + #
117 + chmod 0755 $(TOP)/usr/libexec/netdata/netdata-updater.sh
118 +
119 # apps.plugin should only be runnable by the netdata user. It will be
120 # given extra capabilities in the postinst script.
121 #
netdata-installer.sh
+2 -24
@@ -226,9 +226,6 @@ USAGE: ${PROGRAM} [options]
226 --install <path> Install netdata in <path>. Ex. --install /opt will put netdata in /opt/netdata.
227 --dont-start-it Do not (re)start netdata after installation.
228 --dont-wait Run installation in non-interactive mode.
229 - --auto-update or -u Install netdata-updater in cron to automatically check for updates once per day.
230 - --auto-update-type Override the auto-update scheduling mechanism detection, currently supported types
231 - are: systemd, interval, crontab.
229 --stable-channel Use packages from GitHub release pages instead of nightly updates.
230 This results in less frequent updates.
231 --nightly-channel Use most recent nightly updates instead of GitHub releases.
@@ -301,7 +298,6 @@ HEREDOC
298
299 DONOTSTART=0
300 DONOTWAIT=0
304 -AUTOUPDATE=0
301 NETDATA_PREFIX=
302 LIBS_ARE_HERE=0
303 NETDATA_ENABLE_ML=""
@@ -319,19 +315,8 @@ while [ -n "${1}" ]; do
315 "--dont-scrub-cflags-even-though-it-may-break-things") DONT_SCRUB_CFLAGS_EVEN_THOUGH_IT_MAY_BREAK_THINGS=1 ;;
316 "--dont-start-it") DONOTSTART=1 ;;
317 "--dont-wait") DONOTWAIT=1 ;;
322 - "--auto-update" | "-u") AUTOUPDATE=1 ;;
323 - "--auto-update-type")
324 - AUTO_UPDATE_TYPE="$(echo "${2}" | tr '[:upper:]' '[:lower:]')"
325 - case "${AUTO_UPDATE_TYPE}" in
326 - systemd|interval|crontab)
327 - shift 1
328 - ;;
329 - *)
330 - echo "Unrecognized value for --auto-update-type. Valid values are: systemd, interval, crontab"
331 - exit 1
332 - ;;
333 - esac
334 - ;;
318 + "--auto-update" | "-u") ;;
319 + "--auto-update-type") ;;
320 "--stable-channel") RELEASE_CHANNEL="stable" ;;
321 "--nightly-channel") RELEASE_CHANNEL="nightly" ;;
322 "--enable-plugin-freeipmi") NETDATA_CONFIGURE_OPTIONS="$(echo "${NETDATA_CONFIGURE_OPTIONS%--enable-plugin-freeipmi)}" | sed 's/$/ --enable-plugin-freeipmi/g')" ;;
@@ -1896,13 +1881,6 @@ progress "Installing (but not enabling) the netdata updater tool"
1881 cleanup_old_netdata_updater || run_failed "Cannot cleanup old netdata updater tool."
1882 install_netdata_updater || run_failed "Cannot install netdata updater tool."
1883
1899 -progress "Check if we must enable/disable the netdata updater tool"
1900 -if [ "${AUTOUPDATE}" = "1" ]; then
1901 - enable_netdata_updater "${AUTO_UPDATE_TYPE}" || run_failed "Cannot enable netdata updater tool"
1902 -else
1903 - disable_netdata_updater || run_failed "Cannot disable netdata updater tool"
1904 -fi
1905 -
1884 # -----------------------------------------------------------------------------
1885 progress "Wrap up environment set up"
1886
netdata.spec.in
+6
@@ -270,6 +270,10 @@ rm -rf "${RPM_BUILD_ROOT}"
270
271 install -m 644 -p system/netdata.conf "${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}"
272
273 +# ###########################################################
274 +# Install updater script
275 +install -m 755 -p packaging/installer/netdata-updater.sh "${RPM_BUILD_ROOT}%{_libexecdir}/%{name}/netdata-updater.sh"
276 +
277 # ###########################################################
278 # logrotate settings
279 install -m 755 -d "${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d"
@@ -544,6 +548,8 @@ are sensor monitoring, system event monitoring, power control, and serial-over-L
548 %attr(4750,root,netdata) %{_libexecdir}/%{name}/plugins.d/freeipmi.plugin
549
550 %changelog
551 +* Wed Feb 03 2022 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-16
552 +- Bundle updater script in native packages.
553 * Mon Oct 11 2021 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-15
554 - Remove support code for legacy ACLK implementation.
555 * Wed Sep 16 2020 Austin Hemmelgarn <austin@netdata.cloud> 0.0.0-14
packaging/installer/UPDATE.md
+53 -15
@@ -6,8 +6,9 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/packaging/instal
6
7 # Update the Netdata Agent
8
9 -By default, the Netdata Agent automatically updates with the latest nightly version. If you opted out of automatic
10 -updates, you need to update your Netdata Agent to the latest nightly or stable version.
9 +By default, the Netdata Agent automatically updates with the latest nightly or stable version depending on which
10 +you installed. If you opted out of automatic updates, you need to update your Netdata Agent to the latest nightly
11 +or stable version. You can also [enable or disable automatic updates on an existing install](#control-automatic-updates).
12
13 > 💡 Looking to reinstall the Netdata Agent to enable a feature, update an Agent that cannot update automatically, or
14 > troubleshoot an error during the installation process? See our [reinstallation doc](/packaging/installer/REINSTALL.md)
@@ -20,28 +21,35 @@ icon in the local Agent dashboard's top navigation. This modal informs you wheth
21
22 ## Determine which installation method you used
23
24 +Starting with netdata v1.33.0, you can use Netdata itself to determine the installation type by running:
25 +
26 +```bash
27 +netdata -W buildinfo | grep 'Install type:'
28 +```
29 +
30 +If this produces no output, you have an older install and will have to manually look in the Netdata config directory.
31 If you are not sure where your Netdata config directory is, see the [configuration doc](/docs/configure/nodes.md). In
32 most installations, this is `/etc/netdata`.
33
34 Use `cd` to navigate to the Netdata config directory, then use `ls -a` to look for a file called `.install-type`.
35
36 - If the `.install-type` file doex not exist, look for a file in the same directory called `.environment`.
29 - - If the `.environment` file does not exist, you probably installed Netdata using your system package manager
30 - and should update it the same way you would run updates on the system itself.
31 - - If the `.environment` file does exist, then our [regular update method](#updates-for-most-systems) should
32 - work correctly.
37 + - If the `.environment` file does not exist, then you have a ‘custom’ install.
38 + - If the `.environment` file does exist, then you have either a ‘static’ or ‘build’ install.
39 - If the `.install-type` file does exist, check it’s contents with `cat .install-type`.
34 - - If the `INSTALL_TYPE` key has a value of `custom`, you probably installed Netdata using your system
35 - package manager and should update it the same way you would run updates on the system itself.
36 - - If the `INSTALL_TYPE` key has a value of `oci`, the install is from a Docker image.
37 - - Otherwise, the install should work with our [regular update method](#updates-for-most-systems).
40 + - The value of the `INSTALL_TYPE` key indicates what type of install you have.
41
39 -Next, use the appropriate method to update the Netdata Agent:
42 +The exact update method to use depends on the install type:
43
41 -- [Updates for most systems](#updates-for-most-systems)
42 -- [Docker](#docker)
43 -- [macOS](#macos)
44 -- [Manual installation from Git](#manual-installation-from-git)
44 +- Installs with an install type of 'custom' usually indicate installing a third-party package through the system
45 + package manager. To update these installs, you should update the package just like you would any other package
46 + on your system.
47 +- Installs with an install type starting with `binpkg` or ending with `build` or `static` can be updated using
48 + our [regular update method](#updates-for-most-systems).
49 +- Installs with an install type of 'oci' were created from our official Docker images, and should be updated
50 + using our [Docker](#docker) update procedure.
51 +- macOS users should check [our update instructions for macOS](#macos).
52 +- Manually built installs should check [our update instructions for manual builds](#manual-installation-from-git).
53
54 ## Updates for most systems
55
@@ -95,6 +103,9 @@ Homebrew downloads the latest Netdata via the
103 [formulae](https://github.com/Homebrew/homebrew-core/blob/master/Formula/netdata.rb), ensures all dependencies are met,
104 and updates Netdata via reinstallation.
105
106 +If you instead installed Netdata using our one-line installation script, you can use our [regular update
107 +instructions](#updates-for-most-systems) to update Netdata.
108 +
109 ## Manual installation from Git
110
111 If you installed [Netdata manually from Git](/packaging/installer/methods/manual.md), you can run that installer again
@@ -117,4 +128,31 @@ sudo ./netdata-installer.sh
128 > ⚠️ If you installed Netdata with any optional parameters, such as `--no-updates` to disable automatic updates, and
129 > want to retain those settings, you need to set them again during this process.
130
131 +## Control automatic updates
132 +
133 +Starting with Netdata v1.34.0, you can easily enable or disable automatic updates on an existing installation
134 +using the updater script.
135 +
136 +For most installs on Linux, you can enable auto-updates with:
137 +
138 +```bash
139 +/usr/libexec/netdata/netdata-updater.sh --enable-auto-updates
140 +```
141 +
142 +and disable them with:
143
144 +```bash
145 +/usr/libexec/netdata/netdata-updater.sh --disable-auto-updates
146 +```
147 +
148 +For static installs, instead use:
149 +
150 +```bash
151 +/opt/netdata/usr/libexec/netdata/netdata-updater.sh --enable-auto-updates
152 +```
153 +
154 +and:
155 +
156 +```bash
157 +/opt/netdata/usr/libexec/netdata/netdata-updater.sh --disable-auto-updates
158 +```
packaging/installer/functions.sh
-70
@@ -968,76 +968,6 @@ cleanup_old_netdata_updater() {
968 return 0
969 }
970
971 -enable_netdata_updater() {
972 -
973 - if [ -n "${1}" ] ; then
974 - updater_type="${1}"
975 - else
976 - updater_type="$(_get_scheduler_type)"
977 - fi
978 -
979 - case "${updater_type}" in
980 - "systemd")
981 - systemctl enable netdata-updater.timer
982 -
983 - echo >&2 "Auto-updating has been enabled using a systemd timer unit."
984 - echo >&2
985 - echo >&2 "If the update process fails, the failure will be logged to the systemd journal just like a regular service failure."
986 - echo >&2 "Successful updates should produce empty logs."
987 - echo >&2
988 - ;;
989 - "interval")
990 - ln -sf "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-updater.sh" "$(_get_intervaldir)/netdata-updater"
991 -
992 - echo >&2 "Auto-updating has been enabled through cron, updater script linked to ${TPUT_RED}${TPUT_BOLD}$(_get_intervaldir)/netdata-updater${TPUT_RESET}"
993 - echo >&2
994 - echo >&2 "If the update process fails and you have email notifications set up correctly for cron on this system, you should receive an email notification of the failure."
995 - echo >&2 "Successful updates will not send an email."
996 - echo >&2
997 - ;;
998 - "crontab")
999 - cat "${NETDATA_SOURCE_DIR}/system/netdata.crontab" > "/etc/cron.d/netdata-updater"
1000 -
1001 - echo >&2 "Auto-updating has been enabled through cron, using a crontab at ${TPUT_RED}${TPUT_BOLD}/etc/cron.d/netdata-updater${TPUT_RESET}"
1002 - echo >&2
1003 - echo >&2 "If the update process fails and you have email notifications set up correctly for cron on this system, you should receive an email notification of the failure."
1004 - echo >&2 "Successful updates will not send an email."
1005 - echo >&2
1006 - ;;
1007 - *)
1008 - echo >&2 "Unable to determine what type of auto-update scheduling to use, not enabling auto-updates."
1009 - echo >&2
1010 - return 1
1011 - esac
1012 -
1013 - return 0
1014 -}
1015 -
1016 -disable_netdata_updater() {
1017 - 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)"
1018 - echo >&2
1019 -
1020 - if issystemd && [ -n "$(get_systemd_service_dir)" ] ; then
1021 - systemctl disable netdata-updater.timer
1022 - fi
1023 -
1024 - if [ -d /etc/cron.daily ]; then
1025 - rm -f /etc/cron.daily/netdata-updater.sh
1026 - rm -f /etc/cron.daily/netdata-updater
1027 - fi
1028 -
1029 - if [ -d /etc/periodic/daily ]; then
1030 - rm -f /etc/periodic/daily/netdata-updater.sh
1031 - rm -f /etc/periodic/daily/netdata-updater
1032 - fi
1033 -
1034 - if [ -d /etc/cron.d ]; then
1035 - rm -f /etc/cron.d/netdata-updater
1036 - fi
1037 -
1038 - return 0
1039 -}
1040 -
971 set_netdata_updater_channel() {
972 sed -i -e "s/^RELEASE_CHANNEL=.*/RELEASE_CHANNEL=\"${RELEASE_CHANNEL}\"/" "${NETDATA_USER_CONFIG_DIR}/.environment"
973 }
packaging/installer/kickstart.sh
+41 -1
@@ -64,8 +64,9 @@ USAGE: kickstart.sh [options]
64 --dont-start-it Do not start the agent by default (only for static installs or local builds)
65 --stable-channel Install a stable version instead of a nightly build (default: install a nightly build)
66 --nightly-channel Install a nightly build instead of a stable version
67 - --no-updates Do not enable automatic updates (default: enable automatic updates)
67 + --no-updates Do not enable automatic updates (default: enable automatic updates using the best supported scheduling method)
68 --auto-update Enable automatic updates.
69 + --auto-update-type Specify a particular scheduling type for auto-updates (valid types: systemd, interval, crontab)
70 --disable-telemetry Opt-out of anonymous statistics.
71 --native-only Only install if native binary packages are available.
72 --static-only Only install if a static build is available.
@@ -784,6 +785,30 @@ claim() {
785 fi
786 }
787
788 +# ======================================================================
789 +# Auto-update handling code.
790 +set_auto_updates() {
791 + if [ -x "${INSTALL_PREFIX}/usr/libexec/netdata/netdata-updater.sh" ]; then
792 + updater="${INSTALL_PREFIX}/usr/libexec/netdata/netdata-updater.sh"
793 + elif [ -x "${INSTALL_PREFIX}/netdata/usr/libexec/netdata/netdata-updater.sh" ]; then
794 + updater="${INSTALL_PREFIX}/netdata/usr/libexec/netdata/netdata-updater.sh"
795 + else
796 + warning "Could not find netdata-updater.sh."
797 + return 0
798 + fi
799 +
800 + if [ "${NETDATA_AUTO_UPDATES}" = "1" ]; then
801 + # This first case is for catching using a new kickstart script with an old build. It can be safely removed after v1.34.0 is released.
802 + if grep -qv '--enable-auto-updates' ${updater}; then
803 + echo
804 + elif ! ${updater} --enable-auto-updates "${NETDATA_AUTO_UPDATE_TYPE}"; then
805 + error "Failed to enable auto updates. Netdata will still work, but you will need to update manually."
806 + fi
807 + else
808 + ${updater} --disable-auto-updates
809 + fi
810 +}
811 +
812 # ======================================================================
813 # Native package install code.
814
@@ -1228,6 +1253,7 @@ install_on_linux() {
1253 case "$?" in
1254 0)
1255 NETDATA_INSTALL_SUCCESSFUL=1
1256 + INSTALL_PREFIX="/"
1257 ;;
1258 1)
1259 fatal "Unable to install on this system." F0300
@@ -1342,6 +1368,18 @@ while [ -n "${1}" ]; do
1368 "--stable-channel") RELEASE_CHANNEL="stable" ;;
1369 "--no-updates") NETDATA_AUTO_UPDATES=0 ;;
1370 "--auto-update") NETDATA_AUTO_UPDATES="1" ;;
1371 + "--auto-update-method")
1372 + NETDATA_AUTO_UPDATE_TYPE="$(echo "${2}" | tr '[:upper:]' '[:lower:]')"
1373 + case "${NETDATA_AUTO_UPDATE_TYPE}" in
1374 + systemd|interval|crontab)
1375 + shift 1
1376 + ;;
1377 + *)
1378 + echo "Unrecognized value for --auto-update-type. Valid values are: systemd, interval, crontab"
1379 + exit 1
1380 + ;;
1381 + esac
1382 + ;;
1383 "--reinstall") NETDATA_REINSTALL=1 ;;
1384 "--reinstall-even-if-unsafe") NETDATA_UNSAFE_REINSTALL=1 ;;
1385 "--claim-only") NETDATA_CLAIM_ONLY=1 ;;
@@ -1441,6 +1479,8 @@ elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ]; then
1479 soft_disable_cloud
1480 fi
1481
1482 +set_auto_updates
1483 +
1484 telemetry_event INSTALL_SUCCESS "" ""
1485 cleanup
1486 trap - EXIT
packaging/installer/methods/kickstart.md
+1 -1
@@ -140,7 +140,7 @@ To use `md5sum` to verify the integrity of the `kickstart.sh` script you will do
140 run the following:
141
142 ```bash
143 -[ "373053d7b715af0d9c30e479a6c53809" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
143 +[ "5d558c5a86050ec267f126fbe40df0ec" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
144 ```
145
146 If the script is valid, this command will return `OK, VALID`.
packaging/installer/netdata-updater.sh
+156 -1
@@ -73,6 +73,142 @@ if [ "${ENVIRONMENT_FILE}" = "THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT" ]; th
73 fi
74 fi
75
76 +issystemd() {
77 + # if the directory /lib/systemd/system OR /usr/lib/systemd/system (SLES 12.x) does not exit, it is not systemd
78 + if [ ! -d /lib/systemd/system ] && [ ! -d /usr/lib/systemd/system ]; then
79 + return 1
80 + fi
81 +
82 + # if there is no systemctl command, it is not systemd
83 + systemctl=$(command -v systemctl 2> /dev/null)
84 + if [ -z "${systemctl}" ] || [ ! -x "${systemctl}" ]; then
85 + return 1
86 + fi
87 +
88 + # if pid 1 is systemd, it is systemd
89 + [ "$(basename "$(readlink /proc/1/exe)" 2> /dev/null)" = "systemd" ] && return 0
90 +
91 + # if systemd is not running, it is not systemd
92 + pids=$(safe_pidof systemd 2> /dev/null)
93 + [ -z "${pids}" ] && return 1
94 +
95 + # check if the running systemd processes are not in our namespace
96 + myns="$(readlink /proc/self/ns/pid 2> /dev/null)"
97 + for p in ${pids}; do
98 + ns="$(readlink "/proc/${p}/ns/pid" 2> /dev/null)"
99 +
100 + # if pid of systemd is in our namespace, it is systemd
101 + [ -n "${myns}" ] && [ "${myns}" = "${ns}" ] && return 0
102 + done
103 +
104 + # else, it is not systemd
105 + return 1
106 +}
107 +
108 +_get_scheduler_type() {
109 + if _get_intervaldir > /dev/null ; then
110 + echo 'interval'
111 + elif issystemd ; then
112 + echo 'systemd'
113 + elif [ -d /etc/cron.d ] ; then
114 + echo 'crontab'
115 + else
116 + echo 'none'
117 + fi
118 +}
119 +
120 +_get_intervaldir() {
121 + if [ -d /etc/cron.daily ]; then
122 + echo /etc/cron.daily
123 + elif [ -d /etc/periodic/daily ]; then
124 + echo /etc/periodic/daily
125 + else
126 + return 1
127 + fi
128 +
129 + return 0
130 +}
131 +
132 +enable_netdata_updater() {
133 + if [ -n "${1}" ] ; then
134 + updater_type="${1}"
135 + else
136 + updater_type="$(_get_scheduler_type)"
137 + fi
138 +
139 + case "${updater_type}" in
140 + "systemd")
141 + if issystemd; then
142 + systemctl enable netdata-updater.timer
143 +
144 + info "Auto-updating has been ENABLED using a systemd timer unit.\n"
145 + info "If the update process fails, the failure will be logged to the systemd journal just like a regular service failure."
146 + info "Successful updates should produce empty logs."
147 + else
148 + error "Systemd-based auto-update scheduling requested, but this does not appear to be a systemd system."
149 + error "Auto-updates have NOT been enabled."
150 + return 1
151 + fi
152 + ;;
153 + "interval")
154 + if _get_intervaldir > /dev/null; then
155 + ln -sf "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-updater.sh" "$(_get_intervaldir)/netdata-updater"
156 +
157 + info "Auto-updating has been ENABLED through cron, updater script linked to $(_get_intervaldir)/netdata-updater\n"
158 + info "If the update process fails and you have email notifications set up correctly for cron on this system, you should receive an email notification of the failure."
159 + info "Successful updates will not send an email."
160 + else
161 + error "Interval-based auto-update scheduling requested, but I could not find an interval scheduling directory."
162 + error "Auto-updates have NOT been enabled."
163 + return 1
164 + fi
165 + ;;
166 + "crontab")
167 + if [ -d "/etc/cron.d" ]; then
168 + cat "${NETDATA_SOURCE_DIR}/system/netdata.crontab" > "/etc/cron.d/netdata-updater"
169 +
170 + info "Auto-updating has been ENABLED through cron, using a crontab at /etc/cron.d/netdata-updater\n"
171 + info "If the update process fails and you have email notifications set up correctly for cron on this system, you should receive an email notification of the failure."
172 + info "Successful updates will not send an email."
173 + else
174 + error "Crontab-based auto-update scheduling requested, but there is no '/etc/cron.d'."
175 + error "Auto-updates have NOT been enabled."
176 + return 1
177 + fi
178 + ;;
179 + *)
180 + error "Unable to determine what type of auto-update scheduling to use."
181 + error "Auto-updates have NOT been enabled."
182 + return 1
183 + esac
184 +
185 + return 0
186 +}
187 +
188 +disable_netdata_updater() {
189 + if issystemd && ( systemctl list-units --full -all | grep -Fq "netdata-updater.timer" ) ; then
190 + systemctl disable netdata-updater.timer
191 + fi
192 +
193 + if [ -d /etc/cron.daily ]; then
194 + rm -f /etc/cron.daily/netdata-updater.sh
195 + rm -f /etc/cron.daily/netdata-updater
196 + fi
197 +
198 + if [ -d /etc/periodic/daily ]; then
199 + rm -f /etc/periodic/daily/netdata-updater.sh
200 + rm -f /etc/periodic/daily/netdata-updater
201 + fi
202 +
203 + if [ -d /etc/cron.d ]; then
204 + rm -f /etc/cron.d/netdata-updater
205 + fi
206 +
207 + info "Auto-updates have been DISABLED."
208 +
209 + return 0
210 +}
211 +
212 str_in_list() {
213 printf "%s\n" "${2}" | tr ' ' "\n" | grep -qE "^${1}\$"
214 return $?
@@ -584,6 +720,25 @@ while [ -n "${1}" ]; do
720 elif [ "${1}" = "--tmpdir-path" ]; then
721 NETDATA_TMPDIR_PATH="${2}"
722 shift 2
723 + elif [ "${1}" = "--enable-auto-updates" ]; then
724 + AUTO_UPDATE_TYPE="$(echo "${2}" | tr '[:upper:]' '[:lower:]')"
725 + case "${AUTO_UPDATE_TYPE}" in
726 + systemd|interval|crontab)
727 + enable_netdata_updater "${AUTO_UPDATE_TYPE}"
728 + exit $?
729 + ;;
730 + "")
731 + enable_netdata_updater ""
732 + exit $?
733 + ;;
734 + *)
735 + error "Unrecognized updater type ${2} requested. Supported types are 'systemd', 'interval', and 'crontab'."
736 + exit 1
737 + ;;
738 + esac
739 + elif [ "${1}" = "--disable-auto-updates" ]; then
740 + disable_netdata_updater
741 + exit $?
742 else
743 break
744 fi
@@ -653,7 +808,7 @@ case "${INSTALL_TYPE}" in
808 update_legacy
809 ;;
810 custom)
656 - # At this point, we _should_ have a valid `.environment` file, but it0s best to just check.
811 + # At this point, we _should_ have a valid `.environment` file, but it's best to just check.
812 # If we do, then behave like the legacy updater.
813 if [ -n "${RELEASE_CHANNEL}" ] && [ -n "${NETDATA_PREFIX}" ] && [ -n "${REINSTALL_OPTIONS}" ]; then
814 update_legacy
packaging/makeself/install-or-update.sh
+1 -12
@@ -26,7 +26,6 @@ if [ -d /opt/netdata/etc/netdata.old ]; then
26 fi
27
28 STARTIT=1
29 -AUTOUPDATE=0
29 REINSTALL_OPTIONS=""
30 RELEASE_CHANNEL="nightly" # check .travis/create_artifacts.sh before modifying
31
@@ -36,10 +35,7 @@ while [ "${1}" ]; do
35 STARTIT=0
36 REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
37 ;;
39 - "--auto-update" | "-u")
40 - AUTOUPDATE=1
41 - REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
42 - ;;
38 + "--auto-update" | "-u") ;;
39 "--stable-channel")
40 RELEASE_CHANNEL="stable"
41 REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
@@ -161,13 +157,6 @@ progress "Install (but not enable) netdata updater tool"
157 cleanup_old_netdata_updater || run_failed "Cannot cleanup old netdata updater tool."
158 install_netdata_updater || run_failed "Cannot install netdata updater tool."
159
164 -progress "Check if we must enable/disable the netdata updater tool"
165 -if [ "${AUTOUPDATE}" = "1" ]; then
166 - enable_netdata_updater || run_failed "Cannot enable netdata updater tool"
167 -else
168 - disable_netdata_updater || run_failed "Cannot disable netdata updater tool"
169 -fi
170 -
160 # -----------------------------------------------------------------------------
161 progress "creating quick links"
162