Comment 4 for bug 1312976

Revision history for this message
Tom H (tomh0665) wrote : Re: nfs-utils needs systemd unit or init.d script

I'd posted this to ubuntu-devel-discuss but I was just looking at systemd-boot bugs and thought that I'd post it here too, with apologies for the duplication. I hope that it helps whoever puts together the real thing.

I installed the upstream nfs-utils units and adapted them with "/etc/" overrides; and I created rpcbind units.

# diff /etc/systemd/system/nfs-config.service
/lib/systemd/system/nfs-config.service
7c7
< ExecStart=/lib/systemd/scripts/nfs-utils_env.sh
---
> ExecStart=/usr/lib/systemd/scripts/nfs-utils_env.sh

# diff /etc/systemd/system/rpc-statd-notify.service
/lib/systemd/system/rpc-statd-notify.service
19c19
< ExecStart=-/sbin/sm-notify -d $SMNOTIFYARGS
---
> ExecStart=-/usr/sbin/sm-notify -d $SMNOTIFYARGS

# diff /etc/systemd/system/rpc-statd.service
/lib/systemd/system/rpc-statd.service
16,17c16,17
< PIDFile=/run/rpc.statd.pid
< ExecStart=/sbin/rpc.statd --no-notify $STATDARGS
---
> PIDFile=/var/run/rpc.statd.pid
> ExecStart=/usr/sbin/rpc.statd --no-notify $STATDARGS

# cat /lib/systemd/scripts/nfs-utils_env.sh
#!/bin/sh

NFS_CONFIG=/run/sysconfig/nfs-utils

if [ -e $NFS_CONFIG ] ; then
    rm -f $NFS_CONFIG
fi

if [ -r /etc/default/nfs-common ] ; then
    . /etc/default/nfs-common
fi

if [ -r /etc/default/nfs-kernel-server ] ; then
    . /etc/default/nfs-kernel-server
fi

RPCNFSDARGStmp="$RPCNFSDCOUNT $RPCNFSDOPTS"

mkdir -p /run/sysconfig

echo "GSSDARGS=\"\"" >> $NFS_CONFIG
echo "RPCIDMAPDARGS=\"$RPCIDMAPDARGS\"" >> $NFS_CONFIG
echo "SMNOTIFYARGS=\"\"" >> $NFS_CONFIG
echo "STATDARGS=\"$STATDOPTS\"" >> $NFS_CONFIG

echo "RPCMOUNTDARGS=\"$RPCMOUNTDOPTS\"" >> $NFS_CONFIG
echo "RPCNFSDARGS=\"$RPCNFSDARGStmp\"" >> $NFS_CONFIG
echo "SVCGSSDARGS=\"$RPCSVCGSSDOPTS\"" >> $NFS_CONFIG

[Note on RPCIDMAPDARGS: I set it to "-p /var/lib/nfs/rpc_pipefs" in
"/etc/default/nfs-common" because nfs-idmapd.service was failing
without it. The path to rpc_pipefs was defaulting to "/run/rpc_pipefs"
even though the man page says that the default is
"/var/lib/nfs/rpc_pipefs".]

# cat /lib/systemd/system/rpcbind.service
[Unit]
Description=RPC Bind
After=network.target

[Service]
Type=forking
ExecStart=/sbin/rpcbind
Restart=always

[Install]
WantedBy=rpcbind.target

[Note on rpcbind.service: I'm not sure whether this is the right unit
or whether it should have "Before=rpcbind.target multi-user.target"
and "Requires=rpcbind.target" in the "Unit" section and
"WantedBy=multi-user.target" in the "Install" section.]

# cat /lib/systemd/system/rpcbind.socket
[Unit]
Description=RPC Bind Socket

[Socket]
ListenStream=/run/rpcbind.sock

[Install]
WantedBy=sockets.target