diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-03-27 02:36:03 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-03-27 02:36:03 +0300 |
commit | d3aa6e735805ec2cd2fea664a6309d52b4ab59e0 (patch) | |
tree | ae8b5815916d111d71d6e045764171b1cd482434 /installer | |
parent | 547fd9f2b85a2591322cd93d641dd3b2948a4a1f (diff) |
move init installation to functions.sh
Diffstat (limited to 'installer')
-rw-r--r-- | installer/functions.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/installer/functions.sh b/installer/functions.sh index 36d10ec70a..dac82119c8 100644 --- a/installer/functions.sh +++ b/installer/functions.sh @@ -342,3 +342,81 @@ issystemd() { # else, it is not systemd return 1 } + +install_non_systemd_init() { + [ "${UID}" != 0 ] && return 1 + + local key="unknown" + if [ -f /etc/os-release ] + then + source /etc/os-release || return 1 + key="${ID}-${VERSION_ID}" + + elif [ -f /etc/centos-release ] + then + key=$(</etc/centos-release) + fi + + if [ -d /etc/init.d -a ! -f /etc/init.d/netdata ] + then + if [ "${key}" = "gentoo" ] + then + echo >&2 "Installing OpenRC init file..." + run cp system/netdata-openrc /etc/init.d/netdata && \ + run chmod 755 /etc/init.d/netdata && \ + run rc-update add netdata default && \ + return 0 + + elif [ "${key}" = "ubuntu-12.04" -o "${key}" = "ubuntu-14.04" -o "${key}" = "debian-7" ] + then + echo >&2 "Installing LSB init file..." + run cp system/netdata-lsb /etc/init.d/netdata && \ + run chmod 755 /etc/init.d/netdata && \ + run update-rc.d netdata defaults && \ + run update-rc.d netdata enable && \ + return 0 + + elif [ "${key}" = "CentOS release 6.8 (Final)" -o "${key}" = "amzn-2016.09" ] + then + echo >&2 "Installing init.d file..." + run cp system/netdata-init-d /etc/init.d/netdata && \ + run chmod 755 /etc/init.d/netdata && \ + run chkconfig netdata on && \ + return 0 + else + echo >&2 "I don't know what init file to install on system '${key}'. Open a github issue to help us fix it." + return 1 + fi + elif [ -f /etc/init.d/netdata ] + then + echo >&2 "file '/etc/init.d/netdata' already exists." + return 0 + else + echo >&2 "I don't know what init file to install on system '${key}'. Open a github issue to help us fix it." + fi + + return 1 +} + +install_netdata_service() { + if issystemd + then + # systemd is running on this system + if [ ! -f /etc/systemd/system/netdata.service ] + then + echo >&2 "Installing systemd service..." + run cp system/netdata.service /etc/systemd/system/netdata.service && \ + run systemctl daemon-reload && \ + run systemctl enable netdata && \ + return 0 + else + echo >&2 "file '/etc/systemd/system/netdata.service' already exists." + return 0 + fi + else + install_non_systemd_init + return $? + fi + + return 1 +} |