]> git.pld-linux.org Git - packages/hdparm.git/commitdiff
- optimize for empty config doing nothing
authorElan Ruusamäe <glen@pld-linux.org>
Sun, 28 Jan 2007 11:59:16 +0000 (11:59 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    hdparm.init -> 1.17

hdparm.init

index eef76bcf929c3cfb715bd15e90d51a5393aa0db3..1ceb4b66d8368678a681e3fabc084d81a58cb30a 100644 (file)
@@ -1,14 +1,22 @@
 #!/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
 
-for drive in $(ls /proc/ide 2> /dev/null); do
+for var in $blockdevs; do
+       drive=${var#HDPARM_}
        if [ -L "/proc/ide/${drive}" ]; then
-               eval PARAMS=\$HDPARM_${drive}
+               eval PARAMS=\$$var
                if [ -n "${PARAMS}" ]; then
                        show "Setting parameters for drive %s (%s)" "$drive" "$PARAMS"
                        busy
This page took 0.042877 seconds and 4 git commands to generate.