Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/etc/rc.d



On Tue, 15 Mar 2005, Luke Mewburn wrote:
>       src/etc/rc.d: ntpdate
> Explicitly REQUIRE mountcritremote, since this uses awk.

I prefer time synchronisation to happen as early as possible.
The appended patch removes the dependency on awk.

--apb (Alan Barrett)

Index: src/etc/rc.d/ntpdate
===================================================================
--- ntpdate     11 Oct 2004 15:00:51 -0000      1.17
+++ ntpdate     15 Mar 2005 14:34:38 -0000
@@ -17,14 +17,21 @@
 ntpdate_start()
 {
        if [ -z "$ntpdate_hosts" ]; then
-               ntpdate_hosts=$(awk '
-                       /^#/                            { next }
-                       /^(server|peer)[ \t]*127.127/   { next }
-                       /^(server|peer)/                { if ($2 ~ /^-[46]/)
-                                                           print $3
-                                                         else
-                                                           print $2 }
-               ' </etc/ntp.conf)
+               ntpdate_hosts="$(
+                   while read line ; do
+                       set -- $line
+                       case "$1" in
+                       ''|\#*) ;;
+                       server|peer)
+                           case "$2:$3" in
+                           127.127*|*:127.127*) ;;
+                           -[46]:*)    echo "$3" ;;
+                           *)          echo "$2" ;;
+                           esac
+                           ;;
+                       esac
+                   done </etc/ntp.conf
+                   )"
        fi
        if [ -n "$ntpdate_hosts"  ]; then
                echo "Setting date via ntp."



Home | Main Index | Thread Index | Old Index