| # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # statd - Network Status Monitor daemon |
| |
| # statd is used by the lock daemon to implement lock recovery when the |
| # NFS server machine crashes and reboots |
| |
| # This is modified from Ubuntu's statd.conf |
| |
| description "NSM daemon" |
| author "chromium-os-dev@chromium.org" |
| |
| start on (started rpcbind or mounting TYPE=nfs) |
| stop on stopping rpcbind |
| |
| expect fork |
| respawn |
| |
| env NEED_STATD |
| export NEED_STATD |
| |
| # Uncomment to enable console output |
| #console output |
| |
| env DEFAULTFILE=/etc/conf.d/nfs |
| |
| pre-start script |
| . /etc/init/lib/nfs-check-setup |
| |
| # create the NFS directories here |
| local d |
| for d in rpc_pipefs v4recovery v4root ; do |
| d="/var/lib/nfs/${d}" |
| [ ! -d "${d}" ] && mkdir -p "${d}" |
| done |
| |
| # This doesn't stop upstart from starting the daemon, sadly. |
| # However, it does stop us from starting rpcbind, and if that |
| # is not already running then rpc.statd will fail to start! |
| [ "$NEED_STATD" = "yes" ] || { stop statd; exit 0; } |
| |
| start rpcbind || true |
| status rpcbind | grep -q start/running |
| exec sm-notify |
| end script |
| |
| script |
| if [ -f "$DEFAULTFILE" ]; then |
| . "$DEFAULTFILE" |
| fi |
| |
| # We can't use grep here since the resulting fork will make upstart |
| # think we are done, and then it will be confused when grep exits |
| # We also can't use pattern matching since dash doesn't support it |
| # So how to check NFS_NEED_SERVICES? The environment variable |
| # NEED_STATD is not transferred to this script although from the |
| # Upstart documentation it looks like it should be. |
| |
| # We rely on the 'stop statd' in the pre-start script to stop the |
| # daemon in this case. But upstart doesn't necessary honour that, |
| # probably because it is a race condition. Starting statd by mistake |
| # is probably not a big problem |
| |
| # To fix properly: |
| # 1. Use bash / ash where =~ or == *pattern* or ${var/sub/rep} work |
| # 2. Enhance upstart so that the pre-start script can 'stop the start' |
| exec rpc.statd -L $OPTS_RPC_STATD |
| end script |