raid 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh -e
  2. #
  3. # raid: notify raid events, failures and syncing
  4. #
  5. # Copyright (C) 2010 Canonical Ltd.
  6. # Copyright (C) 2011-2014 Dustin Kirkland
  7. #
  8. # Authors: Dustin Kirkland <kirkland@byobu.org>
  9. #
  10. # This program is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation, version 3 of the License.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. __raid_detail() {
  22. [ -r /proc/mdstat ] && cat /proc/mdstat || true
  23. }
  24. __raid() {
  25. [ -r /proc/mdstat ] || return
  26. while read line; do
  27. local p msg
  28. # Errors in your raid
  29. case "$line" in
  30. *\ blocks\ *\[*_*\])
  31. [ -z "${msg}" ] && msg="RAID"
  32. ;;
  33. *%*)
  34. p="${line%%\%*}${PCT}"; p=${p##* };
  35. [ -z "$msg" ] && msg="RAID"
  36. msg="$msg,$p"
  37. ;;
  38. esac
  39. done < /proc/mdstat
  40. if [ -n "$msg" ]; then
  41. color B w r; printf "%s" "$msg"; color --
  42. elif [ -e "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/raid" ]; then
  43. # Clear out cached raid message
  44. rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/raid"*
  45. fi
  46. }
  47. # vi: syntax=sh ts=4 noexpandtab