aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--conf.d.Linux/clock17
-rwxr-xr-xinit.d.Linux/clock44
3 files changed, 34 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index b8369e6c..6015183b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
+ 23 Oct 2007; Roy Marples <uberlord@gentoo.org>:
+
+ clock init script now handles /etc/adjtime correctly.
+ CLOCK_ADJTIME hinted that it could change the location of /etc/adjtime.
+ This is not the case.
+
19 Oct 2007; Roy Marples <uberlord@gentoo.org>:
Mount /dev/shm for Linux systems, even not when in /etc/fstab, #196345.
diff --git a/conf.d.Linux/clock b/conf.d.Linux/clock
index a7f4f47d..9fa4547b 100644
--- a/conf.d.Linux/clock
+++ b/conf.d.Linux/clock
@@ -1,19 +1,12 @@
-# If you wish to pass any other arguments to hwclock during bootup,
+# If you wish to pass any other arguments to hwclock during bootup,
# you may do so here.
CLOCK_OPTS=""
-# Newer FHS specs say this file should live in /var/lib rather than
-# /etc. If you care about such things, feel free to change this value.
-# Note that a blank value means that you do not wish to even use the
-# adjtime facility. This is the default behavior as adjtime can be
-# very fragile. If the clock is updated without updating the adjtime
-# file (which is common when using services such as ntp), then the
-# clock can be screwed up when it gets updated at next boot.
-
-#CLOCK_ADJTIME="/var/lib/adjtime"
-#CLOCK_ADJTIME="/etc/adjtime"
-CLOCK_ADJTIME=""
+# Set CLOCK_ADJTIME if you wish hwclock to try and handle clock drift.
+# Don't set this if you run a ntp service or anything else that handles
+# clock drift.
+CLOCK_ADJTIME="no"
### ALPHA SPECIFIC OPTIONS ###
diff --git a/init.d.Linux/clock b/init.d.Linux/clock
index 144ecbcb..75910808 100755
--- a/init.d.Linux/clock
+++ b/init.d.Linux/clock
@@ -9,13 +9,20 @@ description_save="Saves the current time in the BIOS."
depend() {
case "${CLOCK_ADJTIME}" in
- "") before *;;
- /etc/*) need checkroot;;
- *) need localmount;;
+ ""|no) before *;;
+ /etc/*|yes) need checkroot;;
+ *) need localmount;;
esac
}
setupopts() {
+ myopts=
+
+ case "${CLOCK_ADJTIME}" in
+ no) CLOCK_ADJTIME=;;
+ yes) CLOCK_ADJTIME="/etc/adjtime";;
+ esac
+
case "${RC_SYS}" in
UML|VPS|XEN)
TBLURB="${RC_SYS}"
@@ -44,19 +51,16 @@ setupopts() {
esac
[ ${fakeit} -eq 1 ] && return 0
- if [ -z "${CLOCK_ADJTIME}" -o ! -w /etc ] ; then
- myadj="--noadjfile"
- else
- myadj="--adjust"
- fi
+ [ -w /etc -a -n "${CLOCK_ADJTIME}" ] || myopts="${myopts} --noadjfile"
[ "${SRM}" = "yes" ] && myopts="${myopts} --srm"
[ "${ARC}" = "arc" ] && myopts="${myopts} --arc"
myopts="${myopts} ${CLOCK_OPTS}"
# Make sure user isn't using rc.conf anymore.
- if grep -q "^CLOCK=" /etc/rc.conf ; then
- ewarn $"CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"
+ if [ -e /etc/rc.conf ] && \
+ [ -n "$(unset CLOCK; . /etc/rc.conf; echo "${CLOCK}")" ] ; then
+ ewarn "CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"
fi
# Make sure people set their timezone ... we do it here
@@ -70,26 +74,21 @@ setupopts() {
start() {
local myopts= myadj= TBLURB= fakeit=0 errstr="" retval=0
- if [ -x /sbin/hwclock ] ; then
- [ -w "${CLOCK_ADJTIME}" ] && echo "0.0 0 0.0" > "${CLOCK_ADJTIME}"
- fi
-
setupopts
if [ ${fakeit} -ne 1 -a -e /proc/modules -a ! -e /dev/rtc ] ; then
modprobe -q rtc || modprobe -q genrtc
fi
- ebegin "Setting system clock using the hardware clock" "[${TBLURB}]"
+ ebegin "Setting system clock using the hardware clock [${TBLURB}]"
if [ ${fakeit} -eq 1 ] ; then
retval=0
elif [ -x /sbin/hwclock ] ; then
# Don't call hwclock unless we need to
- if [ "${TBLURB}" != "UTC" -o "${myadj}" != "--noadjfile" ] ; then
+ if [ "${TBLURB}" != "UTC" -o "${myopts#*--noadjfile}" = "${myopts}" ] ; then
# Since hwclock always exit's with a 0, need to check its output.
- errstr="$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null)"
+ [ -n "${CLOCK_ADJTIME}" ] && errstr="$(/sbin/hwclock --adjust 2>&1 >/dev/null)"
errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"
-
if [ -n "${errstr}" ] ; then
ewarn "${errstr}"
retval=1
@@ -117,12 +116,15 @@ stop() {
if [ ${fakeit} -eq 1 ] ; then
retval=0
elif [ -x /sbin/hwclock ] ; then
- [ -z "$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)" ]
- retval=$?
+ errstr="$(LC_ALL=C /sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)"
+ if [ -n "${errstr}" ] ; then
+ ewarn "${errstr}"
+ retval=1
+ fi
errstr="Failed to sync clocks"
else
retval=1
- errstr="/sbin/hwclock not found"
+ errstr="hwclock not found"
fi
eend ${retval} "${errstr}"
}