S60nfs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/sh
  2. #
  3. # nfs This shell script takes care of starting and stopping
  4. # the NFS services. Stolen from RedHat FC5.
  5. [ -x /usr/sbin/rpc.statd ] || exit 0
  6. [ -x /usr/sbin/rpc.nfsd ] || exit 0
  7. [ -x /usr/sbin/rpc.mountd ] || exit 0
  8. [ -x /usr/sbin/exportfs ] || exit 0
  9. # Don't fail if /etc/exports doesn't exist; create a bare-bones version and continue.
  10. [ -r /etc/exports ] || \
  11. { touch /etc/exports && chmod u+rw,g+r,o+r /etc/exports ; } || \
  12. { echo "/etc/exports does not exist" ; exit 0 ; }
  13. # The /var/lib/nfs directory is actually on a tmpfs filesystem.
  14. mkdir -p /var/lib/nfs/sm
  15. mkdir -p /var/lib/nfs/sm.bak
  16. touch /var/lib/nfs/etab
  17. touch /var/lib/nfs/rmtab
  18. touch /var/lib/nfs/state
  19. touch /var/lib/nfs/xtab
  20. start() {
  21. # Start daemons.
  22. echo -n "Starting NFS statd: "
  23. rpc.statd
  24. touch /var/lock/subsys/nfslock
  25. echo "done"
  26. echo -n "Starting NFS services: "
  27. /usr/sbin/exportfs -r
  28. rpc.statd
  29. echo "done"
  30. echo -n "Starting NFS daemon: "
  31. rpc.nfsd 2
  32. echo "done"
  33. echo -n "Starting NFS mountd: "
  34. rpc.mountd
  35. echo "done"
  36. touch /var/lock/subsys/nfs
  37. }
  38. stop() {
  39. # Stop daemons.
  40. echo -n "Shutting down NFS mountd: "
  41. killall -q rpc.mountd
  42. echo "done"
  43. echo "Shutting down NFS daemon: "
  44. kill -9 `pidof nfsd` 2>/dev/null
  45. echo "done"
  46. echo -n "Shutting down NFS services: "
  47. /usr/sbin/exportfs -au
  48. rm -f /var/lock/subsys/nfs
  49. killall -q rpc.statd
  50. echo "done"
  51. echo -n "Stopping NFS statd: "
  52. killall -q rpc.statd
  53. echo "done"
  54. rm -f /var/lock/subsys/nfslock
  55. }
  56. # See how we were called.
  57. case "$1" in
  58. start)
  59. start
  60. ;;
  61. stop)
  62. stop
  63. ;;
  64. restart)
  65. stop
  66. start
  67. ;;
  68. reload)
  69. /usr/sbin/exportfs -r
  70. touch /var/lock/subsys/nfs
  71. ;;
  72. *)
  73. echo "Usage: nfs {start|stop|reload}"
  74. exit 1
  75. esac
  76. exit 0