]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - smartd.freebsd.initd.in
Updated changelog
[mirror_smartmontools-debian.git] / smartd.freebsd.initd.in
CommitLineData
a7e8ffec
GI
1#!/bin/sh
2# $FreeBSD: ports/sysutils/smartmontools/files/smartd.in,v 1.2 2010/03/27 00:15:05 dougb Exp $
3
4# PROVIDE: smartd
5# REQUIRE: DAEMON
6# BEFORE: LOGIN
7# KEYWORD: shutdown nojail
8
9# Define these smartd_* variables in one of these files:
10# /etc/rc.conf
11# /etc/rc.conf.local
12# /etc/rc.conf.d/smartd
13#
14# DO NOT CHANGE THESE DEFAULT VALUES HERE
15#
16smartd_enable="${smartd_enable-NO}"
17smartd_pidfile="/var/run/smartd.pid"
18
19. /etc/rc.subr
20
21name="smartd"
22rcvar=`set_rcvar`
23command="/usr/local/sbin/smartd"
24extra_commands="reload report"
25reload_cmd="smartd_reload"
26report_cmd="smartd_report"
27
28smartd_reload()
29{
30 rc_pid=$(check_pidfile $pidfile $command)
31 if [ -z "$rc_pid" ]; then
32 [ -n "$rc_fast" ] && return 0
33 _run_rc_notrunning
34 return 1
35 fi
36 echo 'Reloading smartd.'
37 kill -HUP $rc_pid
38}
39
40smartd_report()
41{
42 rc_pid=$(check_pidfile $pidfile $command)
43 if [ -z "$rc_pid" ]; then
44 [ -n "$rc_fast" ] && return 0
45 _run_rc_notrunning
46 return 1
47 fi
48 echo 'Checking SMART devices now.'
49 kill -USR1 $rc_pid
50}
51
52load_rc_config $name
53
54: ${smartd_config="/usr/local/etc/smartd.conf"}
55: ${smartd_flags="-c ${smartd_config}"}
56
57pidfile="${smartd_pidfile}"
58required_files="${smartd_config}"
59
60case "${smartd_flags}" in
61*-p\ *)
62 echo "ERROR: \$smartd_flags includes -p option." \
63 "Please use \$smartd_pidfile instead."
64 exit 1
65 ;;
66*)
67 smartd_flags="-p ${pidfile} ${smartd_flags}"
68 ;;
69esac
70
71run_rc_command "$1"