. /etc/sysconfig/rdate
fi
+# internal functions
+set_time ()
+{
+ if [ $? -eq 0 -a -x /sbin/hwclock ] && is_yes "${SYNC_HWCLOCK}"; then
+ # Set the system clock.
+ ARC=0
+ SRM=0
+ UTC=0
-# See how we were called.
-case "$1" in
- start|restart|reload|force-reload)
- # Check if we have to do anything:
- if is_yes "${SET_TIME}" && [ -n "${RDATE_SERVERS}" ]; then
- run_cmd "$(nls "Setting time from remote server: %s" "${RDATE_SERVERS}")" rdate -s -l "${RDATE_SERVERS}"
- if [ $? -eq 0 -a -x /sbin/hwclock ] && is_yes "${SYNC_HWCLOCK}"; then
- # Set the system clock.
- ARC=0
- SRM=0
- UTC=0
-
- if [ -f /etc/sysconfig/clock ]; then
- . /etc/sysconfig/clock
+ if [ -f /etc/sysconfig/clock ]; then
+ . /etc/sysconfig/clock
- # convert old style clock config to new values
- if [ "${CLOCKMODE}" = "GMT" ]; then
- UTC=true
- elif [ "${CLOCKMODE}" = "ARC" ]; then
- ARC=true
- fi
- fi
-
- if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
+ # convert old style clock config to new values
+ if [ "${CLOCKMODE}" = "GMT" ]; then
+ UTC=true
+ elif [ "${CLOCKMODE}" = "ARC" ]; then
ARC=true
fi
+ fi
- CLOCKFLAGS="--systohc"
-
- if is_yes "$UTC" ; then
- CLOCKFLAGS="$CLOCKFLAGS --utc"
- else
- CLOCKFLAGS="$CLOCKFLAGS --localtime"
- fi
+ if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
+ ARC=true
+ fi
- if is_yes "$ARC" ; then
- CLOCKFLAGS="$CLOCKFLAGS -A"
- fi
+ CLOCKFLAGS="--systohc"
+
+ if is_yes "$UTC" ; then
+ CLOCKFLAGS="$CLOCKFLAGS --utc"
+ else
+ CLOCKFLAGS="$CLOCKFLAGS --localtime"
+ fi
- if is_yes "$SRM" ; then
- CLOCKFLAGS="$CLOCKFLAGS -S"
- fi
+ if is_yes "$ARC" ; then
+ CLOCKFLAGS="$CLOCKFLAGS -A"
+ fi
+
+ if is_yes "$SRM" ; then
+ CLOCKFLAGS="$CLOCKFLAGS -S"
+ fi
+ if is_yes "${BACKGROUND}"; then
+ # be quiet when in background
+ /sbin/hwclock $CLOCKFLAGS
+ else
run_cmd "Syncing hardware clock" /sbin/hwclock $CLOCKFLAGS
fi
fi
+}
+
+
+# See how we were called.
+case "$1" in
+ start|restart|reload|force-reload)
+ # Check if we have to do anything:
+ if is_yes "${SET_TIME}" && [ -n "${RDATE_SERVERS}" ]; then
+ if is_yes "${BACKGROUND}"; then
+ # synchronize in background for faster startups
+ run_cmd "$(nls "Setting time from remote server (bg): %s" "${RDATE_SERVERS}")" /bin/true
+ run_cmd "Syncing hardware clock (bg)" /bin/true
+ {
+ rdate -s -l "${RDATE_SERVERS}"
+ set_time
+ }&
+ else
+ # or else synchronize in foreground for precise timestamps
+ run_cmd "$(nls "Setting time from remote server: %s" "${RDATE_SERVERS}")" rdate -s -l "${RDATE_SERVERS}"
+ set_time
+ fi
+
+ fi
;;
stop)
# nothing to do