Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # smartmontools init file for smartd |
| 4 | # Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net> |
| 5 | # $Id: smartd.initd.in 3360 2011-06-06 19:25:36Z chrfranke $ |
| 6 | |
| 7 | # For RedHat and cousins: |
| 8 | # chkconfig: - 60 60 |
| 9 | # description: Self Monitoring and Reporting Technology (SMART) Daemon |
| 10 | # processname: smartd |
| 11 | |
| 12 | # For SuSE and cousins |
| 13 | ### BEGIN INIT INFO |
| 14 | # Provides: smartd |
| 15 | # Required-Start: $syslog $remote_fs |
| 16 | # Should-Start: sendmail |
| 17 | # Required-Stop: $syslog $remote_fs |
| 18 | # Should-Stop: sendmail |
| 19 | # Default-Start: 2 3 4 5 |
| 20 | # Default-Stop: 0 1 6 |
| 21 | # Short-Description: Monitors disk and tape health via S.M.A.R.T. |
| 22 | # Description: Start S.M.A.R.T. disk and tape monitor. |
| 23 | ### END INIT INFO |
| 24 | |
| 25 | # This program is free software; you can redistribute it and/or modify it |
| 26 | # under the terms of the GNU General Public License as published by the Free |
| 27 | # Software Foundation; either version 2, or (at your option) any later |
| 28 | # version. |
| 29 | # You should have received a copy of the GNU General Public License (for |
| 30 | # example COPYING); if not, write to the Free Software Foundation, Inc., 675 |
| 31 | # Mass Ave, Cambridge, MA 02139, USA. |
| 32 | # This code was originally developed as a Senior Thesis by Michael Cornwell |
| 33 | # at the Concurrent Systems Laboratory (now part of the Storage Systems |
| 34 | # Research Center), Jack Baskin School of Engineering, University of |
| 35 | # California, Santa Cruz. http://ssrc.soe.ucsc.edu/. |
| 36 | |
| 37 | # Uncomment the line below to pass options to smartd on startup. |
| 38 | # Note that distribution specific configuration files like |
| 39 | # /etc/{default,sysconfig}/smartmontools might override these |
| 40 | #smartd_opts="--interval=1800" |
| 41 | |
| 42 | SMARTD_BIN=/usr/sbin/smartd |
| 43 | SMARTDPID=/var/run/smartd.pid |
| 44 | [ -x $SMARTD_BIN ] || exit 0 |
| 45 | RET=0 |
| 46 | |
| 47 | # source configuration file |
| 48 | [ -r /etc/default/rcS ] && . /etc/default/rcS |
| 49 | [ -r /etc/default/smartmontools ] && . /etc/default/smartmontools |
| 50 | |
| 51 | smartd_opts="--pidfile $SMARTDPID $smartd_opts" |
| 52 | |
| 53 | case "$1" in |
| 54 | start) |
| 55 | if [ "$start_smartd" != "yes" ]; then |
| 56 | [ "$VERBOSE" != "no" ] && echo "Not starting S.M.A.R.T. daemon smartd, disabled via /etc/default/smartmontools" |
| 57 | exit 0 |
| 58 | fi |
| 59 | echo -n "Starting S.M.A.R.T. daemon: smartd" |
| 60 | if start-stop-daemon --start --quiet --pidfile $SMARTDPID \ |
| 61 | --exec $SMARTD_BIN -- $smartd_opts; then |
| 62 | echo "." |
| 63 | else |
| 64 | echo " (failed)" |
| 65 | RET=1 |
| 66 | fi |
| 67 | ;; |
| 68 | stop) |
| 69 | echo -n "Stopping S.M.A.R.T. daemon: smartd" |
| 70 | start-stop-daemon --stop --quiet --oknodo --pidfile $SMARTDPID |
| 71 | echo "." |
| 72 | ;; |
| 73 | restart) |
| 74 | $0 stop |
| 75 | $0 start |
| 76 | ;; |
| 77 | force-reload) |
| 78 | $0 reload || $0 restart |
| 79 | ;; |
| 80 | reload) |
| 81 | echo -n "Reload S.M.A.R.T. daemon: smartd" |
| 82 | if start-stop-daemon --stop --quiet --signal 1 \ |
| 83 | --pidfile $SMARTDPID; then |
| 84 | echo "." |
| 85 | else |
| 86 | echo " (failed)" |
| 87 | RET=1 |
| 88 | fi |
| 89 | ;; |
| 90 | report) |
| 91 | echo -n "Checking SMART devices now" |
| 92 | if start-stop-daemon --stop --quiet --signal 10 \ |
| 93 | --pidfile $SMARTDPID; then |
| 94 | echo "." |
| 95 | else |
| 96 | echo " (failed)" |
| 97 | RET=1 |
| 98 | fi |
| 99 | ;; |
| 100 | status) |
| 101 | if pidof $SMARTD_BIN >/dev/null; then |
| 102 | echo "$SMARTD_BIN is running." |
| 103 | else |
| 104 | echo "$SMARTD_BIN is not running." |
| 105 | RET=1 |
| 106 | fi |
| 107 | ;; |
| 108 | *) |
| 109 | echo "Usage: $0 {start|stop|restart|force-reload|reload|report|status}" |
| 110 | exit 1 |
| 111 | esac |
| 112 | exit $RET |