]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - smartd.initd.in
3 # smartmontools init file for smartd
4 # Copyright (C) 2002-8 Bruce Allen
5 # SPDX-License-Identifier: GPL-2.0-or-later
6 # $Id: smartd.initd.in 4760 2018-08-19 18:45:53Z chrfranke $
8 # For RedHat and cousins:
9 # chkconfig: 2345 40 40
10 # description: Self Monitoring and Reporting Technology (SMART) Daemon
13 # For SuSE and cousins
16 # Required-Start: $syslog $remote_fs
17 # Should-Start: sendmail
18 # Required-Stop: $syslog $remote_fs
19 # Should-Stop: sendmail
20 # Default-Start: 2 3 5
22 # Short-Description: Monitors disk and tape health via S.M.A.R.T.
23 # Description: Start S.M.A.R.T. disk and tape monitor.
26 # Uncomment the line below to pass options to smartd on startup.
27 # Note that distribution specific configuration files like
28 # /etc/{default,sysconfig}/smartmontools might override these
29 #smartd_opts="--interval=1800"
31 SMARTD_BIN
=/usr
/local
/sbin
/smartd
33 report_unsupported
() {
34 echo "Currently the smartmontools package has no init script for"
35 echo "the $1 OS/distribution. If you can provide one or this"
36 echo "one works after removing some ifdefs, please contact"
37 echo "smartmontools-support@listi.jpberlin.de."
41 # Red Hat or Yellow Dog or Mandrake
42 if [ -f /etc
/redhat-release
-o -f /etc
/yellowdog-release
-o -f /etc
/mandrake-release
-o -f /etc
/whitebox-release
-o -f /etc
/trustix-release
-o -f /etc
/tinysofa-release
] ; then
44 # Source function library
45 .
/etc
/rc.d
/init.d
/functions
47 # Source configuration file. This should define the shell variable smartd_opts
48 [ -r /etc
/sysconfig
/smartmontools
] && .
/etc
/sysconfig
/smartmontools
53 pidfile
=/var
/lock
/subsys
/smartd
54 config
=/etc
/smartd.conf
58 [ $UID -eq 0 ] ||
exit 4
59 [ -x $SMARTD_BIN ] ||
exit 5
60 [ -f $config ] ||
exit 6
61 echo -n $
"Starting $prog: "
62 daemon
$SMARTD_BIN $smartd_opts
65 [ $RETVAL = 0 ] && touch $pidfile
71 [ $UID -eq 0 ] ||
exit 4
72 echo -n $
"Shutting down $prog: "
82 echo -n $
"Reloading $prog daemon configuration: "
83 killproc
$SMARTD_BIN -HUP
91 echo -n $
"Checking SMART devices now: "
92 killproc
$SMARTD_BIN -USR1
115 condrestart|try-restart
)
116 if [ -f $pidfile ]; then
122 reload ||
(stop
; start
)
129 echo $
"Usage: $0 {start|stop|restart|status|condrestart|try-restart|reload|force-reload|report}"
131 [ "$1" = 'usage' ] && RETVAL
=0
136 elif [ -f /etc
/slackware-version
] ; then
138 # Source configuration file. This should define the shell variable smartd_opts.
139 # Email smartmontools-support mailing list if there is a better choice
140 # of path for Slackware.
142 [ -r /etc
/sysconfig
/smartmontools
] && .
/etc
/sysconfig
/smartmontools
147 echo -n "Starting smartd: "
148 $SMARTD_BIN $smartd_opts
153 echo -n "Shutting down smartd: "
165 if pidof
$SMARTD_BIN >/dev
/null
; then
171 $0 reload ||
$0 restart
175 echo -n "Reloading smartd configuration: "
176 killall
-s HUP
$SMARTD_BIN
181 echo -n "Checking SMART devices now: "
182 killall
-s USR1
$SMARTD_BIN
187 if pidof
$SMARTD_BIN >/dev
/null
; then
188 echo "$SMARTD_BIN is running."
190 echo "$SMARTD_BIN is not running."
195 echo "Usage: $0 {start|stop|restart|try-restart|force-reload|reload|report|status}"
201 elif [ -f /etc
/SuSE-release
] ; then
202 test -x $SMARTD_BIN ||
exit 5
204 # Existence of config file is optional
205 SMARTD_CONFIG
=/etc
/smartd.conf
207 # source configuration file.
208 [ -r /etc
/sysconfig
/smartmontools
] && .
/etc
/sysconfig
/smartmontools
210 if test -n "$SMARTD_CHECK_INTERVAL" -a "$SMARTD_CHECK_INTERVAL" != 1800 ; then
211 smartd_opts
=" -i $SMARTD_CHECK_INTERVAL"
213 if test -n "$SMARTD_LOG_FACILITY" -a "$SMARTD_LOG_FACILITY" != "daemon" ; then
214 smartd_opts
="$smartd_opts -l $SMARTD_LOG_FACILITY"
216 if test -n "$SMARTD_DRIVEDB" ; then
217 smartd_opts
="$smartd_opts -B $SMARTD_DRIVEDB"
219 if test "$SMARTD_SAVESTATES" = "no" ; then
220 smartd_opts
="$smartd_opts -s \"\""
222 if test "$SMARTD_ATTRLOG" = "no" ; then
223 smartd_opts
="$smartd_opts -A \"\""
225 if test -n "$SMARTD_EXTRA_OPTS" ; then
226 smartd_opts
="$smartd_opts $SMARTD_EXTRA_OPTS"
229 # Shell functions sourced from /etc/rc.status:
230 # rc_check check and set local and overall rc status
231 # rc_status check and set local and overall rc status
232 # rc_status -v be verbose in local rc status and clear it afterwards
233 # rc_status -v -r ditto and clear both the local and overall rc status
234 # rc_status -s display "skipped" and exit with status 3
235 # rc_status -u display "unused" and exit with status 3
236 # rc_failed set local and overall rc status to failed
237 # rc_failed <num> set local and overall rc status to <num>
238 # rc_reset clear both the local and overall rc status
239 # rc_exit exit appropriate to overall rc status
240 # rc_active checks whether a service is activated by symlinks
243 # Reset status of this service
246 # Return values acc. to LSB for all commands but status:
248 # 1 - generic or unspecified error
249 # 2 - invalid or excess argument(s)
250 # 3 - unimplemented feature (e.g. "reload")
251 # 4 - user had insufficient privileges
252 # 5 - program is not installed
253 # 6 - program is not configured
254 # 7 - program is not running
255 # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
257 # Note that starting an already running service, stopping
258 # or restarting a not-running service as well as the restart
259 # with force-reload (in case signaling is not supported) are
260 # considered a success.
264 echo -n "Starting smartd "
265 ## Start daemon with startproc(8). If this fails
266 ## the return value is set appropriately by startproc.
268 # We don't use startproc - we need to check for return code 17.
269 if ! /sbin
/checkproc
$SMARTD_BIN ; then
270 eval $SMARTD_BIN$smartd_opts
271 # Remember status and be verbose
272 if test $?
-ne 17 ; then
283 echo -n "Shutting down smartd "
284 /sbin
/killproc
-TERM $SMARTD_BIN
285 # Remember status and be verbose
289 ## Do a restart only if the service was active before.
290 ## Note: try-restart is now part of LSB (as of 1.9).
295 rc_reset
# Not running is not a failure.
297 # Remember status and be quiet
303 # Remember status and be quiet
307 echo -n "Reload service smartd "
308 /sbin
/killproc
-HUP $SMARTD_BIN
312 ## Checking SMART devices now (smartd specific function)
313 echo -n "Checking SMART devices now "
314 /sbin
/killproc
-USR1 $SMARTD_BIN
318 echo -n "Checking for service smartd "
319 ## Check status with checkproc(8), if process is running
320 ## checkproc will return with exit status 0.
322 # Return value is slightly different for the status command:
323 # 0 - service up and running
324 # 1 - service dead, but /var/run/ pid file exists
325 # 2 - service dead, but /var/lock/ lock file exists
326 # 3 - service not running (unused)
327 # 4 - service status unknown :-(
328 # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
330 # NOTE: checkproc returns LSB compliant status values.
331 /sbin
/checkproc
$SMARTD_BIN
335 ## Optional: Probe for the necessity of a reload, print out the
336 ## argument to this init script which is required for a reload.
337 ## Note: probe is not (yet) part of LSB (as of 1.9)
339 test $SMARTD_CONFIG -nt /var
/run
/smartd.pid
&& echo reload
342 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|report|probe}"
348 elif [ -f /etc
/debian_version
] ; then
349 PATH
=/usr
/local
/sbin
:/usr
/local
/bin
:/sbin
:/bin
:/usr
/sbin
:/usr
/bin
350 SMARTDPID
=/var
/run
/smartd.pid
351 [ -x $SMARTD_BIN ] ||
exit 0
354 # source configuration file
355 [ -r /etc
/default
/rcS
] && .
/etc
/default
/rcS
356 [ -r /etc
/default
/smartmontools
] && .
/etc
/default
/smartmontools
358 smartd_opts
="--pidfile $SMARTDPID $smartd_opts"
362 echo -n "Starting S.M.A.R.T. daemon: smartd"
363 if start-stop-daemon
--start --quiet --pidfile $SMARTDPID \
364 --exec $SMARTD_BIN -- $smartd_opts; then
372 echo -n "Stopping S.M.A.R.T. daemon: smartd"
373 start-stop-daemon
--stop --quiet --oknodo --pidfile $SMARTDPID
381 $0 reload ||
$0 restart
384 echo -n "Reload S.M.A.R.T. daemon: smartd"
385 if start-stop-daemon
--stop --quiet --signal 1 \
386 --pidfile $SMARTDPID; then
394 echo -n "Checking SMART devices now"
395 if start-stop-daemon
--stop --quiet --signal 10 \
396 --pidfile $SMARTDPID; then
404 if pidof
$SMARTD_BIN >/dev
/null
; then
405 echo "$SMARTD_BIN is running."
407 echo "$SMARTD_BIN is not running."
412 echo "Usage: $0 {start|stop|restart|force-reload|reload|report|status}"
417 elif [ -f /etc
/gentoo-release
] ; then
418 report_unsupported
"Gentoo"
420 elif [ -f /etc
/turbolinux-release
] ; then
421 report_unsupported
"Turbolinux"
423 elif [ -f /etc
/environment.corel
] ; then
424 report_unsupported
"Corel"
426 # PLEASE ADD OTHER LINUX DISTRIBUTIONS JUST BEFORE THIS LINE, USING elif
428 elif uname
-a |
grep SunOS
> /dev
/null
2>&1 ; then
430 # Source configuration file. This should define the shell variable smartd_opts.
431 # Email smartmontools-support mailing list if there is a better choice
432 # of path for Solaris
434 [ -r /etc
/default
/smartmontools
] && .
/etc
/default
/smartmontools
436 PID_FILE
=/var
/run
/smartd.pid
440 $SMARTD_BIN -p $PID_FILE $smartd_opts
444 [ -f $PID_FILE ] && kill `cat $PID_FILE`
453 kill -s HUP
`cat $PID_FILE`
456 kill -s USR1
`cat $PID_FILE`
459 echo "Usage: $0 {start|stop|restart|reload|report}"
464 # Add other OSes HERE, using elif...
466 report_unsupported
"Unknown"
469 # One should NEVER arrive here, except for a badly written case above,
470 # that fails to exit.
471 echo "SOMETHING IS WRONG WITH THE SMARTD STARTUP SCRIPT"
472 echo "PLEASE CONTACT smartmontools-support@listi.jpberlin.de"