aboutsummaryrefslogtreecommitdiff
path: root/network/unfs3/rc.unfsd
blob: e78b81a91e4ef9ddb9ce177c3d501c49754d9d81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# Start/stop/restart the UNFS server.
#
# This is an init script for the User-mode NFS daemon.
#
# To use NFS, you must first set up /etc/exports.
# See unfsd(8) for information on /etc/exports format.
#
# Written for Slackware Linux' knfsd by Patrick J. Volkerding <volkerdi@slackware.com>.
# Modified to use unfsd by Menno E. Duursma <druiloor@zonnet.nl>

unfsd_start() {
  # Sanity checks.  Exit if there's no /etc/exports, or if there aren't any
  # shares defined in it.
  if [ ! -r /etc/exports ]; then # no config file, exit:
    exit
  elif ! grep -v -e '^#' -e '^$' /etc/exports | grep -q '/' ; then
    exit # no uncommented shares in /etc/exports
  fi

  echo -n "Starting UNFS server daemon(s):"

  if [ -x /sbin/rpc.portmap ]; then
    if ! ps axc | grep -q rpc.portmap ; then
      echo -n "  /sbin/rpc.portmap"
      /sbin/rpc.portmap
    fi
  
    if [ -x /usr/sbin/unfsd ]; then
      echo "  /usr/sbin/nfsd"
      /usr/sbin/unfsd
    fi
  else
    echo "WARNING:  Cannot start RPC portmapper daemon needed for UNFS."
    echo "          /sbin/rpc.portmap (a required daemon) is not executable"
    echo "          or is not present on your system."
    echo
  fi
}

unfsd_stop() {
  echo "Stopping UNFS server daemon..."
  killall unfsd 2> /dev/null
  sleep 1
  killall -9 unfsd 2> /dev/null # make sure :)
}

unfsd_restart() {
  unfsd_stop
  sleep 1
  unfsd_start
}

case "$1" in
'start')
  unfsd_start
  ;;
'stop')
  unfsd_stop
  ;;
'restart')
  unfsd_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac