freebsd-ports/sysutils/smartmontools/files/smartd.in
Doug Barton 16b13f3515 This change has various simplifications/improvements for
the port. Most importantly, it's currently installing the rc.d
script from the source, rather than the fixed one in files/.

1. Remove 6.x compatibility hack
2. Use the PORTDOCS macro
3. Actually install the rc.d script in files/
4. Simplify pkg-plist
5. For the rc.d script:
   a. Move it to the standard location, after LOGIN
   b. Add KEYWORD nojail per the script in the distfiles
   c. Put the standard arguments in their usual order/formats
   d. Simplify the assignments of pidfile and required_files
   e. Use command_args for required arguments, don't abuse _flags
   f. The test for -p in smartd_flags should be a start_precmd,
      we frown on running any code unconditionally.
      Also, improve this check if -p is first.
   g. Bring the reload and report options from the distfile version,
      and simplify them.

PR:		ports/165167
Submitted by:	me
Approved by:	Alex Samorukov <samm@os2.kiev.ua> (maintainer)
2012-02-15 08:46:57 +00:00

70 lines
1.1 KiB
Bash

#!/bin/sh
# $FreeBSD$
#
# PROVIDE: smartd
# REQUIRE: LOGIN
# KEYWORD: shutdown nojail
#
# Define these smartd_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/smartd
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
. /etc/rc.subr
name=smartd
rcvar=smartd_enable
load_rc_config smartd
: ${smartd_enable:="NO"}
required_files=${smartd_config:="%%PREFIX%%/etc/smartd.conf"}
pidfile=${smartd_pidfile:="/var/run/smartd.pid"}
command="%%PREFIX%%/sbin/smartd"
command_args="-c ${required_files} -p ${pidfile}"
extra_commands="reload report"
reload_cmd="smartd_reload"
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()
{
local status
if ! status=`run_rc_command status 2>&1`; then
echo $status
return 1
fi
echo 'Reloading smartd.'
kill -HUP $rc_pid
}
smartd_report()
{
local status
if ! status=`run_rc_command status 2>&1`; then
echo $status
return 1
fi
echo 'Checking SMART devices now.'
kill -USR1 $rc_pid
}
run_rc_command "$1"