]> arthur.barton.de Git - netdata.git/commitdiff
Update Gentoo related files
authorJustin Lecher <jlec@gentoo.org>
Sun, 3 Apr 2016 12:42:41 +0000 (13:42 +0100)
committerJustin Lecher <jlec@gentoo.org>
Sun, 3 Apr 2016 13:07:16 +0000 (14:07 +0100)
* 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>
build/subst.inc
netdata-9999.ebuild
system/Makefile.am
system/netdata-openrc [deleted file]
system/netdata-openrc.in [new file with mode: 0755]

index 18743abb72787fb40f0774edadac1e0285fddff3..99cac7f4f56b4c96dcc8d91be7aac9046e3bfe71 100644 (file)
@@ -2,6 +2,7 @@
        if sed \
                -e 's#[@]localstatedir_POST@#$(localstatedir)#g' \
                -e 's#[@]sbindir_POST@#$(sbindir)#g' \
+               -e 's#[@]sysconfdir_POST@#$(sysconfdir)#g' \
                $< > $@.tmp; then \
                mv "$@.tmp" "$@"; \
        else \
index 414ff99719845e13ba1c3aff8935c92c418d6628..1a4b3ba7316796a7f5ad849b75db9690d7ad7bf5 100644 (file)
@@ -8,38 +8,33 @@ inherit linux-info systemd user
 
 if [[ ${PV} == "9999" ]] ; then
        EGIT_REPO_URI="git://github.com/firehol/${PN}.git"
-       EGIT_BRANCH="master"
        inherit git-r3 autotools
        SRC_URI=""
        KEYWORDS=""
 else
        SRC_URI="http://firehol.org/download/${PN}/releases/v${PV}/${P}.tar.xz"
+       KEYWORDS="~amd64 ~x86"
 fi
 
 
-DESCRIPTION="Linux real time system monitoring, over the web!"
-HOMEPAGE="https://github.com/firehol/netdata"
+DESCRIPTION="Linux real time system monitoring, done right!"
+HOMEPAGE="https://github.com/firehol/netdata http://netdata.firehol.org/"
 
-LICENSE="GPL-3+"
+LICENSE="GPL-3+ MIT BSD"
 SLOT="0"
-KEYWORDS="~amd64 ~x86"
-IUSE="+zlib nfacct nodejs"
+IUSE="+compression nfacct nodejs"
 
 # most unconditional dependencies are for plugins.d/charts.d.plugin:
-RDEPEND=">=app-shells/bash-4
-       sys-apps/sed
-       sys-apps/grep
-       virtual/awk
+RDEPEND="
+       >=app-shells/bash-4:0
        net-misc/curl
        net-misc/wget
-       
-       zlib? ( sys-libs/zlib )
-       
+       virtual/awk
+       compression? ( sys-libs/zlib )
        nfacct? (
                net-firewall/nfacct
                net-libs/libmnl
        )
-
        nodejs? (
                net-libs/nodejs
        )"
@@ -52,6 +47,8 @@ CONFIG_CHECK="
        ~KSM
 "
 
+: ${NETDATA_USER:=netdata}
+
 pkg_setup() {
        linux-info_pkg_setup
 
@@ -59,34 +56,59 @@ pkg_setup() {
        enewuser ${PN} -1 -1 / ${PN}
 }
 
-src_unpack() {
-       if [[ ${PV} == "9999" ]] ; then
-               git-r3_src_unpack
-       fi
-       default
-}
-
 src_prepare() {
-       if [[ ${PV} == "9999" ]] ; then
-               eautoreconf
-       fi
        default
+       [[ ${PV} == "9999" ]] && eautoreconf
 }
 
 src_configure() {
        econf \
                --localstatedir=/var \
+               --with-user=${NETDATA_USER} \
                $(use_enable nfacct plugin-nfacct) \
-               $(use_with zlib) \
-               --with-user=${PN} \
-               || die "configure failed"
+               $(use_with compression zlib)
 }
 
 src_install() {
        default
 
-       fowners ${PN} /var/log/netdata
+       fowners ${NETDATA_USER} /var/log/netdata
+
+       chown -Rc ${NETDATA_USER} "${ED}"/usr/share/${PN} || die
+
+       cat >> "${T}"/${PN}-sysctl <<- EOF
+       kernel.mm.ksm.run = 1
+       kernel.mm.ksm.sleep_millisecs = 1000
+       EOF
+
+       dodoc "${T}"/${PN}-sysctl
 
        newinitd system/netdata-openrc ${PN}
        systemd_dounit system/netdata.service
 }
+
+pkg_postinst() {
+       if [[ -e "/sys/kernel/mm/ksm/run" ]]; then
+               elog "INFORMATION:"
+               echo ""
+               elog "I see you have kernel memory de-duper (called Kernel Same-page Merging,"
+               elog "or KSM) available, but it is not currently enabled."
+               echo ""
+               elog "To enable it run:"
+               echo ""
+               elog "echo 1 >/sys/kernel/mm/ksm/run"
+               elog "echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs"
+               echo  ""
+               elog "If you enable it, you will save 20-60% of netdata memory."
+       else
+               elog "INFORMATION:"
+               echo ""
+               elog "I see you do not have kernel memory de-duper (called Kernel Same-page"
+               elog "Merging, or KSM) available."
+               echo ""
+               elog "To enable it, you need a kernel built with CONFIG_KSM=y"
+               echo ""
+               elog "If you can have it, you will save 20-60% of netdata memory."
+       fi
+
+}
index 88da5341a19e4e137d54995cb07a1c99159c7240..c917a2298e0c194d02835e5b021d2943e39ffc8f 100644 (file)
@@ -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 (executable)
index 202db64..0000000
+++ /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 (executable)
index 0000000..8ac87f8
--- /dev/null
@@ -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 $?
+}