[packages/cachefilesd] add rc-scripts initscript (not tested)
glen
glen at pld-linux.org
Sat Mar 22 18:54:18 CET 2014
commit 46473e89a237aeded0f9e396c2ef61743d0d238d
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sat Mar 22 19:54:09 2014 +0200
add rc-scripts initscript (not tested)
cachefilesd.init | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
cachefilesd.spec | 12 ++++---
2 files changed, 110 insertions(+), 5 deletions(-)
---
diff --git a/cachefilesd.spec b/cachefilesd.spec
index 44f6d98..1be060e 100644
--- a/cachefilesd.spec
+++ b/cachefilesd.spec
@@ -1,5 +1,3 @@
-# TODO:
-# - rc-scripts init
Summary: CacheFiles user-space management daemon
Name: cachefilesd
Version: 0.10.5
@@ -8,10 +6,12 @@ License: GPL v2
Group: Daemons
Source0: http://people.redhat.com/dhowells/fscache/%{name}-%{version}.tar.bz2
# Source0-md5: 9e85dd0ace346ff47e188ded8c05ab3b
+Source1: %{name}.init
Patch0: %{name}-cpueating.patch
URL: http://people.redhat.com/~dhowells/fscache/
Requires(post,preun): /sbin/chkconfig
Requires(post,preun,postun): systemd-units >= 38
+Requires: rc-scripts
Requires: systemd-units >= 38
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -31,25 +31,26 @@ persistent caching to the local disk.
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{/sbin,%{_mandir}/man{5,8},%{systemdunitdir},%{_localstatedir}/cache/fscache}
+install -d $RPM_BUILD_ROOT{/sbin,%{_mandir}/man{5,8},%{systemdunitdir},/etc/rc.d/init.d,%{_localstatedir}/cache/fscache}
%{__make} install \
INSTALL="install -p" \
DESTDIR=$RPM_BUILD_ROOT
+install -p %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/cachefilesd
cp -p cachefilesd.service $RPM_BUILD_ROOT%{systemdunitdir}
%clean
rm -rf $RPM_BUILD_ROOT
%post
-#/sbin/chkconfig --add cachefilesd
+/sbin/chkconfig --add cachefilesd
%service cachefilesd restart "cachefilesd daemon"
%systemd_post cachefilesd.service
%preun
if [ "$1" = "0" ]; then
-# /sbin/chkconfig --del cachefilesd
+ /sbin/chkconfig --del cachefilesd
%service cachefilesd stop
fi
%systemd_preun cachefilesd.service
@@ -65,5 +66,6 @@ fi
%attr(755,root,root) /sbin/cachefilesd
%{_mandir}/man5/cachefilesd.conf.5*
%{_mandir}/man8/cachefilesd.8*
+%attr(754,root,root) /etc/rc.d/init.d/cachefilesd
%{systemdunitdir}/cachefilesd.service
%dir %{_localstatedir}/cache/fscache
diff --git a/cachefilesd.init b/cachefilesd.init
new file mode 100755
index 0000000..cbf421b
--- /dev/null
+++ b/cachefilesd.init
@@ -0,0 +1,103 @@
+#!/bin/sh
+#
+# cachefilesd Start up and shut down the cachefilesd daemon
+#
+# chkconfig: 345 13 87
+#
+# description: Starts user-level daemon that manages the caching files \
+# used by Network Filsystems
+#
+# processname: cachefilesd
+# config: /etc/cachefilesd.conf
+#
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down "CacheFiles Daemon"
+ exit 1
+ fi
+else
+ exit 0
+fi
+
+# Set defaults
+CONFFILE=/etc/cachefilesd.conf
+PIDFILE=/var/run/cachefilesd.pid
+OPTIONS="-f $CONFFILE"
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/cachefilesd ] && . /etc/sysconfig/cachefilesd
+
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/cachefilesd ]; then
+ msg_already_running "CacheFiles Daemon"
+ return
+ fi
+
+ msg_starting "CacheFiles Daemon"
+ modprobe -qs cachefiles
+ daemon --pidfile=$PIDFILE /usr/sbin/cachefilesd $OPTIONS
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cachefilesd
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/cachefilesd ]; then
+ msg_not_running "CacheFiles Daemon"
+ return
+ fi
+
+ # Stop daemons.
+ msg_stopping "CacheFiles Daemon"
+ killproc --pidfile $PIDFILE cachefilesd -TERM
+ rm -f /var/lock/subsys/cachefilesd
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/cachefilesd ]; then
+ msg_not_running "CacheFiles Daemon"
+ RETVAL=$1
+ return
+ fi
+
+ stop
+ start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
+ status)
+ status --pidfile $PIDFILE cachefilesd
+ RETVAL=$?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/cachefilesd.git/commitdiff/46473e89a237aeded0f9e396c2ef61743d0d238d
More information about the pld-cvs-commit
mailing list