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.

This commit is contained in:
Roy Marples 2007-10-23 20:00:08 +00:00
parent dc3bce5dae
commit bf0cc2dac4
3 changed files with 34 additions and 33 deletions

View File

@ -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.

View File

@ -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 ###

View File

@ -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}"
}