3 # Provides: openafs-client
4 # Required-Start: $remote_fs $network $time
5 # Required-Stop: $remote_fs $network
6 # Should-Start: $syslog
8 # Default-Start: 2 3 4 5
10 # Short-Description: OpenAFS client
11 # Description: Starts or stops the OpenAFS client, loading the
12 # OpenAFS kernel module as necessary.
15 # Modified by Sam Hartman <hartmans@mit.edu> for Debian
16 # Copyright 2000, International Business Machines Corporation and others.
17 # All Rights Reserved.
19 # This software has been released under the terms of the IBM Public
20 # License. For details, see the LICENSE file in the top-level source
21 # directory or online at http://www.openafs.org/dl/license10.html
23 # This init script bears little resemblence to the regular upstream init
24 # script at this point and is therefore maintained as a Debian-specific file.
25 # The upstream init script assumes Red Hat paths and uses insmod to load the
26 # module directly rather than using modprobe.
28 PATH=/bin:/usr/bin:/sbin:/usr/sbin
30 CACHEINFO=${CACHEINFO:-/etc/openafs/cacheinfo}
31 MODULEROOT=${MODULEROOT:-/lib/modules/`uname -r`}
32 MODULEDIR=${MODULEDIR:-$MODULEROOT/fs}
33 DKMSDIR=${DKMSDIR:-$MODULEROOT/updates/dkms}
38 # Gather up options and post startup script name, if present
39 if [ -f /etc/openafs/afs.conf ]; then
40 . /etc/openafs/afs.conf
43 # Return 1 if the argument is "true".
45 if [ x"$1" = x"true" ] ; then
52 # Load the AFS client module if it's not already loaded. Set $MODULEDIR and
53 # $LIBAFS to override the default location and module name. Also check before
54 # loading whether the module is listed in the module dependencies so that we
55 # can exit with a 0 status in that case.
57 if [ -z "$LIBAFS" ] ; then
60 if [ ! -f "$MODULEDIR/$LIBAFS" -a ! -f "$DKMSDIR/$LIBAFS" ] ; then
63 AFS module $MODULEDIR/$LIBAFS does not exist.
64 Not starting AFS. Please consider building kernel modules using
65 instructions in /usr/share/doc/openafs-client/README.modules
67 # We must exit successfully here or openafs-client will fail on
68 # installation unless a module is installed.
72 if grep -q openafs "$MODULEROOT/modules.dep" ; then
75 LOADED=`/sbin/lsmod | fgrep openafs`
76 if [ -z "$LOADED" ] ; then
79 if [ $status = 0 ] ; then
83 # We must exit successfully here if the openafs module just isn't
84 # listed in the dependency information for modprobe, which can happen
85 # if openafs-client and the module package are installed at the same
86 # time and the module hasn't been set up yet.
87 if [ $sawdep = 0 ] ; then
96 # Determine which afsd options to use. /etc/openafs/afs.conf contains the
97 # settings that are checked here.
98 choose_afsd_options() {
99 if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then
100 AFSD_OPTIONS="$VERBOSE"
102 AFSD_OPTIONS="$OPTIONS $VERBOSE"
105 # These variables are from /etc/openafs/afs.conf.client and are managed
106 # automatically by debconf.
107 if is_on $AFS_AFSDB ; then
108 AFSD_OPTIONS="$AFSD_OPTIONS -afsdb"
110 if is_on $AFS_DYNROOT ; then
111 AFSD_OPTIONS="$AFSD_OPTIONS -dynroot"
113 if is_on $AFS_FAKESTAT ; then
114 AFSD_OPTIONS="$AFSD_OPTIONS -fakestat"
118 # Start afsd. Be careful not to start it if another one is already running,
119 # as that has a bad tendency to hang the system. Earlier versions of the
120 # openafs-client package put afsd in /usr/sbin.
122 if pidof /sbin/afsd >/dev/null || pidof /usr/sbin/afsd >/dev/null ; then
127 start-stop-daemon --start --quiet --exec /sbin/afsd -- $AFSD_OPTIONS
130 # From /etc/openafs/afs.conf.client, whether to enable fcrypt encryption.
131 if is_on $AFS_CRYPT ; then
135 # From /etc/openafs/afs.conf, set a sysname list if one was configured.
136 if [ -n "$AFS_SYSNAME" ] ; then
137 fs sysname $AFS_SYSNAME
141 # Kill all processes that are accessing AFS. Not enabled by default, and
142 # normally called via kill_all_afs.
145 mount=`grep ^'AFS ' /etc/mtab | awk '{ print $2 }'`
146 if [ -n "$mount" ] ; then
147 pids=`/usr/bin/lsof -Fp $mount | sed 's/p//'`
148 if [ -n "$pids" ] ; then
149 kill -$signal $pids > /dev/null 2>&1
155 # Repeatedly call kill_afs for a series of signals to give AFS-using processes
156 # a hope of shutting down cleanly if the system is shutting down. Not enabled
157 # by default. Enable this in /etc/openafs/afs.conf.
159 # Warns and does nothing if lsof is not installed.
161 runlevel=`runlevel | sed 's/^. //'`
162 if [ "$runlevel" -eq 0 ] || [ "$runlevel" -eq 6 ] ; then
163 if [ -x /usr/bin/lsof ] ; then
164 echo -n "Killing processes with AFS files open: "
171 echo '/usr/bin/lsof not found, not killing processes' >&2
179 if is_on $AFS_CLIENT && test -x /sbin/afsd ; then
180 echo -n "Starting AFS services:"
181 if load_client ; then
186 echo "Failed to load AFS kernel module, not starting AFS" >&2
193 if test -x /sbin/afsd ; then
194 echo -n "Starting AFS services:"
195 if load_client ; then
200 echo "Failed to load AFS kernel module, not starting AFS" >&2
208 echo -n "Stopping AFS services:"
209 if grep -q '^AFS ' /etc/mtab ; then
210 umount `grep ^'AFS ' /etc/mtab | awk '{ print $2 }'`
213 if pidof /usr/sbin/afsd >/dev/null || pidof /sbin/afsd >/dev/null ; then
217 # If running with the -rmtsys option, afsd doesn't kill the rmtsys helper
218 # on afsd -shutdown. Run start-stop-daemon to make sure that everything
220 start-stop-daemon --stop --quiet --name afsd
222 LIBAFS=`/sbin/lsmod | awk 'BEGIN { FS = " " } /openafs/ { print $1 }'`
223 if [ -n "$LIBAFS" ] ; then
230 restart|force-reload)
237 'openafs-client {start|force-start|stop|restart|force-reload}' >&2