]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Add systemd unit file for openafs-client
authorBenjamin Kaduk <kaduk@mit.edu>
Thu, 23 Oct 2014 02:51:44 +0000 (22:51 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 23 Oct 2014 03:37:36 +0000 (23:37 -0400)
debian/changelog
debian/openafs-client-precheck [new file with mode: 0755]
debian/openafs-client.install
debian/openafs-client.service [new file with mode: 0755]
debian/rules

index bb5e0bf236c46b9ab97adae1d48f6111dc902119..024f1e8e6b91799f4c30a25fb91fcd6e9a0d253d 100644 (file)
@@ -4,6 +4,20 @@ openafs (1.6.10-1) UNRELEASED; urgency=medium
     - fix segfault with aklog -path.
   * The 1.6.10~pre1-1 changelog entry contains a full summary of changes
     in the upstream release.
+  * Add a systemd unit file for openafs-client.
+    - The variables AFS_PRE_SHUTDOWN and AFS_POST_INIT from
+      /etc/openafs.afs.conf are no longer honored.  They should be
+      converted to the systemd format and placed in
+      /etc/systemd/system/openafs-client.service.d/ ; automatic conversion
+      is not possible.  In particular, the kill_all_afs functionality is
+      not available.
+    - The LIBAFS, MODULEROOT, MODULEDIR, and DKMSDIR settings from
+      /etc/openafs/afs.conf are not used by the unit file.
+    - The extra shutdown handling for when the NFS translator is used
+      was not converted to the systemd format; the necessary feature
+      was removed from the Linux kernel in 2008.
+    - Support for cold shutdowns is removed.  They generally resulted
+      only in strange failures later on.
 
  -- Benjamin Kaduk <kaduk@mit.edu>  Wed, 22 Oct 2014 13:10:59 -0400
 
diff --git a/debian/openafs-client-precheck b/debian/openafs-client-precheck
new file mode 100755 (executable)
index 0000000..e62d5f1
--- /dev/null
@@ -0,0 +1,78 @@
+#! /bin/sh
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+# Gather up options and post startup script name, if present
+if [ -f /etc/openafs/afs.conf ]; then
+    . /etc/openafs/afs.conf
+fi
+
+CACHEINFO=${CACHEINFO:-/etc/openafs/cacheinfo}
+
+# Exit if the package is not installed.
+[ -x /sbin/afsd ] || exit 1
+
+# Do some other checks for prerequisites
+if ! [ -f "${CACHEINFO}" ]; then
+    echo "required cacheinfo file does not exist" >&2
+    exit 1
+fi
+if ! [ -d $(awk -F : '{print $1}' < "${CACHEINFO}") ]; then
+    echo "AFS mountpoint is not a directory or does not exist" >&2
+    exit 1
+fi
+if pidof /sbin/afsd || pidof /usr/sbin/afsd; then
+    echo "afsd is already running?" >&2
+    exit 1
+fi
+
+# Ensure that the kernel module is loaded.
+if [ -z $(/sbin/lsmod | fgrep openafs) ]; then
+    modprobe openafs
+    status=$?
+
+    if [ $status -ne 0 ] ; then
+       echo "Failed to load openafs.ko.  Does it need to be built?" >&2
+        exit $status
+    fi
+fi
+
+# Determine which afsd options to use.  /etc/openafs/afs.conf contains the
+# settings that are checked here.
+if [ -z "$OPTIONS" ] || [ "$OPTIONS" = "AUTOMATIC" ] ; then
+    AFSD_OPTIONS="$VERBOSE"
+else
+    AFSD_OPTIONS="$OPTIONS $VERBOSE"
+fi
+
+# These variables are from /etc/openafs/afs.conf.client and are managed
+# automatically by debconf.
+case "$AFS_AFSDB" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee])
+    AFSD_OPTIONS="$AFSD_OPTIONS -afsdb"
+esac
+case "$AFS_DYNROOT" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee])
+    AFSD_OPTIONS="$AFSD_OPTIONS -dynroot"
+    ;;
+[Ss][Pp][Aa][Rr][Ss][Ee])
+    AFSD_OPTIONS="$AFSD_OPTIONS -dynroot-sparse"
+esac
+case "$AFS_FAKESTAT" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee])
+    AFSD_OPTIONS="$AFSD_OPTIONS -fakestat"
+esac
+
+case "$AFS_CRYPT" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee])
+    AFS_SETCRYPT=on
+    ;;
+*)
+    AFS_SETCRYPT=off
+esac
+
+# Generate an EnvironmentFile for use by systemd.
+cat > /var/cache/openafs/openafs-client.env <<EOF
+AFSD_ARGS=${AFSD_OPTIONS}
+AFS_SETCRYPT=${AFS_SETCRYPT}
+AFS_SYSNAME=${AFS_SYSNAME}
+EOF
index 65c0b67444ff3c8eeafe0c6911390662659198fb..c98193006b5ca14af5e45c73aceb8e5243ad6027 100644 (file)
@@ -32,6 +32,7 @@ debian/tmp/usr/sbin/rmtsysd             usr/sbin
 
 debian/tmp/usr/sbin/afsd                sbin
 
+debian/openafs-client-precheck                        usr/share/openafs
 debian/CellServDB                                     usr/share/openafs
 debian/tmp/usr/share/openafs/C/afszcm.cat             usr/share/openafs/C
 
diff --git a/debian/openafs-client.service b/debian/openafs-client.service
new file mode 100755 (executable)
index 0000000..c8ec0df
--- /dev/null
@@ -0,0 +1,21 @@
+[Unit]
+Description=OpenAFS client
+Wants=network-online.target
+After=network.target network-online.target local-fs.target
+Before=remote-fs.target
+
+[Service]
+Type=forking
+ExecStartPre=/usr/share/openafs/openafs-client-precheck
+ExecStart=/sbin/afsd $AFSD_ARGS
+ExecStartPost=fs setcrypt $AFS_SETCRYPT
+ExecStartPost=fs sysname $AFS_SYSNAME
+ExecStopPre=grep -qv ^1$ /proc/sys/kernel/modules_disabled
+ExecStop=umount -a -t afs
+ExecStop=umount -af -t afs
+ExecStopPost=rmmod openafs
+EnvironmentFile=/var/cache/openafs/openafs-client.env
+KillMode=none
+
+[Install]
+WantedBy=multi-user.target remote-fs.target
index 7373b59320113a7f3ff1f33df99950814e3cad31..c124019cf3d34b13a35a6c0d302807b956ffbdb6 100755 (executable)
@@ -90,7 +90,7 @@ get-orig-source:
 
 # Use dh for most actions, with overrides below.
 %:
-       dh $@
+       dh $@ --with-systemd
 
 # Handle the renaming of the up man page to afs-up here since the man pages
 # are generated from POD source by regen.sh.