/rc4.d/S25mdadm

http://github.com/brinkman83/bashrc · Shell · 79 lines · 49 code · 8 blank · 22 comment · 5 complexity · 62dd8d0b38179b325bc11aa5f80357e2 MD5 · raw file

  1. #!/bin/sh
  2. #
  3. # Start the MD monitor daemon for all active MD arrays if desired.
  4. #
  5. # Copyright © 2001-2005 Mario Jou/3en <joussen@debian.org>
  6. # Copyright © 2005-2008 Martin F. Krafft <madduck@debian.org>
  7. # Distributable under the terms of the GNU GPL version 2.
  8. #
  9. ### BEGIN INIT INFO
  10. # Provides: mdadm
  11. # Required-Start: checkroot
  12. # Required-Stop: umountroot
  13. # Should-Start: module-init-tools
  14. # Default-Start: S
  15. # Default-Stop: 0 6
  16. # Short-Description: MD monitoring daemon
  17. # Description: mdadm provides a monitor mode, in which it will scan for
  18. # problems with the MD devices. If a problem is found, the
  19. # administrator is alerted via email, or a custom script is
  20. # run.
  21. ### END INIT INFO
  22. #
  23. set -eu
  24. MDADM=/sbin/mdadm
  25. RUNDIR=/var/run/mdadm
  26. PIDFILE=$RUNDIR/monitor.pid
  27. DEBIANCONFIG=/etc/default/mdadm
  28. test -x "$MDADM" || exit 0
  29. test -f /proc/mdstat || exit 0
  30. START_DAEMON=true
  31. test -f $DEBIANCONFIG && . $DEBIANCONFIG
  32. . /lib/lsb/init-functions
  33. is_true()
  34. {
  35. case "${1:-}" in
  36. [Yy]es|[Yy]|1|[Tt]|[Tt]rue) return 0;;
  37. *) return 1;
  38. esac
  39. }
  40. case "${1:-}" in
  41. start)
  42. if is_true $START_DAEMON; then
  43. log_daemon_msg "Starting MD monitoring service" "mdadm --monitor"
  44. mkdir -p $RUNDIR
  45. set +e
  46. start-stop-daemon -S -p $PIDFILE -x $MDADM -- \
  47. --monitor --pid-file $PIDFILE --daemonise --scan ${DAEMON_OPTIONS:-}
  48. log_end_msg $?
  49. set -e
  50. fi
  51. ;;
  52. stop)
  53. if [ -f $PIDFILE ] ; then
  54. log_daemon_msg "Stopping MD monitoring service" "mdadm --monitor"
  55. set +e
  56. start-stop-daemon -K -p $PIDFILE -x $MDADM
  57. rm -f $PIDFILE
  58. log_end_msg $?
  59. set -e
  60. fi
  61. ;;
  62. restart|reload|force-reload)
  63. ${0:-} stop
  64. ${0:-} start
  65. ;;
  66. *)
  67. echo "Usage: ${0:-} {start|stop|restart|reload|force-reload}" >&2
  68. exit 1
  69. ;;
  70. esac
  71. exit 0