summaryrefslogtreecommitdiffstats
path: root/system/install-service.sh.in
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2022-10-19 07:11:09 -0400
committerGitHub <noreply@github.com>2022-10-19 07:11:09 -0400
commitb5e1e3690c9a8e59abe3a3a247ce7906f3259053 (patch)
tree82c12c6411acde46f78c16bfc754c37c348fc127 /system/install-service.sh.in
parent05ef3a0c55747ab41abe5e2459d787d9a43a4416 (diff)
Properly guard commands when installing services for offline service managers. (#13848)
Diffstat (limited to 'system/install-service.sh.in')
-rwxr-xr-xsystem/install-service.sh.in16
1 files changed, 11 insertions, 5 deletions
diff --git a/system/install-service.sh.in b/system/install-service.sh.in
index 28bce124c8..59cff0a083 100755
--- a/system/install-service.sh.in
+++ b/system/install-service.sh.in
@@ -243,7 +243,9 @@ install_systemd_service() {
fi
if [ "${ENABLE}" = "auto" ]; then
- IS_NETDATA_ENABLED="$(systemctl is-enabled netdata 2> /dev/null || echo "Netdata not there")"
+ if [ "$(check_systemd)" = "YES" ]; then
+ IS_NETDATA_ENABLED="$(systemctl is-enabled netdata 2> /dev/null || echo "Netdata not there")"
+ fi
if [ "${IS_NETDATA_ENABLED}" = "disabled" ]; then
ENABLE="disable"
@@ -258,7 +260,7 @@ install_systemd_service() {
exit 4
fi
- if check_systemd; then
+ if [ "$(check_systemd)" = "YES" ]; then
if ! systemctl daemon-reload; then
warning "Failed to reload systemd unit files."
fi
@@ -270,7 +272,7 @@ install_systemd_service() {
}
systemd_cmds() {
- if check_systemd; then
+ if [ "$(check_systemd)" = "YES" ]; then
NETDATA_START_CMD='systemctl start netdata'
NETDATA_STOP_CMD='systemctl stop netdata'
else # systemd is not running, use external defaults by providing no commands
@@ -316,8 +318,12 @@ check_openrc() {
}
enable_openrc() {
- runlevel="$(rc-status -r)"
+ if [ "$(check_openrc)" = "YES" ]; then
+ runlevel="$(rc-status -r)"
+ fi
+
runlevel="${runlevel:-default}"
+
if ! rc-update add netdata "${runlevel}"; then
warning "Failed to enable Netdata service in runlevel ${runlevel}."
fi
@@ -339,7 +345,7 @@ install_openrc_service() {
}
openrc_cmds() {
- if check_openrc; then
+ if [ "$(check_openrc)" = "YES" ]; then
NETDATA_START_CMD='rc-service netdata start'
NETDATA_STOP_CMD='rc-service netdata stop'
else # Not booted using OpenRC, use external defaults by not providing commands.