]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Separate helper for shutdown module check
authorBenjamin Kaduk <kaduk@mit.edu>
Thu, 30 Oct 2014 20:07:41 +0000 (16:07 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 30 Oct 2014 20:50:26 +0000 (16:50 -0400)
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.

debian/openafs-client-postcheck [new file with mode: 0755]
debian/openafs-client.install
debian/openafs-client.postrm
debian/openafs-client.service

diff --git a/debian/openafs-client-postcheck b/debian/openafs-client-postcheck
new file mode 100755 (executable)
index 0000000..aef53a7
--- /dev/null
@@ -0,0 +1,12 @@
+#! /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
index c98193006b5ca14af5e45c73aceb8e5243ad6027..5a7e92018977566dcde79529fd5ca4b8bd45775a 100644 (file)
@@ -33,6 +33,7 @@ debian/tmp/usr/sbin/rmtsysd             usr/sbin
 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
 
index c11d0df0015906812d5216c52406dbc6630d7e75..cc9e64faede9c712d2c61ae079885eb6e8c0a9de 100755 (executable)
@@ -10,6 +10,7 @@ if [ "$1" = 'purge' ] ; then
         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#
index ac3ab62f827643cf981dad066064b3ef7fd34cbc..7b4c04e5354805e864eb20952e42180ffe20adeb 100755 (executable)
@@ -11,10 +11,12 @@ ExecStart=/sbin/afsd $AFSD_ARGS
 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