summaryrefslogtreecommitdiffstats
path: root/packaging/installer/functions.sh
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2022-05-23 15:19:07 +0300
committerGitHub <noreply@github.com>2022-05-23 15:19:07 +0300
commit7c6ca406e57925f8f656342446c18855e80963ff (patch)
tree7577cc20cbcd2ca02f954cecd77411e996c21cbb /packaging/installer/functions.sh
parent0197e62098c89e88eab6d1d30ced2a0cdca4dfce (diff)
fix: don't kill Netdata PIDs if successfully stopped Netdata (#12982)
Diffstat (limited to 'packaging/installer/functions.sh')
-rw-r--r--packaging/installer/functions.sh25
1 files changed, 16 insertions, 9 deletions
diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh
index eb23bd83c4..fe2fed7816 100644
--- a/packaging/installer/functions.sh
+++ b/packaging/installer/functions.sh
@@ -640,39 +640,46 @@ netdata_pids() {
}
stop_all_netdata() {
+ stop_success=0
if [ "${UID}" -eq 0 ]; then
- uname="$(uname 2> /dev/null)"
+ uname="$(uname 2>/dev/null)"
# Any of these may fail, but we need to not bail if they do.
if issystemd; then
if systemctl stop netdata; then
+ stop_success=1
sleep 5
fi
elif [ "${uname}" = "Darwin" ]; then
if launchctl stop netdata; then
+ stop_success=1
sleep 5
fi
elif [ "${uname}" = "FreeBSD" ]; then
if /etc/rc.d/netdata stop; then
+ stop_success=1
sleep 5
fi
else
if service netdata stop; then
+ stop_success=1
sleep 5
fi
fi
fi
- if [ -n "$(netdata_pids)" ] && [ -n "$(command -v netdatacli)" ]; then
- netdatacli shutdown-agent
- sleep 20
- fi
+ if [ "$stop_success" = "0" ]; then
+ if [ -n "$(netdata_pids)" ] && [ -n "$(command -v netdatacli)" ]; then
+ netdatacli shutdown-agent
+ sleep 20
+ fi
- for p in $(netdata_pids); do
- # shellcheck disable=SC2086
- stop_netdata_on_pid ${p}
- done
+ for p in $(netdata_pids); do
+ # shellcheck disable=SC2086
+ stop_netdata_on_pid ${p}
+ done
+ fi
}
# -----------------------------------------------------------------------------