]> arthur.barton.de Git - netdata.git/commitdiff
install /etc/init.d/netdata on certain servers
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 5 Nov 2016 01:47:37 +0000 (03:47 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 5 Nov 2016 01:47:37 +0000 (03:47 +0200)
netdata-installer.sh

index e5e2da82506097c97a8bf6d81b6355de6f83d00a..ae831fe77df661776b7ca3c8e9f64d55bb6d0b94 100755 (executable)
@@ -806,6 +806,49 @@ issystemd() {
     return 1
 }
 
+installed_init_d=0
+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
+            run cp system/netdata-openrc /etc/init.d/netdata && \
+            run chmod 755 /etc/init.d/netdata && \
+            run rc-update add netdata default && \
+            installed_init_d=1
+        
+        elif [ "${key}" = "ubuntu-12.04" -o "${key}" = "ubuntu-14.04" ]
+            then
+            run cp system/netdata-lsb /etc/init.d/netdata && \
+            run chmod 755 /etc/init.d/netdata && \
+            run update-rc.d netdata enable && \
+            installed_init_d=1
+
+        elif [ "${key}" = "CentOS release 6.8 (Final)" ]
+            then
+            run cp system/netdata-init-d /etc/init.d/netdata && \
+            run chmod 755 /etc/init.d/netdata && \
+            run chkconfig netdata on && \
+            installed_init_d=1
+        fi
+    fi
+
+    return 0
+}
+
 started=0
 if [ "${UID}" -eq 0 ]
     then
@@ -826,6 +869,8 @@ if [ "${UID}" -eq 0 ]
 
         stop_all_netdata
         service netdata restart && started=1
+    else
+        install_non_systemd_init
     fi
 
     if [ ${started} -eq 0 ]
@@ -1070,6 +1115,12 @@ if [ -f /etc/systemd/system/netdata.service ]
     rm -i /etc/systemd/system/netdata.service
 fi
 
+if [ -f /etc/init.d/netdata ]
+    then
+    echo "Deleting /etc/init.d/netdata ..."
+    rm -i /etc/init.d/netdata
+fi
+
 getent passwd netdata > /dev/null
 if [ $? -eq 0 ]
     then