Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from netdata:master #302

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions packaging/installer/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,22 @@ issystemd() {
}

get_systemd_service_dir() {
if [ -w "/lib/systemd/system" ]; then
echo "/lib/systemd/system"
elif [ -w "/usr/lib/systemd/system" ]; then
echo "/usr/lib/systemd/system"
elif [ -w "/etc/systemd/system" ]; then
echo "/etc/systemd/system"
unit_paths="$(systemctl show -p UnitPath | cut -f 2- -d '=' | tr ' ' '\n')"

if [ -n "${unit_paths}" ]; then
lib_paths="$(echo "${unit_paths}" | grep -vE '^/(run|etc)' | awk '{line[NR] = $0} END {for (i = NR; i > 0; i--) print line[i]}')"
etc_paths="$(echo "${unit_paths}" | grep -E '^/etc' | grep -vE '(attached|control)$')"
else
lib_paths="/usr/lib/systemd/system /lib/systemd/system /usr/local/lib/systemd/system"
etc_paths="/etc/systemd/system"
fi

for path in ${lib_paths} ${etc_paths}; do
if [ -d "${path}" ] && [ -w "${path}" ]; then
echo "${path}"
return 0
fi
done
}

run_install_service_script() {
Expand Down
53 changes: 35 additions & 18 deletions packaging/installer/netdata-uninstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -731,27 +731,45 @@ if [ "$(uname -s)" = "Darwin" ]; then
fi

#### REMOVE NETDATA FILES

# Handle updater files first so that it doesn’t try to run while we
# are uninstalling things.
if [ -x "${NETDATA_PREFIX}/usr/libexec/netdata-updater.sh" ]; then
"${NETDATA_PREFIX}/usr/libexec/netdata-updater.sh" --disable-auto-updates
else
rm_file /etc/periodic/daily/netdata-updater
rm_file /etc/cron.daily/netdata-updater
rm_file /etc/cron.d/netdata-updater
rm_file /etc/cron.d/netdata-updater-daily
fi

if issystemd; then
for unit in netdata.service netdata-updater.timer; do
systemctl disable "${unit}"
systemctl stop "${unit}"
done

for unit in netdata.service netdata-updater.service netdata-updater.timer; do
unit_path="$(systemctl show -p FragmentPath "${unit}" | cut -f 2- -d '=')"
override_paths="$(systemctl show -p DropInPaths "${unit}" | cut -f 2- -d '=')"
for path in "${unit_path}" ${override_paths} ; do
rm_file "${path}"
done
done

rm_file /usr/lib/systemd/[email protected]/netdata.conf
rm_file /lib/systemd/[email protected]/netdata.conf
rm_dir /usr/lib/systemd/[email protected]/
rm_file /usr/lib/systemd/system-preset/50-netdata.preset
rm_file /lib/systemd/system-preset/50-netdata.preset

systemctl daemon-reload
fi

rm_file /etc/logrotate.d/netdata
rm_file /usr/lib/systemd/[email protected]/netdata.conf
rm_file /etc/systemd/system/netdata.service
rm_file /lib/systemd/system/netdata.service
rm_file /usr/lib/systemd/system/netdata.service
rm_file /etc/systemd/system/netdata-updater.service
rm_file /lib/systemd/system/netdata-updater.service
rm_file /usr/lib/systemd/system/netdata-updater.service
rm_file /etc/systemd/system/netdata-updater.timer
rm_file /lib/systemd/system/netdata-updater.timer
rm_file /usr/lib/systemd/system/netdata-updater.timer
rm_file /usr/lib/systemd/system-preset/50-netdata.preset
rm_file /lib/systemd/system-preset/50-netdata.preset
rm_file /etc/init.d/netdata
rm_file /etc/periodic/daily/netdata-updater
rm_file /etc/cron.daily/netdata-updater
rm_file /etc/cron.d/netdata-updater
rm_file /etc/cron.d/netdata-updater-daily
rm_file /Library/LaunchDaemons/com.github.netdata.plist


if [ -n "${NETDATA_PREFIX}" ] && [ -d "${NETDATA_PREFIX}" ] && [ "netdata" = "$(basename "$NETDATA_PREFIX")" ] ; then
rm_dir "${NETDATA_PREFIX}"
else
Expand All @@ -768,7 +786,6 @@ else
rm_dir "${NETDATA_PREFIX}/var/cache/netdata"
rm_dir "${NETDATA_PREFIX}/var/log/netdata"
rm_dir "${NETDATA_PREFIX}/etc/netdata"
rm_dir /usr/lib/systemd/[email protected]/
fi

if [ -n "${tmpdir}" ]; then
Expand Down
29 changes: 22 additions & 7 deletions packaging/installer/netdata-updater.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ issystemd() {
return 1
}

systemd_unit_exists() {
if systemctl list-unit-files "${1}" 2>&1 | tail -n 1 | grep -qv '^0 '; then
return 0
else
return 1
fi
}

# shellcheck disable=SC2009
running_under_anacron() {
pid="${1:-$$}"
Expand Down Expand Up @@ -307,11 +315,17 @@ enable_netdata_updater() {
case "${updater_type}" in
"systemd")
if issystemd; then
systemctl enable netdata-updater.timer

info "Auto-updating has been ENABLED using a systemd timer unit.\n"
info "If the update process fails, the failure will be logged to the systemd journal just like a regular service failure."
info "Successful updates should produce empty logs."
if systemd_unit_exists netdata-updater.timer; then
systemctl enable netdata-updater.timer
systemctl start netdata-updater.timer

info "Auto-updating has been ENABLED using a systemd timer unit.\n"
info "If the update process fails, the failure will be logged to the systemd journal just like a regular service failure."
info "Successful updates should produce empty logs."
else
error "Systemd-based auto-update scheduling requested, but the required timer unit does not exist. Auto-updates have NOT been enabled."
return 1
fi
else
error "Systemd-based auto-update scheduling requested, but this does not appear to be a systemd system. Auto-updates have NOT been enabled."
return 1
Expand Down Expand Up @@ -351,8 +365,9 @@ enable_netdata_updater() {
}

disable_netdata_updater() {
if issystemd && ( systemctl list-units --full -all | grep -Fq "netdata-updater.timer" ) ; then
if issystemd && systemd_unit_exists "netdata-updater.timer" ; then
systemctl disable netdata-updater.timer
systemctl stop netdata-updater.timer
fi

if [ -d /etc/cron.daily ]; then
Expand Down Expand Up @@ -387,7 +402,7 @@ auto_update_status() {
enabled=""

if issystemd; then
if systemctl list-units --full -all | grep -Fq "netdata-updater.timer"; then
if systemd_unit_exists "netdata-updater.timer"; then
if systemctl is-enabled netdata-updater.timer; then
info "Auto-updates using a systemd timer unit are ENABLED"
enabled="systemd"
Expand Down
2 changes: 1 addition & 1 deletion packaging/windows/package-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi

${GITHUB_ACTIONS+echo "::group::Licenses"}
if [ ! -f "/gpl-3.0.txt" ]; then
curl -o /gpl-3.0.txt "https://www.gnu.org/licenses/gpl-3.0.txt"
cp "${repo_root}/LICENSE" /gpl-3.0.txt
fi

if [ ! -f "/cloud.txt" ]; then
Expand Down
8 changes: 4 additions & 4 deletions src/web/api/functions/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void global_functions_add(void) {
rrd_function_add_inline(
localhost,
NULL,
"streaming",
"netdata-streaming",
10,
RRDFUNCTIONS_PRIORITY_DEFAULT + 1,
RRDFUNCTIONS_VERSION_DEFAULT,
Expand All @@ -22,7 +22,7 @@ void global_functions_add(void) {
NULL,
"netdata-api-calls",
10,
RRDFUNCTIONS_PRIORITY_DEFAULT + 2,
RRDFUNCTIONS_PRIORITY_DEFAULT + 1,
RRDFUNCTIONS_VERSION_DEFAULT,
RRDFUNCTIONS_PROGRESS_HELP,
"top",
Expand All @@ -44,9 +44,9 @@ void global_functions_add(void) {
rrd_function_add_inline(
localhost,
NULL,
"metrics-cardinality",
"netdata-metrics-cardinality",
10,
RRDFUNCTIONS_PRIORITY_DEFAULT,
RRDFUNCTIONS_PRIORITY_DEFAULT + 1,
RRDFUNCTIONS_VERSION_DEFAULT,
RRDFUNCTIONS_METRICS_CARDINALITY_HELP,
"top",
Expand Down
27 changes: 19 additions & 8 deletions system/install-service.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,27 @@ check_systemd() {
}

get_systemd_service_dir() {
if [ -w "/lib/systemd/system" ]; then
echo "/lib/systemd/system"
elif [ -w "/usr/lib/systemd/system" ]; then
echo "/usr/lib/systemd/system"
elif [ -w "/etc/systemd/system" ]; then
echo "/etc/systemd/system"
set +e
unit_paths="$(systemctl show -p UnitPath | cut -f 2- -d '=' | tr ' ' '\n')"
set -e

if [ -n "${unit_paths}" ]; then
lib_paths="$(echo "${unit_paths}" | grep -vE '^/(run|etc)' | awk '{line[NR] = $0} END {for (i = NR; i > 0; i--) print line[i]}')"
etc_paths="$(echo "${unit_paths}" | grep -E '^/etc' | grep -vE '(attached|control)$')"
else
error "Unable to detect systemd service directory."
exit 4
lib_paths="/usr/lib/systemd/system /lib/systemd/system /usr/local/lib/systemd/system"
etc_paths="/etc/systemd/system"
fi

for path in ${lib_paths} ${etc_paths}; do
if [ -d "${path}" ] && [ -w "${path}" ]; then
echo "${path}"
return 0
fi
done

error "Unable to detect usable systemd service directory."
exit 4
}

install_systemd_service() {
Expand Down
Loading