/ctdb/events.d/60.nfs

http://github.com/brinkman83/bashrc · Shell · 111 lines · 76 code · 22 blank · 13 comment · 13 complexity · 0789bfb773a7befa57f0f102ab5640ee MD5 · raw file

  1. #!/bin/sh
  2. # script to manage nfs in a clustered environment
  3. start_nfs() {
  4. /bin/mkdir -p $CTDB_BASE/state/nfs
  5. /bin/mkdir -p $CTDB_BASE/state/statd/ip
  6. /bin/mkdir -p $STATD_SHARED_DIRECTORY
  7. startstop_nfs stop
  8. startstop_nfs start
  9. }
  10. reconfigure_nfs() {
  11. # always restart the lockmanager so that we start with a clusterwide
  12. # graceperiod when ip addresses has changed
  13. [ -x $CTDB_BASE/statd-callout ] && {
  14. $CTDB_BASE/statd-callout notify &
  15. } >/dev/null 2>&1
  16. }
  17. . $CTDB_BASE/functions
  18. service_name="nfs"
  19. service_start="start_nfs"
  20. service_stop="startstop_nfs stop"
  21. service_reconfigure="reconfigure_nfs"
  22. loadconfig
  23. [ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
  24. ctdb_start_stop_service
  25. case "$1" in
  26. startup)
  27. ctdb_service_start
  28. ;;
  29. shutdown)
  30. ctdb_service_stop
  31. ;;
  32. takeip)
  33. ctdb_service_set_reconfigure
  34. touch $CTDB_BASE/state/statd/ip/$3
  35. ;;
  36. releaseip)
  37. ctdb_service_set_reconfigure
  38. /bin/rm -f $CTDB_BASE/state/statd/ip/$3
  39. ;;
  40. recovered)
  41. # if we have taken or released any ips we must
  42. # restart the lock manager so that we enter a clusterwide grace period
  43. if ctdb_service_needs_reconfigure ; then
  44. ctdb_service_reconfigure
  45. fi
  46. ;;
  47. monitor)
  48. if ctdb_service_needs_reconfigure ; then
  49. ctdb_service_reconfigure
  50. exit 0
  51. fi
  52. # check that statd responds to rpc requests
  53. # if statd is not running we try to restart it
  54. rpcinfo -u localhost 100024 1 > /dev/null || {
  55. RPCSTATDOPTS=""
  56. [ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
  57. [ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
  58. [ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
  59. rpc.statd $RPCSTATDOPTS
  60. echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
  61. }
  62. # check that NFS responds to rpc requests
  63. ctdb_check_rpc "NFS" 100003 3
  64. # and that its directories are available
  65. [ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
  66. exportfs | grep -v '^#' | grep '^/' |
  67. sed -e 's/[[:space:]]*[^[:space:]]*$//' |
  68. ctdb_check_directories
  69. } || exit $?
  70. # check that lockd responds to rpc requests
  71. ctdb_check_rpc "lockd" 100021 1
  72. echo "$STATD_SHARED_DIRECTORY" | ctdb_check_directories "statd" || \
  73. exit $?
  74. # mount needs special handling since it is sometimes not started
  75. # correctly on RHEL5
  76. rpcinfo -u localhost 100005 1 > /dev/null || {
  77. echo "ERROR: MOUNTD is not running. Trying to restart it."
  78. RPCMOUNTDOPTS=""
  79. [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
  80. killall -q -9 rpc.mountd
  81. rpc.mountd $RPCMOUNTDOPTS &
  82. exit 1
  83. }
  84. ;;
  85. *)
  86. ctdb_standard_event_handler "$@"
  87. ;;
  88. esac
  89. exit 0