]> TLD Linux GIT Repositories - packages/rrdtool.git/commitdiff
- added init script for rrdcached
authorMarcin Krol <hawk@tld-linux.org>
Mon, 6 Mar 2023 21:37:45 +0000 (22:37 +0100)
committerMarcin Krol <hawk@tld-linux.org>
Mon, 6 Mar 2023 21:37:45 +0000 (22:37 +0100)
rrdcached.init [new file with mode: 0644]
rrdcached.sysconfig [new file with mode: 0644]
rrdtool.spec

diff --git a/rrdcached.init b/rrdcached.init
new file mode 100644 (file)
index 0000000..3cf1417
--- /dev/null
@@ -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 (file)
index 0000000..a359b53
--- /dev/null
@@ -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
index d67c28005621af418ca5051fc234773c9fca7557..7d47bc1ffd98857ba643af0c2f5322d9a3044f30 100644 (file)
@@ -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*