3 # smartmontools init.d startup script
5 # (C) 2003,04,07 Guido Günther <agx@sigxcpu.org>
7 # loosely based on the init script that comes with smartmontools which is
8 # copyrighted 2002 by Bruce Allen <smartmontools-support@lists.sourceforge.net>
11 # Provides: smartmontools
12 # Required-Start: $syslog $remote_fs
13 # Required-Stop: $syslog $remote_fs
14 # Default-Start: 2 3 4 5
16 # Short-Description: SMART monitoring daemon
19 SMARTCTL
=/usr
/sbin
/smartctl
20 SMARTD
=/usr
/sbin
/smartd
21 SMARTDPID
=/var
/run
/smartd.pid
22 [ -x $SMARTCTL ] ||
exit 0
23 [ -x $SMARTD ] ||
exit 0
24 .
/lib
/lsb
/init-functions
28 [ -r /etc
/default
/smartmontools
] && .
/etc
/default
/smartmontools
30 smartd_opts
="--pidfile $SMARTDPID $smartd_opts"
33 log_action_begin_msg
"Enabling S.M.A.R.T."
34 for device
in $enable_smart; do
35 log_action_cont_msg
"$device"
36 if ! $SMARTCTL --quietmode=errorsonly
--smart=on
$device; then
37 log_action_cont_msg
"(failed)"
44 check_start_smartd_option
() {
45 if [ ! "$start_smartd" = "yes" ]; then
46 log_warning_msg
"Not starting S.M.A.R.T. daemon smartd, disabled via /etc/default/smartmontools"
55 [ -n "$enable_smart" ] && enable_smart
56 if check_start_smartd_option
; then
58 log_daemon_msg
"Starting S.M.A.R.T. daemon" "smartd"
59 if start-stop-daemon
--start --quiet --pidfile $SMARTDPID \
60 --exec $SMARTD -- $smartd_opts; then
69 log_daemon_msg
"Stopping S.M.A.R.T. daemon" "smartd"
70 start-stop-daemon
--stop --quiet --oknodo --pidfile $SMARTDPID
74 log_daemon_msg
"Reloading S.M.A.R.T. daemon" "smartd"
75 if start-stop-daemon
--stop --quiet --signal 1 \
76 --pidfile $SMARTDPID; then
84 if check_start_smartd_option
; then
85 log_daemon_msg
"Restarting S.M.A.R.T. daemon" "smartd"
86 start-stop-daemon
--stop --quiet --oknodo --retry 30 --pidfile $SMARTDPID
88 if start-stop-daemon
--start --quiet --pidfile $SMARTDPID \
89 --exec $SMARTD -- $smartd_opts; then
98 echo "Usage: /etc/init.d/smartmontools {start|stop|restart|reload|force-reload}"