Menu

[r2016]: / trunk / etc / rc.d / ataidle  Maximize  Restore  History

Download this file

53 lines (40 with data), 1.3 kB

#!/bin/sh
# Copyright (c) 2007 Volker Theile (votdev@gmx.de)
# All rights reserved.

# PROVIDE: ataidle
# REQUIRE: DAEMON
# BEFORE: LOGIN

. /etc/rc.subr
. /etc/configxml.subr

echo -n "Initializing idle timer/UDMA on ATA disks: "

# Process all configured IDE disks.
/usr/local/bin/xml sel -t -m "//disks/disk[type = 'IDE']" \
	-v "concat(name,' ',udma,' ',harddiskstandby,' ',apm,' ',acoustic)" \
	-i "position() != last()" -n -b \
	${configxml_file} | /usr/local/bin/xml unesc | \
	while read _name _udma _harddiskstandby _apm _acoustic; do
		# Calculate the channel and device ids.
		_devnum=${_name#*ad}
		_channel=$(( ${_devnum} / 2 ))
		_device=$(( ${_devnum} % 2 ))

		# If UDMA mode is forced, launch atacontrol.
		if [ "auto" != "${_udma}" ]; then
			/sbin/atacontrol mode ${_name} ${_udma} > /dev/null 2>&1
		fi

		# Set command args.
		_cmdargs=""

		if [ ${_acoustic} != 0 ]; then
			_cmdargs="${_cmdargs} -A ${_acoustic}"
		fi

		if [ ${_apm} != 0 ]; then
			_cmdargs="${_cmdargs} -P ${_apm}"
		fi

		if [ ${_harddiskstandby} != 0 ]; then
			_cmdargs="${_cmdargs} -S ${_harddiskstandby}"
		fi

		/usr/local/sbin/ataidle ${_cmdargs} ${_channel} ${_device} > /dev/null 2>&1

		# Print out some disk informations.
		echo -n "${_name} "
	done

# Finally do a line break.
echo
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.