summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorJustin Lecher <jlec@gentoo.org>2016-04-03 13:42:41 +0100
committerJustin Lecher <jlec@gentoo.org>2016-04-03 14:07:16 +0100
commit00fe19f2b1f744b893c805f63b6638b7f0558961 (patch)
treedbd4607bd637992770f13ec33e335778efa6d0fc /system
parent292277aa30cf8b940e64e647fa2087dae5488887 (diff)
Update Gentoo related files
* Properly replace install destination at buildtime in init script * Ebuild: - Add note about KSM - Drop KEYWORDS in live ebuild - Strip down calls which equal default - Set DESCRIPTION to GH slogan - Rename USE zlib to compression - Drop additional die - Allow to change NETDATA_USER in make.conf * Clean openrc init script Signed-off-by: Justin Lecher <jlec@gentoo.org>
Diffstat (limited to 'system')
-rw-r--r--system/Makefile.am4
-rwxr-xr-xsystem/netdata-openrc125
-rwxr-xr-xsystem/netdata-openrc.in83
3 files changed, 86 insertions, 126 deletions
diff --git a/system/Makefile.am b/system/Makefile.am
index 88da5341a1..c917a2298e 100644
--- a/system/Makefile.am
+++ b/system/Makefile.am
@@ -3,6 +3,7 @@
#
MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
CLEANFILES = \
+ netdata-openrc \
netdata.service \
$(NULL)
@@ -11,10 +12,11 @@ include $(top_srcdir)/build/subst.inc
SUFFIXES = .in
nodist_noinst_DATA = \
+ netdata-openrc \
netdata.service \
$(NULL)
dist_noinst_DATA = \
- netdata-openrc \
+ netdata-openrc.in \
netdata.service.in \
$(NULL)
diff --git a/system/netdata-openrc b/system/netdata-openrc
deleted file mode 100755
index 202db64c0b..0000000000
--- a/system/netdata-openrc
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/sbin/runscript
-
-# The path netdata has been installed.
-# Leave it empty if netdata is installed in /
-NETDATA_INSTALL_PATH=${NETDATA_INSTALL_PATH-}
-
-# The user netdata is configured to run as.
-# If you edit its configuration file to set a different
-# user, set it here too, to have its files switch ownership
-NETDATA_OWNER=${NETDATA_OWNER-netdata:netdata}
-
-# The URL to download netdata config.
-NETDATA_CONFIG_URL=${NETDATA_CONFIG_URL-http://localhost:19999/netdata.conf}
-
-# The timeout in seconds to wait for netdata
-# to save its database on disk and exit.
-NETDATA_WAIT_EXIT_TIMEOUT=${NETDATA_WAIT_EXIT_TIMEOUT-15}
-
-# When set to 1, if netdata does not exit in
-# NETDATA_WAIT_EXIT_TIMEOUT, we will force it
-# to exit.
-NETDATA_FORCE_EXIT=${NETDATA_FORCE_EXIT-0}
-
-# Netdata will use these services, only if they
-# are enabled to start.
-NETDATA_START_AFTER_SERVICES="${NETDATA_START_AFTER_SERVICES-apache2 squid nginx mysql named opensips upsd hostapd postfix lm_sensors}"
-
-extra_started_commands="getconf"
-pidfile="/var/run/netdata/netdata.pid"
-command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
-command_background="yes"
-
-depend() {
- use logger
- need net
-
- local x
- for x in ${NETDATA_START_AFTER_SERVICES}
- do
- if [ -f /etc/runlevels/default/${x} ]
- then
- use ${x}
- fi
- done
-}
-
-start() {
- local ret
-
- if [ ! -d ${NETDATA_INSTALL_PATH}/var/cache/netdata ]
- then
- ebegin "Creating ${NETDATA_INSTALL_PATH}/var/cache/netdata"
- mkdir -p ${NETDATA_INSTALL_PATH}/var/cache/netdata
- chown ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
- echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
- eend $?
- fi
-
- if [ "$(cat ${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner 2>/dev/null)" != "${NETDATA_OWNER}" ]
- then
- ebegin "Switching ownership of ${NETDATA_INSTALL_PATH}/var/cache/netdata"
- chown -R ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
- echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
- eend 0
- fi
-
- ebegin "Starting netdata"
- start-stop-daemon --start --quiet --pidfile ${pidfile} --exec ${command} -- ${NETDATA_EXTRA_ARGS}
- ret=$?
- eend $ret
-
- if [ $ret -eq 0 -a ! -f ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf ]
- then
- ebegin "Downloading default configuration to ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
- sleep 2
- curl -s -o ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
- ret=$?
- if [ $ret -eq 0 -a -s ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ]
- then
- mv ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf
- else
- ret=1
- rm ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new 2>/dev/null
- fi
- eend $ret
- fi
-}
-
-stop() {
- local result ret=0 count=0 sigkill=0
-
- ebegin "Stopping netdata"
- start-stop-daemon --stop --quiet --pidfile ${pidfile}
- result=$?
- eend $result
-
- ebegin "Waiting for netdata to save its database"
- while [ -f "${pidfile}" ]
- do
- if [ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]
- then
- sigkill=1
- break
- fi
-
- count=$[count + 1]
- kill -0 $(cat ${pidfile}) 2>/dev/null
- ret=$?
- test $ret -eq 0 && sleep 1
- done
- eend $sigkill
-
- if [ $sigkill -eq 1 -a -f "${pidfile}" ]
- then
- ebegin "Netdata is taking too long to exit, forcing it to quit"
- kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
- eend $?
- fi
-}
-
-getconf() {
- ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
- curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"
- eend $?
-}
diff --git a/system/netdata-openrc.in b/system/netdata-openrc.in
new file mode 100755
index 0000000000..8ac87f869e
--- /dev/null
+++ b/system/netdata-openrc.in
@@ -0,0 +1,83 @@
+#!/sbin/runscript
+
+# The user netdata is configured to run as.
+# If you edit its configuration file to set a different
+# user, set it here too, to have its files switch ownership
+: ${NETDATA_OWNER:=netdata:netdata}
+
+# The URL to download netdata config.
+: ${NETDATA_CONFIG_URL:=http://localhost:19999/netdata.conf}
+
+# The timeout in seconds to wait for netdata
+# to save its database on disk and exit.
+: ${NETDATA_WAIT_EXIT_TIMEOUT:=15}
+
+# When set to 1, if netdata does not exit in
+# NETDATA_WAIT_EXIT_TIMEOUT, we will force it
+# to exit.
+: ${NETDATA_FORCE_EXIT:=0}
+
+# Netdata will use these services, only if they
+# are enabled to start.
+: ${NETDATA_START_AFTER_SERVICES:=apache2 squid nginx mysql named opensips upsd hostapd postfix lm_sensors}
+
+extra_started_commands="getconf"
+pidfile="/run/netdata/netdata.pid"
+command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
+command_background="yes"
+command_args="${NETDATA_EXTRA_ARGS}"
+start_stop_daemon_args="-u ${NETDATA_OWNER}"
+
+depend() {
+ use logger
+ need net
+ after ${NETDATA_START_AFTER_SERVICES}
+
+ checkpath -o ${NETDATA_OWNER} -d @localstatedir_POST@/cache/netdata /run/netdata
+}
+
+start_post() {
+ if [[ ! -f @sysconfdir_POST@/netdata/netdata.conf ]]; then
+ ebegin "Downloading default configuration to @sysconfdir_POST@/netdata/netdata.conf"
+ sleep 2
+ curl -s -o @sysconfdir_POST@/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
+ ret=$?
+ if [[ $ret -eq 0 && -s @sysconfdir_POST@/netdata/netdata.conf.new ]]; then
+ mv @sysconfdir_POST@/netdata/netdata.conf{.new,}
+ else
+ ret=1
+ rm @sysconfdir_POST@/netdata/netdata.conf.new 2>/dev/null
+ fi
+ eend $ret
+ fi
+}
+
+stop_post() {
+ local result ret=0 count=0 sigkill=0
+
+ ebegin "Waiting for netdata to save its database"
+ while [[ -f "${pidfile}" ]]; do
+ if [[ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]]; then
+ sigkill=1
+ break
+ fi
+
+ count=$[count + 1]
+ kill -0 $(cat ${pidfile}) 2>/dev/null
+ ret=$?
+ test $ret -eq 0 && sleep 1
+ done
+ eend $sigkill
+
+ if [[ $sigkill -eq 1 && -f "${pidfile}" ]]; then
+ ebegin "Netdata is taking too long to exit, forcing it to quit"
+ kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
+ eend $?
+ fi
+}
+
+getconf() {
+ ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
+ curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"
+ eend $?
+}