Skip to main content
Topic: Installed netdata but no rc scripts available (Read 272 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Installed netdata but no rc scripts available

I installed "netdata" but there are no rc scripts to start the service.
On Devuan i have a script /etc/init.d/netdata to start the service.
I think i must write my own script, note netdata is launched as user netdata which cannot login.

Re: Installed netdata but no rc scripts available

Reply #1
This is the devuan script, it's looks easy,
Code: [Select]
#!/bin/sh
### BEGIN INIT INFO
# Provides:          netdata
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Should-Start:      $syslog
# Should-Stop:       $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Real-time charts for system monitoring
# Description:       Start netdata, a real-time monitoring tool
### END INIT INFO

# Documentation
#  man netdata
#  file:///usr/share/doc/netdata/html/index.html
#  https://github.com/netdata/netdata

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
. /lib/lsb/init-functions

NAME=netdata
PIDFILE=/run/netdata.pid
DAEMON=/usr/sbin/$NAME
DAEMON_USER=$NAME
DAEMON_ARGS="-P $PIDFILE"

# Exit if executable is not installed
[ -x "$DAEMON" ] || exit 0

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="the netdata daemon"
CONF_FNAME=/etc/netdata/netdata.conf

STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}"

case "$1" in
  start)
if [ ! -f "$CONF_FNAME" ]; then
log_action_msg "Not starting $DESC: $CONF_FNAME is missing."
exit 0
fi

log_action_begin_msg "Starting $DESC"

if start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --test; then
if start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON -- $DAEMON_ARGS; then
log_action_end_msg 0
else
log_action_end_msg 1
exit 1
fi
else
log_action_end_msg 0 "already running"
fi
;;
 

Re: Installed netdata but no rc scripts available

Reply #2
Please, put the script in code tags. You can convert most systemd service files to openrc using http://openrc.run/:
Code: [Select]
#!/sbin/openrc-run

name=$RC_SVCNAME
description="Real time performance monitoring"
supervisor="supervise-daemon"
command="/usr/bin/netdata"
command_args="-D $EXTRA_OPTS"
supervise_daemon_args=" -N 0"
command_user="netdata:netdata"

depend() {
after net httpd squid nfs-server mysqld mysql named postfix chronyd
}