#!/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_device: list of devices on which to run ataidle
# ataidle_adX: parameters to pass to ataidle(8)

# Example:
# Put the disks ad1, ad2 and ad3 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_device="ad1 ad2 ad3"
# ataidle_ad1="-I 60 -S 120 -A 127 -P 254 0 1"
# ataidle_ad2="-I 60 -S 120 -A 127 -P 254 1 0"
# ataidle_ad3="-I 60 -S 120 -A 127 -P 254 1 1"
#

. %%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}" ]; then
        for i in ${ataidle_device}; do
            eval ataidle_args=\$ataidle_${i}
            ${command} ${ataidle_args}
        done
    fi
}

run_rc_command "$1"



syntax highlighted by Code2HTML, v. 0.9.1