@cryptotaxi247 / netdata-1 / commits / 00fe19f2b

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>

Justin Lecher committed Apr 3, 2016 at 13:42 UTC 00fe19f2b1f744b893c805f63b6638b7f0558961
5 files changed +137 -154
build/subst.inc
+1
@@ -2,6 +2,7 @@
2 if sed \
3 -e 's#[@]localstatedir_POST@#$(localstatedir)#g' \
4 -e 's#[@]sbindir_POST@#$(sbindir)#g' \
5 + -e 's#[@]sysconfdir_POST@#$(sysconfdir)#g' \
6 $< > $@.tmp; then \
7 mv "$@.tmp" "$@"; \
8 else \
netdata-9999.ebuild
+50 -28
@@ -8,38 +8,33 @@ inherit linux-info systemd user
8
9 if [[ ${PV} == "9999" ]] ; then
10 EGIT_REPO_URI="git://github.com/firehol/${PN}.git"
11 - EGIT_BRANCH="master"
11 inherit git-r3 autotools
12 SRC_URI=""
13 KEYWORDS=""
14 else
15 SRC_URI="http://firehol.org/download/${PN}/releases/v${PV}/${P}.tar.xz"
16 + KEYWORDS="~amd64 ~x86"
17 fi
18
19
20 -DESCRIPTION="Linux real time system monitoring, over the web!"
21 -HOMEPAGE="https://github.com/firehol/netdata"
20 +DESCRIPTION="Linux real time system monitoring, done right!"
21 +HOMEPAGE="https://github.com/firehol/netdata http://netdata.firehol.org/"
22
23 -LICENSE="GPL-3+"
23 +LICENSE="GPL-3+ MIT BSD"
24 SLOT="0"
25 -KEYWORDS="~amd64 ~x86"
26 -IUSE="+zlib nfacct nodejs"
25 +IUSE="+compression nfacct nodejs"
26
27 # most unconditional dependencies are for plugins.d/charts.d.plugin:
29 -RDEPEND=">=app-shells/bash-4
30 - sys-apps/sed
31 - sys-apps/grep
32 - virtual/awk
28 +RDEPEND="
29 + >=app-shells/bash-4:0
30 net-misc/curl
31 net-misc/wget
35 -
36 - zlib? ( sys-libs/zlib )
37 -
32 + virtual/awk
33 + compression? ( sys-libs/zlib )
34 nfacct? (
35 net-firewall/nfacct
36 net-libs/libmnl
37 )
42 -
38 nodejs? (
39 net-libs/nodejs
40 )"
@@ -52,6 +47,8 @@ CONFIG_CHECK="
47 ~KSM
48 "
49
50 +: ${NETDATA_USER:=netdata}
51 +
52 pkg_setup() {
53 linux-info_pkg_setup
54
@@ -59,34 +56,59 @@ pkg_setup() {
56 enewuser ${PN} -1 -1 / ${PN}
57 }
58
62 -src_unpack() {
63 - if [[ ${PV} == "9999" ]] ; then
64 - git-r3_src_unpack
65 - fi
66 - default
67 -}
68 -
59 src_prepare() {
70 - if [[ ${PV} == "9999" ]] ; then
71 - eautoreconf
72 - fi
60 default
61 + [[ ${PV} == "9999" ]] && eautoreconf
62 }
63
64 src_configure() {
65 econf \
66 --localstatedir=/var \
67 + --with-user=${NETDATA_USER} \
68 $(use_enable nfacct plugin-nfacct) \
80 - $(use_with zlib) \
81 - --with-user=${PN} \
82 - || die "configure failed"
69 + $(use_with compression zlib)
70 }
71
72 src_install() {
73 default
74
88 - fowners ${PN} /var/log/netdata
75 + fowners ${NETDATA_USER} /var/log/netdata
76 +
77 + chown -Rc ${NETDATA_USER} "${ED}"/usr/share/${PN} || die
78 +
79 + cat >> "${T}"/${PN}-sysctl <<- EOF
80 + kernel.mm.ksm.run = 1
81 + kernel.mm.ksm.sleep_millisecs = 1000
82 + EOF
83 +
84 + dodoc "${T}"/${PN}-sysctl
85
86 newinitd system/netdata-openrc ${PN}
87 systemd_dounit system/netdata.service
88 }
89 +
90 +pkg_postinst() {
91 + if [[ -e "/sys/kernel/mm/ksm/run" ]]; then
92 + elog "INFORMATION:"
93 + echo ""
94 + elog "I see you have kernel memory de-duper (called Kernel Same-page Merging,"
95 + elog "or KSM) available, but it is not currently enabled."
96 + echo ""
97 + elog "To enable it run:"
98 + echo ""
99 + elog "echo 1 >/sys/kernel/mm/ksm/run"
100 + elog "echo 1000 >/sys/kernel/mm/ksm/sleep_millisecs"
101 + echo ""
102 + elog "If you enable it, you will save 20-60% of netdata memory."
103 + else
104 + elog "INFORMATION:"
105 + echo ""
106 + elog "I see you do not have kernel memory de-duper (called Kernel Same-page"
107 + elog "Merging, or KSM) available."
108 + echo ""
109 + elog "To enable it, you need a kernel built with CONFIG_KSM=y"
110 + echo ""
111 + elog "If you can have it, you will save 20-60% of netdata memory."
112 + fi
113 +
114 +}
system/Makefile.am
+3 -1
@@ -3,6 +3,7 @@
3 #
4 MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
5 CLEANFILES = \
6 + netdata-openrc \
7 netdata.service \
8 $(NULL)
9
@@ -11,10 +12,11 @@ include $(top_srcdir)/build/subst.inc
12 SUFFIXES = .in
13
14 nodist_noinst_DATA = \
15 + netdata-openrc \
16 netdata.service \
17 $(NULL)
18
19 dist_noinst_DATA = \
18 - netdata-openrc \
20 + netdata-openrc.in \
21 netdata.service.in \
22 $(NULL)
system/netdata-openrc deleted
-125
@@ -1,125 +0,0 @@
1 -#!/sbin/runscript
2 -
3 -# The path netdata has been installed.
4 -# Leave it empty if netdata is installed in /
5 -NETDATA_INSTALL_PATH=${NETDATA_INSTALL_PATH-}
6 -
7 -# The user netdata is configured to run as.
8 -# If you edit its configuration file to set a different
9 -# user, set it here too, to have its files switch ownership
10 -NETDATA_OWNER=${NETDATA_OWNER-netdata:netdata}
11 -
12 -# The URL to download netdata config.
13 -NETDATA_CONFIG_URL=${NETDATA_CONFIG_URL-http://localhost:19999/netdata.conf}
14 -
15 -# The timeout in seconds to wait for netdata
16 -# to save its database on disk and exit.
17 -NETDATA_WAIT_EXIT_TIMEOUT=${NETDATA_WAIT_EXIT_TIMEOUT-15}
18 -
19 -# When set to 1, if netdata does not exit in
20 -# NETDATA_WAIT_EXIT_TIMEOUT, we will force it
21 -# to exit.
22 -NETDATA_FORCE_EXIT=${NETDATA_FORCE_EXIT-0}
23 -
24 -# Netdata will use these services, only if they
25 -# are enabled to start.
26 -NETDATA_START_AFTER_SERVICES="${NETDATA_START_AFTER_SERVICES-apache2 squid nginx mysql named opensips upsd hostapd postfix lm_sensors}"
27 -
28 -extra_started_commands="getconf"
29 -pidfile="/var/run/netdata/netdata.pid"
30 -command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
31 -command_background="yes"
32 -
33 -depend() {
34 - use logger
35 - need net
36 -
37 - local x
38 - for x in ${NETDATA_START_AFTER_SERVICES}
39 - do
40 - if [ -f /etc/runlevels/default/${x} ]
41 - then
42 - use ${x}
43 - fi
44 - done
45 -}
46 -
47 -start() {
48 - local ret
49 -
50 - if [ ! -d ${NETDATA_INSTALL_PATH}/var/cache/netdata ]
51 - then
52 - ebegin "Creating ${NETDATA_INSTALL_PATH}/var/cache/netdata"
53 - mkdir -p ${NETDATA_INSTALL_PATH}/var/cache/netdata
54 - chown ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
55 - echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
56 - eend $?
57 - fi
58 -
59 - if [ "$(cat ${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner 2>/dev/null)" != "${NETDATA_OWNER}" ]
60 - then
61 - ebegin "Switching ownership of ${NETDATA_INSTALL_PATH}/var/cache/netdata"
62 - chown -R ${NETDATA_OWNER} ${NETDATA_INSTALL_PATH}/var/cache/netdata
63 - echo "${NETDATA_OWNER}" >${NETDATA_INSTALL_PATH}/var/cache/netdata/.last_owner
64 - eend 0
65 - fi
66 -
67 - ebegin "Starting netdata"
68 - start-stop-daemon --start --quiet --pidfile ${pidfile} --exec ${command} -- ${NETDATA_EXTRA_ARGS}
69 - ret=$?
70 - eend $ret
71 -
72 - if [ $ret -eq 0 -a ! -f ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf ]
73 - then
74 - ebegin "Downloading default configuration to ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
75 - sleep 2
76 - curl -s -o ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
77 - ret=$?
78 - if [ $ret -eq 0 -a -s ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ]
79 - then
80 - mv ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf
81 - else
82 - ret=1
83 - rm ${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf.new 2>/dev/null
84 - fi
85 - eend $ret
86 - fi
87 -}
88 -
89 -stop() {
90 - local result ret=0 count=0 sigkill=0
91 -
92 - ebegin "Stopping netdata"
93 - start-stop-daemon --stop --quiet --pidfile ${pidfile}
94 - result=$?
95 - eend $result
96 -
97 - ebegin "Waiting for netdata to save its database"
98 - while [ -f "${pidfile}" ]
99 - do
100 - if [ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]
101 - then
102 - sigkill=1
103 - break
104 - fi
105 -
106 - count=$[count + 1]
107 - kill -0 $(cat ${pidfile}) 2>/dev/null
108 - ret=$?
109 - test $ret -eq 0 && sleep 1
110 - done
111 - eend $sigkill
112 -
113 - if [ $sigkill -eq 1 -a -f "${pidfile}" ]
114 - then
115 - ebegin "Netdata is taking too long to exit, forcing it to quit"
116 - kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
117 - eend $?
118 - fi
119 -}
120 -
121 -getconf() {
122 - ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
123 - curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"
124 - eend $?
125 -}
system/netdata-openrc.in new
+83
@@ -0,0 +1,83 @@
1 +#!/sbin/runscript
2 +
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}
7 +
8 +# The URL to download netdata config.
9 +: ${NETDATA_CONFIG_URL:=http://localhost:19999/netdata.conf}
10 +
11 +# The timeout in seconds to wait for netdata
12 +# to save its database on disk and exit.
13 +: ${NETDATA_WAIT_EXIT_TIMEOUT:=15}
14 +
15 +# When set to 1, if netdata does not exit in
16 +# NETDATA_WAIT_EXIT_TIMEOUT, we will force it
17 +# to exit.
18 +: ${NETDATA_FORCE_EXIT:=0}
19 +
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}
23 +
24 +extra_started_commands="getconf"
25 +pidfile="/run/netdata/netdata.pid"
26 +command="${NETDATA_INSTALL_PATH}/usr/sbin/netdata"
27 +command_background="yes"
28 +command_args="${NETDATA_EXTRA_ARGS}"
29 +start_stop_daemon_args="-u ${NETDATA_OWNER}"
30 +
31 +depend() {
32 + use logger
33 + need net
34 + after ${NETDATA_START_AFTER_SERVICES}
35 +
36 + checkpath -o ${NETDATA_OWNER} -d @localstatedir_POST@/cache/netdata /run/netdata
37 +}
38 +
39 +start_post() {
40 + if [[ ! -f @sysconfdir_POST@/netdata/netdata.conf ]]; then
41 + ebegin "Downloading default configuration to @sysconfdir_POST@/netdata/netdata.conf"
42 + sleep 2
43 + curl -s -o @sysconfdir_POST@/netdata/netdata.conf.new "${NETDATA_CONFIG_URL}"
44 + ret=$?
45 + if [[ $ret -eq 0 && -s @sysconfdir_POST@/netdata/netdata.conf.new ]]; then
46 + mv @sysconfdir_POST@/netdata/netdata.conf{.new,}
47 + else
48 + ret=1
49 + rm @sysconfdir_POST@/netdata/netdata.conf.new 2>/dev/null
50 + fi
51 + eend $ret
52 + fi
53 +}
54 +
55 +stop_post() {
56 + local result ret=0 count=0 sigkill=0
57 +
58 + ebegin "Waiting for netdata to save its database"
59 + while [[ -f "${pidfile}" ]]; do
60 + if [[ $count -gt ${NETDATA_WAIT_EXIT_TIMEOUT} ]]; then
61 + sigkill=1
62 + break
63 + fi
64 +
65 + count=$[count + 1]
66 + kill -0 $(cat ${pidfile}) 2>/dev/null
67 + ret=$?
68 + test $ret -eq 0 && sleep 1
69 + done
70 + eend $sigkill
71 +
72 + if [[ $sigkill -eq 1 && -f "${pidfile}" ]]; then
73 + ebegin "Netdata is taking too long to exit, forcing it to quit"
74 + kill -SIGKILL $(cat ${pidfile}) 2>/dev/null
75 + eend $?
76 + fi
77 +}
78 +
79 +getconf() {
80 + ebegin "Downloading configuration from netdata to /tmp/netdata.conf"
81 + curl -o /tmp/netdata.conf "${NETDATA_CONFIG_URL}"
82 + eend $?
83 +}