summaryrefslogtreecommitdiff
path: root/sysutils/ataidle/files/ataidle.in
blob: 4889da7ae39e257a22369372520fcf0d85e5e250 (plain) (blame)
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
#!/bin/sh

# PROVIDE: ataidle
# BEFORE: LOGIN

#
# Add the following lines to /etc/rc.conf to enable ataidle:
#
# ataidle_enable (bool): set to NO by default.
#         Set to YES to enable ataidle.
# ataidle_devices: list of devices on which to run ataidle
# ataidle_adX: parameters to pass to ataidle(8)

# Example:
# Put the disks ad0, ad1 and ad2 into Idle mode after 60
# minutes and Standby mode after 120 minutes. Also, set the
# AAM and APM values to their maximum so the drives run at
# their maximum performance.
#
# ataidle_devices="ad0 ad1 ad2"
# ataidle_ad0="-I 60 -S 120 -A 127 -P 254"
# ataidle_ad1="-I 60 -S 120 -A 127 -P 254"
# ataidle_ad2="-I 60 -S 120 -A 127 -P 254"
#

. %%RC_SUBR%%

name="ataidle"
rcvar=${name}_enable

command="%%PREFIX%%/sbin/${name}"
start_cmd="ataidle_start"

load_rc_config $name

: ${ataidle_enable="NO"}

ataidle_start()
{
	if [ -n "${ataidle_device}" -a -z "${ataidle_devices}" ]; then
		echo "warning: old ataidle rc settings found"
		ataidle_devices=${ataidle_device}
	fi

	if [ -n "${ataidle_devices}" ]; then
		for i in ${ataidle_devices}; do
			eval ataidle_args=\$ataidle_${i}
			echo "ATAidle: configuring device /dev/${i}"
			${command} ${ataidle_args} /dev/${i}
		done
	fi
}

run_rc_command "$1"