version 1.1.1.1, 2012/02/21 16:32:16
|
version 1.1.1.2, 2012/10/09 09:36:45
|
Line 1
|
Line 1
|
#!/bin/sh |
#!/bin/sh |
# $FreeBSD: ports/sysutils/smartmontools/files/smartd.in,v 1.2 2010/03/27 00:15:05 dougb Exp $ |
|
|
|
|
# $FreeBSD: ports/sysutils/smartmontools/files/smartd.in,v 1.4 2012/02/15 08:46:57 dougb Exp $ |
|
# |
# PROVIDE: smartd |
# PROVIDE: smartd |
# REQUIRE: DAEMON | # REQUIRE: LOGIN |
# BEFORE: LOGIN | |
# KEYWORD: shutdown nojail |
# KEYWORD: shutdown nojail |
| # |
# Define these smartd_* variables in one of these files: |
# Define these smartd_* variables in one of these files: |
# /etc/rc.conf | # /etc/rc.conf |
# /etc/rc.conf.local | # /etc/rc.conf.local |
# /etc/rc.conf.d/smartd | # /etc/rc.conf.d/smartd |
# |
# |
# DO NOT CHANGE THESE DEFAULT VALUES HERE |
# DO NOT CHANGE THESE DEFAULT VALUES HERE |
# |
|
smartd_enable="${smartd_enable-NO}" |
|
smartd_pidfile="/var/run/smartd.pid" |
|
|
|
. /etc/rc.subr |
. /etc/rc.subr |
|
|
name="smartd" | name=smartd |
rcvar=`set_rcvar` | rcvar=smartd_enable |
| |
| load_rc_config smartd |
| |
| : ${smartd_enable:="NO"} |
| |
| required_files=${smartd_config:="/usr/local/etc/smartd.conf"} |
| pidfile=${smartd_pidfile:="/var/run/smartd.pid"} |
| |
command="/usr/local/sbin/smartd" |
command="/usr/local/sbin/smartd" |
|
command_args="-c ${required_files} -p ${pidfile}" |
|
|
extra_commands="reload report" |
extra_commands="reload report" |
reload_cmd="smartd_reload" |
reload_cmd="smartd_reload" |
report_cmd="smartd_report" |
report_cmd="smartd_report" |
|
|
|
start_precmd=smartd_prestart |
|
|
|
smartd_prestart() |
|
{ |
|
case "${smartd_flags}" in |
|
-p*|*-p*) |
|
err 1 'smartd_flags includes the -p option, use smartd_pidfile instead' |
|
;; |
|
esac |
|
} |
|
|
smartd_reload() |
smartd_reload() |
{ |
{ |
rc_pid=$(check_pidfile $pidfile $command) | local status |
if [ -z "$rc_pid" ]; then | |
[ -n "$rc_fast" ] && return 0 | if ! status=`run_rc_command status 2>&1`; then |
_run_rc_notrunning | echo $status |
return 1 | return 1 |
fi | fi |
echo 'Reloading smartd.' | echo 'Reloading smartd.' |
kill -HUP $rc_pid | kill -HUP $rc_pid |
} |
} |
|
|
smartd_report() |
smartd_report() |
{ |
{ |
rc_pid=$(check_pidfile $pidfile $command) | local status |
if [ -z "$rc_pid" ]; then | |
[ -n "$rc_fast" ] && return 0 | |
_run_rc_notrunning | |
return 1 | |
fi | |
echo 'Checking SMART devices now.' | |
kill -USR1 $rc_pid | |
} | |
|
|
load_rc_config $name | if ! status=`run_rc_command status 2>&1`; then |
| echo $status |
: ${smartd_config="/usr/local/etc/smartd.conf"} | return 1 |
: ${smartd_flags="-c ${smartd_config}"} | fi |
| echo 'Checking SMART devices now.' |
pidfile="${smartd_pidfile}" | kill -USR1 $rc_pid |
required_files="${smartd_config}" | } |
| |
case "${smartd_flags}" in | |
*-p\ *) | |
echo "ERROR: \$smartd_flags includes -p option." \ | |
"Please use \$smartd_pidfile instead." | |
exit 1 | |
;; | |
*) | |
smartd_flags="-p ${pidfile} ${smartd_flags}" | |
;; | |
esac | |
|
|
run_rc_command "$1" |
run_rc_command "$1" |