aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2011-07-15 17:09:11 +0100
committerDavid Howells <dhowells@redhat.com>2011-07-15 17:09:11 +0100
commite353e46554276ebab0be1f8d939871ed852c5fc3 (patch)
tree7e15814cb4d66d1550e2e52b8713604397e12ee7
parent0ad4e0b02dacff2befe2c5246e542428903a4567 (diff)
downloadcachefilesd-e353e46554276ebab0be1f8d939871ed852c5fc3.tar.gz
Fix the cachefilesd initscript
Fix the cachefilesd initscript to: (1) embed a parseable description for init to use, and (2) use the appropriate exit codes. For more information, see: https://fedoraproject.org/wiki/Packaging/SysVInitScript Signed-off-by: David Howells <dhowells@redhat.com>
-rwxr-xr-xcachefilesd.initd152
-rw-r--r--redhat/cachefilesd.spec3
2 files changed, 97 insertions, 58 deletions
diff --git a/cachefilesd.initd b/cachefilesd.initd
index c1856dd..7962782 100755
--- a/cachefilesd.initd
+++ b/cachefilesd.initd
@@ -2,22 +2,25 @@
#
# cachefilesd Start up and shut down the cachefilesd daemon
#
+### BEGIN INIT INFO
+# Provides: fscache
+# Required-Start: $local_fs $time
+# Required-Stop: $local_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Control the persistent network fs caching service
+# Description: CacheFiles provides persistent local caching for network (and
+# other) filesystems in a directory on a locally mounted disk.
+### END INIT INFO
+#
# chkconfig: - 13 87
# description: Starts user-level daemon that manages the caching files \
# used by Network Filsystems
+#
# Source function library.
. /etc/init.d/functions
-# Source networking configuration.
-if [ ! -f /etc/sysconfig/network ]; then
- exit 0
-fi
-. /etc/sysconfig/network
-
-# Check that networking is up.
-[ "${NETWORKING}" = "no" ] && exit 0
-
RETVAL=0
CONFFILE=/etc/cachefilesd.conf
@@ -33,60 +36,93 @@ OPTIONS="-f $CONFFILE"
# Check for and source configuration file otherwise set defaults
[ -f /etc/sysconfig/$PROG ] && . /etc/sysconfig/$PROG
-case "$1" in
- start|condstart)
- # Make sure the daemon is not already running.
- if status $PROG > /dev/null ; then
- exit 0
+rh_status() {
+ status -p $PIDFILE -l $(basename $LOCKFILE) $PROG
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+start() {
+ [ `id -u` -eq 0 ] || return 4
+ [ -x $exec ] || return 5
+ [ -f $config ] || return 6
+
+ # Make sure the daemon is not already running.
+ rh_status_q && return 0
+ rm -f $LOCKFILE
+
+ echo -n $"Starting $PROG: "
+
+ # Set security contexts
+ /sbin/restorecon /sbin/cachefilesd || return 1
+ /sbin/restorecon /dev/cachefiles || return 1
+ /sbin/restorecon -R `awk -- '/^dir/ { print $2 }' $CONFFILE` || return 1
+
+ # Load the cachefiles module if needed
+ [ -x "$MODPROBE" ] && {
+ if ! /sbin/lsmod | grep cachefiles > /dev/null ; then
+ $MODPROBE cachefiles $MODPROBE_ARGS || return 1
fi
- rm -f $LOCKFILE
-
- echo -n $"Starting $PROG: "
-
- # Set security contexts
- /sbin/restorecon /sbin/cachefilesd
- /sbin/restorecon /dev/cachefiles
- /sbin/restorecon -R `awk -- '/^dir/ { print $2 }' $CONFFILE`
-
- # Load the cachefiles module if needed
- [ -x "$MODPROBE" ] && {
- if ! /sbin/lsmod | grep cachefiles > /dev/null ; then
- $MODPROBE cachefiles $MODPROBE_ARGS || exit 1
- fi
- }
-
- # Start daemon.
- daemon --pidfile=$PIDFILE $PROG ${OPTIONS}
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch $LOCKFILE
+ }
+
+ # Start daemon.
+ daemon --pidfile=$PIDFILE $PROG ${OPTIONS} 2>/dev/null
+ RETVAL=$?
+
+ echo
+ [ $RETVAL -eq 0 ] && touch $LOCKFILE
+ return $RETVAL
+}
+
+stop() {
+ [ `id -u` -eq 0 ] || return 4
+ rh_status_q || return 0
+
+ echo -n $"Shutting down $PROG: "
+ killproc -p $PIDFILE $PROG
+ RETVAL=$?
+
+ echo
+ [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
+ return $RETVAL
+}
+
+usage() {
+ echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|status}"
+}
+
+if [ $# -gt 1 ]; then
+ exit 2
+fi
+
+case "$1" in
+ start|condstart)
+ start
;;
- stop)
- # Stop daemon.
- echo -n $"Shutting down $PROG: "
- killproc -p $PIDFILE
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
+ stop)
+ stop
;;
- status)
- status $PROG
- RETVAL=$?
+ restart|force-reload)
+ stop; start
;;
- restart|reload)
- $0 stop
- $0 start
- RETVAL=$?
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ stop ; start
;;
- condrestart)
- if [ -f $LOCKFILE ]; then
- $0 restart
- RETVAL=$?
- fi
+ reload)
+ usage
+ # unimplemented feature
+ exit 3
+ ;;
+ status)
+ rh_status
+ ;;
+ *)
+ usage
+ exit 2
;;
- *)
- echo $"Usage: $0 {start|stop|restart|condstart|condrestart|status}"
- exit 1
esac
-exit $RETVAL
+exit $?
diff --git a/redhat/cachefilesd.spec b/redhat/cachefilesd.spec
index a2179fc..9f44515 100644
--- a/redhat/cachefilesd.spec
+++ b/redhat/cachefilesd.spec
@@ -83,6 +83,9 @@ fi
%{_localstatedir}/cache/fscache
%changelog
+* Fri Jun 18 2010 David Howells <dhowells@redhat.com>
+- Fix the initscript to have the appropriate parseable description and exit codes.
+
* Wed Apr 28 2010 David Howells <dhowells@redhat.com>
- Fix the Requires line on selinux-policy-base to be >=, not =.