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
stop_all_netdata
service netdata restart && started=1
+ else
+ install_non_systemd_init
fi
if [ ${started} -eq 0 ]
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