summaryrefslogtreecommitdiff
path: root/init.d.Linux
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-23 20:00:08 +0000
committerRoy Marples <roy@marples.name>2007-10-23 20:00:08 +0000
commitbf0cc2dac43bde5249ad2a918006e560382f86d0 (patch)
tree478e3740ef81e906853fa8af89bcf260af9f1d9b /init.d.Linux
parentdc3bce5dae6daf7a9d3c2996fdc581241549d165 (diff)
downloadopenrc-bf0cc2dac43bde5249ad2a918006e560382f86d0.tar.gz
openrc-bf0cc2dac43bde5249ad2a918006e560382f86d0.tar.bz2
openrc-bf0cc2dac43bde5249ad2a918006e560382f86d0.tar.xz
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.
Diffstat (limited to 'init.d.Linux')
-rwxr-xr-xinit.d.Linux/clock44
1 files changed, 23 insertions, 21 deletions
diff --git a/init.d.Linux/clock b/init.d.Linux/clock
index 144ecbc..7591080 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}"
}