# have other commands that you also want to run, you'll have to put them in
# that function, as you can only run one function.)
#AFS_POST_INIT=afs_server_prefs
+
+# If you want to always run some command before shutting down OpenAFS, you can
+# put it here. The same caveat applies about multiple commands.
+AFS_PRE_SHUTDOWN=
+
+# If you are having problems with AFS shutting down cleanly or the system not
+# rebooting because the partition the AFS cache was on could not be unmounted,
+# try installing lsof and uncommenting this. This will cause all processes
+# with open AFS files to be killed before unmounting AFS.
+#
+# Warning: This means /etc/init.d/openafs-client stop will kill all processes
+# with files open in AFS rather than returning an error saying the file system
+# is busy. This is what you want when the whole system is shutting down, but
+# often *not* what you want when just stopping and restarting the client.
+# OpenAFS has no way of distinguishing between those two cases. Only enable
+# this if you're certain it's what you want.
+#AFS_PRE_SHUTDOWN=kill_all_afs
- Choose the client options based on the cache size by default.
- Move the code to build the options string to the init script from
afs.conf so that afs.conf is pure configuration.
+ - Add an AFS_PRE_SHUTDOWN hook called before shutting down the client.
+ - Provide a shutdown hook, disabled by default, that kills all
+ processes with files open in /afs. Enabling this ensures a more
+ reliable clean shutdown and umounting of the cache partition, but
+ may not always be what the admin wants.
- Improve the readability of the output on start.
- Significantly improve the comments in afs.conf.
- Remove the code to set -nosettime as it's now the default.
fi
}
+# Kill all processes that are accessing AFS. Not enabled by default, and
+# normally called via kill_all_afs. Warns and does nothing if lsof is not
+# installed.
+kill_afs() {
+ signal=$1
+ pids=`/usr/bin/lsof -Fp /afs | sed 's/p//'`
+ if [ -n "$pids" ] ; then
+ kill -$signal $pids > /dev/null 2>&1
+ sleep 1
+ fi
+}
+
+# Repeatedly call kill_afs for a series of signals to give AFS-using processes
+# a hope of shutting down cleanly. Not enabled by default. Enable this in
+# /etc/openafs/afs.conf (but see the warning in that file).
+kill_all_afs() {
+ if [ -x /usr/bin/lsof ] ; then
+ echo -n "Killing processes with AFS files open: "
+ kill_afs HUP
+ kill_afs TERM
+ kill_afs ABRT
+ kill_afs KILL
+ echo "done."
+ else
+ echo '/usr/bin/lsof not found, not killing processes' >&2
+ fi
+}
+
case "$1" in
start)
;;
stop|force-stop)
+ $AFS_PRE_SHUTDOWN
echo -n "Stopping AFS services:"
if mount | grep -q '^AFS' ; then
umount /afs