added freebsd init file
Costa Tsaousis (ktsaou) committed
Jan 20, 2018 at 18:14 UTC
3827569c309284df52f5c75e48d78affdff2f0c0
3 files changed
+56
-1
installer/functions.sh
+7
-1
@@ -502,9 +502,15 @@ NETDATA_START_CMD="netdata"
502
NETDATA_STOP_CMD="killall netdata"
503
504
install_netdata_service() {
505
+ local uname="$(uname 2>/dev/null)"
506
+
507
if [ "${UID}" -eq 0 ]
508
then
507
- if issystemd
509
+ if [ "${uname}" = "FreeBSD" ]
510
+ then
511
+ run cp system/netdata-freebsd /etc/rc.d/netdata && \
512
+ return 0
513
+ elif issystemd
514
then
515
# systemd is running on this system
516
NETDATA_START_CMD="systemctl start netdata"
system/Makefile.am
+3
@@ -8,6 +8,7 @@ CLEANFILES = \
8
netdata.service \
9
netdata-init-d \
10
netdata-lsb \
11
+ netdata-freebsd \
12
$(NULL)
13
14
include $(top_srcdir)/build/subst.inc
@@ -20,6 +21,7 @@ nodist_noinst_DATA = \
21
netdata.service \
22
netdata-init-d \
23
netdata-lsb \
24
+ netdata-freebsd \
25
$(NULL)
26
27
dist_noinst_DATA = \
@@ -28,5 +30,6 @@ dist_noinst_DATA = \
30
netdata.service.in \
31
netdata-init-d.in \
32
netdata-lsb.in \
33
+ netdata-freebsd.in \
34
netdata.conf \
35
$(NULL)
system/netdata-freebsd.in
new
+46
@@ -0,0 +1,46 @@
1
+#!/bin/sh
2
+
3
+. /etc/rc.subr
4
+
5
+name=netdata
6
+rcvar=netdata_enable
7
+
8
+pidfile="@localstatedir_POST@/run/netdata.pid"
9
+
10
+command="@sbindir_POST@/netdata"
11
+command_args="-P ${pidfile}"
12
+
13
+required_files="@sysconfdir_POST@/netdata/netdata.conf"
14
+
15
+start_precmd="netdata_prestart"
16
+stop_postcmd="netdata_poststop"
17
+
18
+extra_commands="reloadhealth savedb"
19
+
20
+reloadhealth_cmd="netdata_reloadhealth"
21
+savedb_cmd="netdata_savedb"
22
+
23
+netdata_prestart()
24
+{
25
+ return 0
26
+}
27
+
28
+netdata_poststop()
29
+{
30
+ return 0
31
+}
32
+
33
+netdata_reloadhealth()
34
+{
35
+ kill -USR2 `cat ${pidfile}`
36
+ return 0
37
+}
38
+
39
+netdata_savedb()
40
+{
41
+ kill -USR1 `cat ${pidfile}`
42
+ return 0
43
+}
44
+
45
+load_rc_config $name
46
+run_rc_command "$1"