File: cachefilesd.initd

package info (click to toggle)
cachefilesd 0.10.10-0.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 188 kB
  • sloc: ansic: 1,121; sh: 233; makefile: 75
file content (128 lines) | stat: -rwxr-xr-x 2,645 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
#
# 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


RETVAL=0
CONFFILE=/etc/cachefilesd.conf
LOCKFILE=/var/lock/subsys/cachefilesd
PIDFILE=/var/run/cachefilesd.pid
MODPROBE=/sbin/modprobe
MODPROBE_ARGS=""
PROG="cachefilesd"
OPTIONS="-f $CONFFILE"

[ ! -x /sbin/$PROG ] && exit 0

# Check for and source configuration file otherwise set defaults
[ -f /etc/sysconfig/$PROG ] && . /etc/sysconfig/$PROG

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
    }

    # 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
	;;
    restart|force-reload)
	stop; start
	;;
    condrestart|try-restart)
        rh_status_q || exit 0
        stop ; start
	;;
    reload)
        usage
        # unimplemented feature
        exit 3
        ;;
    status)
        rh_status
        ;;
    *)
	usage
	exit 2
	;;
esac

exit $?