summaryrefslogtreecommitdiffstats
path: root/source/a/smartmontools/rc.smartd
blob: 8254b394241408c386372a0b2200784d2f579314 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# /etc/rc.d/rc.smartd
#
# Start/stop/restart the smartd daemon, which monitors the status of
# S.M.A.R.T. compatible hard drives and reports any problems.
#
# By default, smartd will scan for all ATA/SATA and SCSI/SAS hard drives
# and solid-state drives. Settings may be customized in /etc/smartd.conf.

# Import script defaults:
if [ -r /etc/default/smartd ]; then
  . /etc/default/smartd
fi
 
smart_start() {
  if [ -x /usr/sbin/smartd -a -r /etc/smartd.conf ]; then
    echo "Starting smartd:  /usr/sbin/smartd -p /run/smartd.pid $SMARTD_OPTIONS &"
    /usr/sbin/smartd -p /run/smartd.pid $SMARTD_OPTIONS &
  fi
}

smart_stop() {
  echo "Stopping smartd."
  if [ -r /run/smartd.pid ]; then
    kill $(cat /run/smartd.pid)
  else
    killall smartd
  fi
}

smart_restart() {
  smart_stop
  sleep 1
  smart_start
}

case "$1" in
'start')
  smart_start
  ;;
'stop')
  smart_stop
  ;;
'restart')
  smart_restart
  ;;
*)
  echo "Usage: $0 {start|stop|restart}"
esac