Trying to stick with POSIX syntax only just slows things down.
---
 rc.sysinit |   27 +++++++++++----------------
 1 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/rc.sysinit b/rc.sysinit
index 29adeca..f3e60b7 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -44,27 +44,22 @@ fi
 
 HWCLOCK_PARAMS="--hctosys"
 case $HARDWARECLOCK in
-    UTC) "$HWCLOCK_PARAMS --utc";;
-    localtime) HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime";;
+    UTC) HWCLOCK_PARAMS+=" --utc";;
+    localtime) HWCLOCK_PARAMS+=" --localtime";;
     *) HWCLOCK_PARAMS="";;
 esac
 
-if [ -n "$HWCLOCK_PARAMS" ]; then
+if [[ $HWCLOCK_PARAMS ]]; then
        # enable rtc access
-       /sbin/modprobe -q rtc-cmos
-       # some custom kernels use rtc/genrtc, try to load those too
-       /sbin/modprobe -q rtc
-       /sbin/modprobe -q genrtc
+       /sbin/modprobe -q -a rtc-cmos rtc genrtc
        # If devtmpfs is used, the required RTC device already exists now
        # Otherwise, create whatever device is available
-       if [ ! -c /dev/rtc -a ! -c /dev/rtc0 ]; then
-               if [ -f /sys/class/rtc/rtc0/dev ]; then
-                       IFS=: read -r major minor < /sys/class/rtc/rtc0/dev
-                       /bin/mknod /dev/rtc0 c $major $minor
-               elif [ -f /sys/class/misc/rtc/dev ]; then
-                       IFS=: read -r major minor < /sys/class/misc/rtc/dev
-                       /bin/mknod /dev/rtc c $major $minor
-               fi
+       if ! [[ -c /dev/rtc || -c /dev/rtc0 ]]; then
+            for dev in /sys/class/rtc/rtc0/dev /sys/class/misc/rtc/dev; do
+                [[ -e $dev ]] || continue
+               IFS=: read -r major minor < "$dev"
+               /bin/mknod /dev/rtc c $major $minor
+           done
        fi
 
        # Do a clock set here for a few reasons:
@@ -75,7 +70,7 @@ if [ -n "$HWCLOCK_PARAMS" ]; then
        #    a later time.
        # This does *NOT* take into account a time adjustment file as /var may 
not be
        # mounted yet. A second set occurs later to match rc.conf.
-       if [ -f /etc/localtime ]; then
+       if [[ -f /etc/localtime ]]; then
                /sbin/hwclock $HWCLOCK_PARAMS --noadjfile
        fi
 fi
-- 
1.7.1

Reply via email to