3 # Provides: openafs-client
4 # Required-Start: $remote_fs $network $time
5 # Required-Stop: $remote_fs $network
6 # Should-Start: $syslog $named openafs-fileserver
7 # Should-Stop: openafs-fileserver
9 # Default-Start: 2 3 4 5
11 # Short-Description: OpenAFS client
12 # Description: Starts or stops the OpenAFS client, loading the
13 # OpenAFS kernel module as necessary.
16 # Modified by Sam Hartman <hartmans@mit.edu> for Debian
17 # Copyright 2000, International Business Machines Corporation and others.
18 # All Rights Reserved.
20 # This software has been released under the terms of the IBM Public
21 # License. For details, see the LICENSE file in the top-level source
22 # directory or online at http://www.openafs.org/dl/license10.html
24 # This init script bears little resemblence to the regular upstream init
25 # script at this point and is therefore maintained as a Debian-specific file.
26 # The upstream init script assumes Red Hat paths and uses insmod to load the
27 # module directly rather than using modprobe.
29 PATH
=/bin
:/usr
/bin
:/sbin
:/usr
/sbin
31 CACHEINFO
=${CACHEINFO:-/etc/openafs/cacheinfo}
32 MODULEROOT
=${MODULEROOT:-/lib/modules/`uname -r`}
33 MODULEDIR
=${MODULEDIR:-$MODULEROOT/fs}
34 DKMSDIR
=${DKMSDIR:-$MODULEROOT/updates/dkms}
36 # Exit if the package is not installed.
37 [ -x /sbin
/afsd
] ||
exit 0
39 # Define LSB log_* functions and get other support infrastructure.
40 .
/lib
/lsb
/init-functions
45 # Gather up options and post startup script name, if present
46 if [ -f /etc
/openafs
/afs.conf
]; then
47 .
/etc
/openafs
/afs.conf
50 # Return 1 if the argument is "true".
52 if [ x
"$1" = x
"true" ] ; then
59 # Determine if kernel module loading is disabled. If it's not, don't attempt
60 # to stop or restart AFS, since we'll end up in a bad inconsistent state.
61 is_loading_disabled
() {
62 disabled
=`cat /proc/sys/kernel/modules_disabled 2>/dev/null`
63 if [ "$disabled" = 1 ] ; then
70 # Load the AFS client module if it's not already loaded. Set $MODULEDIR and
71 # $LIBAFS to override the default location and module name. Also check before
72 # loading whether the module is listed in the module dependencies so that we
73 # can exit with a 0 status in that case.
75 if [ -z "$LIBAFS" ] ; then
78 if [ ! -f "$MODULEDIR/$LIBAFS" -a ! -f "$DKMSDIR/$LIBAFS" ] ; then
81 AFS module $MODULEDIR/$LIBAFS does not exist.
82 Not starting AFS. Please consider building kernel modules using
83 instructions in /usr/share/doc/openafs-client/README.modules
85 # We must exit successfully here or openafs-client will fail on
86 # installation unless a module is installed.
90 if grep -q openafs
"$MODULEROOT/modules.dep" ; then
93 LOADED
=`/sbin/lsmod | fgrep openafs`
94 if [ -z "$LOADED" ] ; then
97 if [ $status = 0 ] ; then
101 # We must exit successfully here if the openafs module just isn't
102 # listed in the dependency information for modprobe, which can happen
103 # if openafs-client and the module package are installed at the same
104 # time and the module hasn't been set up yet.
105 if [ $sawdep = 0 ] ; then
114 # Determine which afsd options to use. /etc/openafs/afs.conf contains the
115 # settings that are checked here.
116 choose_afsd_options
() {
117 if [ -z "$OPTIONS" ] ||
[ "$OPTIONS" = "AUTOMATIC" ] ; then
118 AFSD_OPTIONS
="$VERBOSE"
120 AFSD_OPTIONS
="$OPTIONS $VERBOSE"
123 # These variables are from /etc/openafs/afs.conf.client and are managed
124 # automatically by debconf.
125 if is_on
$AFS_AFSDB ; then
126 AFSD_OPTIONS
="$AFSD_OPTIONS -afsdb"
128 if [ "$AFS_DYNROOT" = 'Yes' ] ||
[ "$AFS_DYNROOT" = 'true' ] ; then
129 AFSD_OPTIONS
="$AFSD_OPTIONS -dynroot"
130 elif [ "$AFS_DYNROOT" = 'Sparse' ] ; then
131 AFSD_OPTIONS
="$AFSD_OPTIONS -dynroot-sparse"
133 if is_on
$AFS_FAKESTAT ; then
134 AFSD_OPTIONS
="$AFSD_OPTIONS -fakestat"
138 # Start afsd. Be careful not to start it if another one is already running,
139 # as that has a bad tendency to hang the system. Earlier versions of the
140 # openafs-client package put afsd in /usr/sbin.
142 if pidof
/sbin
/afsd
>/dev
/null || pidof
/usr
/sbin
/afsd
>/dev
/null
; then
147 start-stop-daemon
--start --quiet --exec /sbin
/afsd
-- $AFSD_OPTIONS
150 # From /etc/openafs/afs.conf.client, whether to enable fcrypt encryption.
151 if is_on
$AFS_CRYPT ; then
155 # From /etc/openafs/afs.conf, set a sysname list if one was configured.
156 if [ -n "$AFS_SYSNAME" ] ; then
157 fs sysname
$AFS_SYSNAME
161 # Kill all processes that are accessing AFS. Not enabled by default, and
162 # normally called via kill_all_afs.
165 mount
=`grep ^'AFS ' /etc/mtab | awk '{ print $2 }'`
166 if [ -n "$mount" ] ; then
167 pids
=`/usr/bin/lsof -Fp $mount | sed 's/p//'`
168 if [ -n "$pids" ] ; then
169 kill -$signal $pids > /dev
/null
2>&1
175 # Repeatedly call kill_afs for a series of signals to give AFS-using processes
176 # a hope of shutting down cleanly if the system is shutting down. Not enabled
177 # by default. Enable this in /etc/openafs/afs.conf.
179 # Warns and does nothing if lsof is not installed.
181 runlevel
=`runlevel | sed 's/^. //'`
182 if [ "$runlevel" -eq 0 ] ||
[ "$runlevel" -eq 6 ] ; then
183 if [ -x /usr
/bin
/lsof
] ; then
184 echo -n "Killing processes with AFS files open: "
191 echo '/usr/bin/lsof not found, not killing processes' >&2
199 if is_on
$AFS_CLIENT && test -x /sbin
/afsd
; then
200 echo -n "Starting AFS services:"
201 if load_client
; then
206 echo "Failed to load AFS kernel module, not starting AFS" >&2
213 if test -x /sbin
/afsd
; then
214 echo -n "Starting AFS services:"
215 if load_client
; then
220 echo "Failed to load AFS kernel module, not starting AFS" >&2
227 if is_loading_disabled
; then
228 echo "Module loading disabled, cannot stop AFS" >&2
232 echo -n "Stopping AFS services:"
233 if grep -q '^AFS ' /etc
/mtab
; then
234 umount
`grep ^'AFS ' /etc/mtab | awk '{ print $2 }'`
237 if pidof
/usr
/sbin
/afsd
>/dev
/null || pidof
/sbin
/afsd
>/dev
/null
; then
241 # If running with the -rmtsys option, afsd doesn't kill the rmtsys helper
242 # on afsd -shutdown. Run start-stop-daemon to make sure that everything
244 start-stop-daemon
--stop --quiet --name afsd
246 LIBAFS
=`/sbin/lsmod | awk 'BEGIN { FS = " " } /openafs/ { print $1 }'`
247 if [ -n "$LIBAFS" ] ; then
254 restart|force-reload
)
261 'openafs-client {start|force-start|stop|restart|force-reload}' >&2