diff options
author | freaj <freaj@riseup.net> | 2015-03-30 11:08:25 +0200 |
---|---|---|
committer | freaj <freaj@riseup.net> | 2015-03-30 11:08:25 +0200 |
commit | cec37e643f4889b4b8652bdfce886b1e5e81f2bd (patch) | |
tree | c992d8325923324f5d318f57b4c05dd5fe494988 /pcr/openrc-misc/hdparm-init-8 | |
parent | 7385c6143c1b587bca68deade6e5989d11879767 (diff) | |
download | abslibre-cec37e643f4889b4b8652bdfce886b1e5e81f2bd.tar.gz abslibre-cec37e643f4889b4b8652bdfce886b1e5e81f2bd.tar.bz2 abslibre-cec37e643f4889b4b8652bdfce886b1e5e81f2bd.zip |
openrc-misc: add new package to [pcr]
Diffstat (limited to 'pcr/openrc-misc/hdparm-init-8')
-rw-r--r-- | pcr/openrc-misc/hdparm-init-8 | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/pcr/openrc-misc/hdparm-init-8 b/pcr/openrc-misc/hdparm-init-8 new file mode 100644 index 000000000..9a4200c82 --- /dev/null +++ b/pcr/openrc-misc/hdparm-init-8 @@ -0,0 +1,61 @@ +#!/sbin/runscript +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/hdparm/files/hdparm-init-8,v 1.3 2012/04/29 00:30:18 vapier Exp $ + +depend() { + before bootmisc +} + +do_hdparm() { + local e= + eval e=\$${extra_args} + [ -z "${args}${all_args}${e}" ] && return 0 + + if [ -n "${args:=${all_args} ${e}}" ] ; then + local orgdevice=$(readlink -f "${device}") + if [ -b "${orgdevice}" ] ; then + ebegin "Running hdparm on ${device}" + hdparm ${args} "${device}" > /dev/null + eend $? + fi + fi +} + +scan_nondevfs() { + # non-devfs compatible system + local device + + for device in /dev/hd* /dev/sd* /dev/cdrom* ; do + [ -e "${device}" ] || continue + case "${device}" in + *[0-9]) continue ;; + /dev/hd*) extra_args="pata_all_args" ;; + /dev/sd*) extra_args="sata_all_args" ;; + *) extra_args="_no_xtra_args" ;; + esac + + # check that the block device really exists by + # opening it for reading + local errmsg= status= nomed=1 + errmsg=$(export LC_ALL=C ; : 2>&1 <"${device}") + status=$? + case ${errmsg} in + *": No medium found") nomed=0;; + esac + if [ -b "${device}" ] && [ "${status}" = "0" -o "${nomed}" = "0" ] ; then + local conf_var="${device##*/}_args" + eval args=\$${conf_var} + do_hdparm + fi + done +} + +start() { + if get_bootparam "nohdparm" ; then + ewarn "Skipping hdparm init as requested in kernel cmdline" + return 0 + fi + + scan_nondevfs +} |