summaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
authorKonstantinos Natsakis <5933427+knatsakis@users.noreply.github.com>2019-11-06 12:50:02 +0200
committerGitHub <noreply@github.com>2019-11-06 12:50:02 +0200
commite3b4a62c1e08ec07a42fb2c780230a0fe7d4537b (patch)
treedcbb8fd5035b4222593854f8b5ade5dc11c680b0 /packaging
parent928c52f73f7f21e6d434bff82b01effedb6010bd (diff)
netdata-installer.sh follow-up based on #7060 review (#7200)
* netdata-installer.sh: Improve message about updater installation * packaging/installer/functions.sh: get_crondir() fails if crondir is not found * packaging/installer/functions.sh: Mark get_crondir and check_crondir_permissions functions as private
Diffstat (limited to 'packaging')
-rw-r--r--packaging/installer/functions.sh34
1 files changed, 18 insertions, 16 deletions
diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh
index 03dd8dc89a..d2b7b67616 100644
--- a/packaging/installer/functions.sh
+++ b/packaging/installer/functions.sh
@@ -728,19 +728,21 @@ safe_sha256sum() {
fi
}
-get_crondir() {
- crondir=
- [ -d "/etc/periodic/daily" ] && crondir="/etc/periodic/daily"
- [ -d "/etc/cron.daily" ] && crondir="/etc/cron.daily"
+_get_crondir() {
+ if [ -d /etc/cron.daily ]; then
+ echo /etc/cron.daily
+ elif [ -d /etc/periodic/daily ]; then
+ echo /etc/periodic/daily
+ else
+ echo >&2 "Cannot figure out the cron directory to handle netdata-updater.sh activation/deactivation"
+ return 1
+ fi
- echo "${crondir}"
+ return 0
}
-check_crondir_permissions() {
- if [ -z "${1}" ]; then
- echo >&2 "Cannot figure out the cron directory to handle netdata-updater.sh activation/deactivation"
- return 1
- elif [ "${UID}" -ne "0" ]; then
+_check_crondir_permissions() {
+ if [ "${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"
return 1
@@ -773,8 +775,8 @@ cleanup_old_netdata_updater() {
rm -f "${NETDATA_PREFIX}"/usr/libexec/netdata-updater.sh
fi
- crondir="$(get_crondir)"
- check_crondir_permissions "${crondir}" || return 1
+ crondir="$(_get_crondir)" || return 1
+ _check_crondir_permissions "${crondir}" || return 1
if [ -f "${crondir}/netdata-updater.sh" ]; then
echo >&2 "Removing incorrect netdata-updater filename in cron"
@@ -785,8 +787,8 @@ cleanup_old_netdata_updater() {
}
enable_netdata_updater() {
- crondir="$(get_crondir)"
- check_crondir_permissions "${crondir}" || return 1
+ crondir="$(_get_crondir)" || return 1
+ _check_crondir_permissions "${crondir}" || return 1
echo >&2 "Adding to cron"
@@ -803,8 +805,8 @@ enable_netdata_updater() {
}
disable_netdata_updater() {
- crondir="$(get_crondir)"
- check_crondir_permissions "${crondir}" || return 1
+ crondir="$(_get_crondir)" || return 1
+ _check_crondir_permissions "${crondir}" || return 1
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