smartd 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #! /bin/sh
  2. # smartmontools init file for smartd
  3. ### BEGIN INIT INFO
  4. # Provides: smartd
  5. # Required-Start: $syslog $remote_fs
  6. # Should-Start: sendmail
  7. # Required-Stop: $syslog $remote_fs
  8. # Should-Stop: sendmail
  9. # Default-Start: 2 3 5
  10. # Default-Stop:
  11. # Short-Description: Monitors disk and tape health via S.M.A.R.T.
  12. # Description: Start S.M.A.R.T. disk and tape monitor.
  13. ### END INIT INFO
  14. source /lib/lsb/init-functions
  15. # Source configuration file. This should define the shell variable smartd_opts
  16. [ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
  17. SMARTD_BIN=/usr/sbin/smartd
  18. pidfile=/run/lock/smartd
  19. config=/etc/smartd.conf
  20. case "$1" in
  21. start)
  22. log_info_msg "Starting smartd... "
  23. if [ ! -f $config ]; then
  24. log_info_msg2 "configuration file $config missing"
  25. failed=1
  26. elif start_daemon $SMARTD_BIN $smartd_opts; then
  27. touch $pidfile
  28. else
  29. failed=1
  30. fi
  31. (exit $failed)
  32. evaluate_retval
  33. ;;
  34. stop)
  35. log_info_msg "Stopping smartd... "
  36. killproc $SMARTD_BIN
  37. evaluate_retval
  38. rm -f $pidfile
  39. ;;
  40. report)
  41. log_info_msg "Checking SMART devices now... "
  42. killproc $SMARTD_BIN -USR1
  43. evaluate_retval
  44. ;;
  45. reload)
  46. log_info_msg "Reloading smartd daemon configuration... "
  47. killproc $SMARTD_BIN -HUP
  48. evaluate_retval
  49. ;;
  50. restart)
  51. $0 stop
  52. sleep 1
  53. $0 start
  54. ;;
  55. status)
  56. statusproc $SMARTD_BIN
  57. ;;
  58. *)
  59. echo "Usage: $0 {start|stop|report|reload|restart|status}"
  60. exit 1
  61. ;;
  62. esac