diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-05-26 21:18:03 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-05-26 21:18:03 +0300 |
commit | dbe9a655193ede02450e555c2db67ceb3cb78fab (patch) | |
tree | c34e04f2ad630f60b1aee6f3dcaed0c748c50e27 /installer | |
parent | 99c0a03df1ef572c3c778f7ae075d7f3ef2810ec (diff) |
give instructions using service or systemctl if they are available
Diffstat (limited to 'installer')
-rw-r--r-- | installer/functions.sh | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/installer/functions.sh b/installer/functions.sh index d1416853bc..a073760ee8 100644 --- a/installer/functions.sh +++ b/installer/functions.sh @@ -120,13 +120,13 @@ systemctl_cmd="$(which_cmd systemctl)" service() { local cmd="${1}" action="${2}" - if [ ! -z "${service_cmd}" ] + if [ ! -z "${systemctl_cmd}" ] then - run "${service_cmd}" "${cmd}" "${action}" + run "${systemctl_cmd}" "${action}" "${cmd}" return $? - elif [ ! -z "${systemctl_cmd}" ] + elif [ ! -z "${service_cmd}" ] then - run "${systemctl_cmd}" "${action}" "${cmd}" + run "${service_cmd}" "${cmd}" "${action}" return $? fi return 1 @@ -442,12 +442,18 @@ install_non_systemd_init() { return 1 } +NETDATA_START_CMD="netdata" +NETDATA_STOP_CMD="killall netdata" + install_netdata_service() { if [ "${UID}" -eq 0 ] then if issystemd then # systemd is running on this system + NETDATA_START_CMD="systemctl start netdata" + NETDATA_STOP_CMD="systemctl stop netdata" + if [ ! -f /etc/systemd/system/netdata.service ] then echo >&2 "Installing systemd service..." @@ -461,7 +467,15 @@ install_netdata_service() { fi else install_non_systemd_init - return $? + local ret=$? + + if [ ${ret} -eq 0 ] + then + NETDATA_START_CMD="service netdata start" + NETDATA_STOP_CMD="service netdata stop" + fi + + return ${ret} fi fi |