If a client was running during the upgrade from a sysvinit version
of the package, stopping it with the systemd unit file will not
necessarily have run the precheck script sufficiently recently to
fill in the KMOD variable with openafs, so that the shut-down client
would leave the kernel module loaded. This causes great badness
when attempting to start the client again.
We do not want to reuse the precheck script during shutdown, as it
has conditionals on things like "not already running" which are not
appropriate there, so use a separate helper script for shutdown.
Always unload a module if it's present (unless loading is disabled),
to reduce the risk that subsequent starts will have trouble.
--- /dev/null
+#! /bin/sh
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+# Always unload a module if it's loaded.
+if /sbin/lsmod | grep -Fq openafs; then
+ KMOD=openafs
+else
+ KMOD=--version
+fi
+cat > /var/cache/openafs-client/openafs-client.shutdown.env <<EOF
+KMOD=${KMOD}
+EOF
debian/tmp/usr/sbin/afsd sbin
debian/openafs-client-precheck usr/share/openafs
+debian/openafs-client-postcheck usr/share/openafs
debian/CellServDB usr/share/openafs
debian/tmp/usr/share/openafs/C/afszcm.cat usr/share/openafs/C
rm -f "/etc/openafs/$file"
done
rm -f /var/cache/openafs-client/openafs-client.env
+ rm -f /var/cache/openafs-client/openafs-client.shutdown.env
fi
#DEBHELPER#
ExecStartPost=/usr/bin/fs setcrypt $AFS_SETCRYPT
ExecStartPost=/usr/bin/fs sysname $AFS_SYSNAME
ExecStop=/bin/grep -qv ^1$ /proc/sys/kernel/modules_disabled
+ExecStop=/usr/share/openafs/openafs-client-postcheck
ExecStop=/bin/umount -a -t afs
ExecStop=/bin/umount -af -t afs
ExecStopPost=/sbin/rmmod $KMOD
EnvironmentFile=/var/cache/openafs-client/openafs-client.env
+EnvironmentFile=-/var/cache/openafs-client/openafs-client.shutdown.env
KillMode=none
GuessMainPID=no