summaryrefslogtreecommitdiffstats
path: root/smartd.freebsd.initd.in
blob: cac843201888b704880a4a26ed0f77f01657b351 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh

# $FreeBSD: ports/sysutils/smartmontools/files/smartd.in,v 1.4 2012/02/15 08:46:57 dougb Exp $
#
# 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:="/usr/local/etc/smartd.conf"}
pidfile=${smartd_pidfile:="/var/run/smartd.pid"}

command="/usr/local/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"