]> git.pld-linux.org Git - packages/hdparm.git/blobdiff - hdparm.init
- optimize for empty config doing nothing
[packages/hdparm.git] / hdparm.init
index 3a8603d79a49793531555c1abebd14a72b087933..1ceb4b66d8368678a681e3fabc084d81a58cb30a 100644 (file)
@@ -1,27 +1,29 @@
 #!/bin/sh
 
+[ -f /etc/sysconfig/hdparm ] || exit 0
+
+blockdevs=$(awk -F= '!/^#/ && !/^$/ {if ($2) print $1}' /etc/sysconfig/hdparm)
+if [ -z "$blockdevs" ]; then
+       exit 0
+fi
+
 # Source function library
 . /etc/rc.d/init.d/functions
 
-# Get service config
-[ -f /etc/sysconfig/hdparm ] && . /etc/sysconfig/hdparm
+# Source hdparm configureation.
+. /etc/sysconfig/hdparm
 
-if [ -c /dev/.devfsd ]; then
-        # we have devfs enabled kernel
-        DRIVES=$(ls -1 /dev/hd* /dev/sd* 2> /dev/null | \
-               awk -F'/' ' ! /[0-9]$/ { print $3; }')
-else
-       DRIVES="`awk '!($NF ~ /md|name/) { print $NF }' /proc/partitions`"
-fi
-
-for drive in $DRIVES; do
-       eval PARAMS=\$HDPARM_${drive}
-       if [ -n "${PARAMS}" ] ; then
-               show "Setting parameters for drive %s" "$drive"
-               busy
-               /sbin/hdparm ${PARAMS} /dev/$drive
-               deltext
-               ok
+for var in $blockdevs; do
+       drive=${var#HDPARM_}
+       if [ -L "/proc/ide/${drive}" ]; then
+               eval PARAMS=\$$var
+               if [ -n "${PARAMS}" ]; then
+                       show "Setting parameters for drive %s (%s)" "$drive" "$PARAMS"
+                       busy
+                       /sbin/hdparm ${PARAMS} /dev/${drive}
+                       ok
+               fi
        fi
-done  
+done
+
 exit 0
This page took 0.098347 seconds and 4 git commands to generate.