3 # The user netdata is configured to run as.
4 # If you edit its configuration file to set a different
5 # user, set it here too, to have its files switch ownership
6 : ${NETDATA_OWNER:=netdata:netdata}
8 # The URL to download netdata config.
9 : ${NETDATA_CONFIG_URL:=http://localhost:19999/netdata.conf}
11 # The timeout in seconds to wait for netdata
12 # to save its database on disk and exit.
13 : ${NETDATA_WAIT_EXIT_TIMEOUT:=15}
15 # When set to 1, if netdata does not exit in
16 # NETDATA_WAIT_EXIT_TIMEOUT, we will force it
18 : ${NETDATA_FORCE_EXIT:=0}
20 # Netdata will use these services, only if they
21 # are enabled to start.
22 : ${NETDATA_START_AFTER_SERVICES:=apache2 squid nginx mysql named opensips upsd hostapd postfix lm_sensors}
24 extra_started_commands="getconf"
25 pidfile="/run/netdata.pid"
26 command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
27 command_background="yes"
28 command_args="-P ${pidfile} ${NETDATA_EXTRA_ARGS}"
29 # start_stop_daemon_args="-u ${NETDATA_OWNER}"
30 start_stop_daemon_args=""
35 after ${NETDATA_START_AFTER_SERVICES}
37 checkpath -o ${NETDATA_OWNER} -d @localstatedir_POST@/cache/netdata /run/netdata
41 if [[ ! -f @sysconfdir_POST@/netdata/netdata.conf ]]; then
42 ebegin "Downloading default configuration to @sysconfdir_POST@/netdata/netdata.conf"
44 curl -s -o @sysconfdir_POST@/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
46 if [[ $ret -eq 0 && -s @sysconfdir_POST@/netdata/netdata.conf.new ]]; then
47 mv @sysconfdir_POST@/netdata/netdata.conf{.new,}
50 rm @sysconfdir_POST@/netdata/netdata.conf.new 2>/dev/null
57 local result ret=0 count=0 sigkill=0
59 ebegin "Waiting for netdata to save its database"
60 while [[ -f "${pidfile}" ]]; do
61 if [[ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]]; then
67 kill -0 $(cat ${pidfile}) 2>/dev/null
69 test $ret -eq 0 && sleep 1
73 if [[ $sigkill -eq 1 && -f "${pidfile}" ]]; then
74 ebegin "Netdata is taking too long to exit, forcing it to quit"
75 kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
81 ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
82 curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"