From: Marcin Krol Date: Mon, 6 Mar 2023 21:37:45 +0000 (+0100) Subject: - added init script for rrdcached X-Git-Url: https://git.tld-linux.org/?a=commitdiff_plain;h=c1c0d670e1b2b5b2cb587d3f0e7a28e3b09a7c80;p=packages%2Frrdtool.git - added init script for rrdcached --- diff --git a/rrdcached.init b/rrdcached.init new file mode 100644 index 0000000..3cf1417 --- /dev/null +++ b/rrdcached.init @@ -0,0 +1,78 @@ +#!/bin/sh +# +# rrdcached This shell script takes care of starting and stopping +# the rrdcached. +# +# chkconfig: 2345 19 81 +# description: It comes by night and sucks the vital essence from your computers. +# + +# Source function library +. /etc/rc.d/init.d/functions + +[ -f /etc/sysconfig/rrdcached ] && . /etc/sysconfig/rrdcached + +# Set defaults if not defined in service config file +RRDCACHED_WRITE_TIMEOUT=${RRDCACHED_WRITE_TIMEOUT:-300} +RRDCACHED_WRITE_DELAY=${RRDCACHED_WRITE_DELAY:-180} +RRDCACHED_WRITE_THREADS=${RRDCACHED_WRITE_THREADS:-4} +RRDCACHED_PID_FILE="/var/run/rrdcached.pid" +RRDCACHED_SOCKET="/var/run/rrdcached.sock" + +start() { + # Check if the service is already running? + if [ -f /var/lock/subsys/rrdcached ]; then + msg_already_running "rrdcached" + return + fi + + msg_starting "rrdcached" + daemon /usr/bin/rrdcached -m 0660 -w ${RRDCACHED_WRITE_TIMEOUT} -z ${RRDCACHED_WRITE_DELAY} -t ${RRDCACHED_WRITE_THREADS} -p ${RRDCACHED_PID_FILE} -l ${RRDCACHED_SOCKET} + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rrdcached +} + +stop() { + if [ ! -f /var/lock/subsys/rrdcached ]; then + msg_not_running "rrdcached" + return + fi + + # Stop daemons. + msg_stopping "rrdcached" + killproc /usr/sbin/rrdcached + rm -f /var/lock/subsys/rrdcached +} + +condrestart() { + if [ ! -f /var/lock/subsys/rrdcached ]; then + msg_not_running "rrdcached" + RETVAL=$1 + return + fi + + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status rrdcached + RETVAL=$? + ;; +*) + msg_usage "$0 {start|stop|restart|status}" + exit 3 + ;; +esac +exit $RETVAL diff --git a/rrdcached.sysconfig b/rrdcached.sysconfig new file mode 100644 index 0000000..a359b53 --- /dev/null +++ b/rrdcached.sysconfig @@ -0,0 +1,8 @@ +# Write interval in seconds +#RRDCACHED_WRITE_TIMEOUT=300 + +# Maximum write delay in seconds +#RRDCACHED_WRITE_DELAY=180 + +# Number of write threads +#RRDCACHED_WRITE_THREADS=4 diff --git a/rrdtool.spec b/rrdtool.spec index d67c280..7d47bc1 100644 --- a/rrdtool.spec +++ b/rrdtool.spec @@ -28,11 +28,13 @@ Summary(ru.UTF-8): RRDtool - база данных с "циклическим о Summary(uk.UTF-8): RRDtool - це система зберігання та показу серійних даних Name: rrdtool Version: 1.8.0 -Release: 1 +Release: 0.1 License: GPL v2+ + FLOSS exception Group: Applications/Databases Source0: https://github.com/oetiker/rrdtool-1.x/releases/download/v%{version}/%{name}-%{version}.tar.gz # Source0-md5: 852754364cbd0703a099b5eb32932851 +Source1: rrdcached.init +Source2: rrdcached.sysconfig Patch0: %{name}-tcl-path.patch Patch1: groff.patch URL: http://oss.oetiker.ch/rrdtool/ @@ -357,7 +359,7 @@ install -d perl-docs/html %install rm -rf $RPM_BUILD_ROOT -install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} +install -d $RPM_BUILD_ROOT{/etc/{rc.d/init.d,sysconfig},%{_examplesdir}/%{name}-%{version}} %{__make} install \ DESTDIR=$RPM_BUILD_ROOT \ @@ -366,6 +368,9 @@ install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} examplesdir=%{_examplesdir}/%{name}-%{version} \ RUBYARCHDIR=$RPM_BUILD_ROOT%{ruby_archdir} +install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/rrdcached +install %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/rrdcached + %{__rm} $RPM_BUILD_ROOT%{_libdir}/librrd.la %{__rm} -r $RPM_BUILD_ROOT%{_docdir} @@ -383,6 +388,26 @@ rm -rf $RPM_BUILD_ROOT %post -p /sbin/ldconfig %postun -p /sbin/ldconfig +%pre cached +%groupadd -g 347 rrdcached +%useradd -u 347 -d /usr/share/empty -g rrdcached -c "rrdcached daemon user" rrdcached + +%post cached +/sbin/chkconfig --add rrdcached +%service rrdcached restart + +%postun cached +if [ "$1" = "0" ]; then + %userremove rrdcached + %groupremove rrdcached +fi + +%preun cached +if [ "$1" = "0" ]; then + %service rrdcached stop + /sbin/chkconfig --del rrdcached +fi + %files %defattr(644,root,root,755) %doc CHANGES CONTRIBUTORS COPYRIGHT NEWS THREADS TODO @@ -430,6 +455,8 @@ rm -rf $RPM_BUILD_ROOT %files devel %defattr(644,root,root,755) %attr(755,root,root) %{_libdir}/librrd.so +%attr(754,root,root) /etc/rc.d/init.d/rrdcached +%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/rrdcached %{_includedir}/rrd*.h %{_pkgconfigdir}/librrd.pc %{_mandir}/man3/librrd.3*