install /etc/init.d/netdata on certain servers
Costa Tsaousis (ktsaou) committed
Nov 5, 2016 at 03:47 UTC
91aadf8e7309c3c52ec88f52cc0dda5650f2c746
1 file changed
+51
netdata-installer.sh
+51
@@ -806,6 +806,49 @@ issystemd() {
806
return 1
807
}
808
809
+installed_init_d=0
810
+install_non_systemd_init() {
811
+ [ "${UID}" != 0 ] && return 1
812
+
813
+ local key="unknown"
814
+ if [ -f /etc/os-release ]
815
+ then
816
+ source /etc/os-release || return 1
817
+ key="${ID}-${VERSION_ID}"
818
+
819
+ elif [ -f /etc/centos-release ]
820
+ then
821
+ key=$(</etc/centos-release)
822
+ fi
823
+
824
+ if [ -d /etc/init.d -a ! -f /etc/init.d/netdata ]
825
+ then
826
+ if [ "${key}" = "gentoo" ]
827
+ then
828
+ run cp system/netdata-openrc /etc/init.d/netdata && \
829
+ run chmod 755 /etc/init.d/netdata && \
830
+ run rc-update add netdata default && \
831
+ installed_init_d=1
832
+
833
+ elif [ "${key}" = "ubuntu-12.04" -o "${key}" = "ubuntu-14.04" ]
834
+ then
835
+ run cp system/netdata-lsb /etc/init.d/netdata && \
836
+ run chmod 755 /etc/init.d/netdata && \
837
+ run update-rc.d netdata enable && \
838
+ installed_init_d=1
839
+
840
+ elif [ "${key}" = "CentOS release 6.8 (Final)" ]
841
+ then
842
+ run cp system/netdata-init-d /etc/init.d/netdata && \
843
+ run chmod 755 /etc/init.d/netdata && \
844
+ run chkconfig netdata on && \
845
+ installed_init_d=1
846
+ fi
847
+ fi
848
+
849
+ return 0
850
+}
851
+
852
started=0
853
if [ "${UID}" -eq 0 ]
854
then
@@ -826,6 +869,8 @@ if [ "${UID}" -eq 0 ]
869
870
stop_all_netdata
871
service netdata restart && started=1
872
+ else
873
+ install_non_systemd_init
874
fi
875
876
if [ ${started} -eq 0 ]
@@ -1070,6 +1115,12 @@ if [ -f /etc/systemd/system/netdata.service ]
1115
rm -i /etc/systemd/system/netdata.service
1116
fi
1117
1118
+if [ -f /etc/init.d/netdata ]
1119
+ then
1120
+ echo "Deleting /etc/init.d/netdata ..."
1121
+ rm -i /etc/init.d/netdata
1122
+fi
1123
+
1124
getent passwd netdata > /dev/null
1125
if [ $? -eq 0 ]
1126
then