| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | |
| 4 | # PROVIDE: netdata |
| 5 | # REQUIRE: DAEMON NETWORKING |
| 6 | # BEFORE: LOGIN |
| 7 | # KEYWORD: shutdown |
| 8 | |
| 9 | . /etc/rc.subr |
| 10 | |
| 11 | name=netdata |
| 12 | rcvar=netdata_enable |
| 13 | |
| 14 | piddir="@localstatedir_POST@/run/netdata" |
| 15 | pidfile="${piddir}/netdata.pid" |
| 16 | |
| 17 | command="@sbindir_POST@/netdata" |
| 18 | command_args="-P ${pidfile}" |
| 19 | |
| 20 | required_files="@configdir_POST@/netdata.conf" |
| 21 | |
| 22 | start_precmd="netdata_prestart" |
| 23 | stop_postcmd="netdata_poststop" |
| 24 | |
| 25 | extra_commands="reloadhealth" |
| 26 | |
| 27 | reloadhealth_cmd="netdata_reloadhealth" |
| 28 | |
| 29 | netdata_prestart() |
| 30 | { |
| 31 | [ ! -d "${piddir}" ] && mkdir -p "${piddir}" |
| 32 | chown @netdata_user_POST@:@netdata_user_POST@ "${piddir}" |
| 33 | return 0 |
| 34 | } |
| 35 | |
| 36 | netdata_poststop() |
| 37 | { |
| 38 | [ -f "${pidfile}" ] && rm "${pidfile}" |
| 39 | return 0 |
| 40 | } |
| 41 | |
| 42 | netdata_reloadhealth() |
| 43 | { |
| 44 | p=`cat ${pidfile}` |
| 45 | kill -USR2 ${p} && echo "Sent USR2 (reload health) to pid ${p}" |
| 46 | return 0 |
| 47 | } |
| 48 | |
| 49 | load_rc_config $name |
| 50 | run_rc_command "$1" |