| 1 |
#!/bin/sh |
| 2 |
# nfsmount calls this script when mounting a filesystem with locking |
| 3 |
# enabled, but when statd does not seem to be running (based on |
| 4 |
# /run/rpc.statd.pid). |
| 5 |
# It should run statd with whatever flags are apropriate for this |
| 6 |
# site. |
| 7 |
PATH="/sbin:/usr/sbin:/bin:/usr/bin" |
| 8 |
|
| 9 |
# Use flock to serialize the running of this script |
| 10 |
exec 9> /run/rpc.statd.lock |
| 11 |
flock -x 9 |
| 12 |
|
| 13 |
if [ -s /run/rpc.statd.pid ] && |
| 14 |
[ "1$(cat /run/rpc.statd.pid)" -gt 1 ] && |
| 15 |
kill -0 "$(cat /run/rpc.statd.pid)" > /dev/null 2>&1 |
| 16 |
then |
| 17 |
# statd already running - must have been slow to respond. |
| 18 |
exit 0 |
| 19 |
fi |
| 20 |
# First try systemd if it's installed. |
| 21 |
if [ -d /run/systemd/system ]; then |
| 22 |
# Quit only if the call worked. |
| 23 |
if systemctl start rpc-statd.service; then |
| 24 |
# Ensure systemd knows not to stop rpc.statd or its dependencies |
| 25 |
# on 'systemctl isolate ..' |
| 26 |
systemctl add-wants --runtime remote-fs.target rpc-statd.service |
| 27 |
exit 0 |
| 28 |
fi |
| 29 |
fi |
| 30 |
|
| 31 |
cd / |
| 32 |
# Fall back to launching it ourselves. |
| 33 |
exec rpc.statd --no-notify |