| 1 |
#!/sbin/runscript |
| 2 |
# Copyright 1999-2007 Gentoo Foundation |
| 3 |
# Distributed under the terms of the GNU General Public License v2 |
| 4 |
|
| 5 |
opts="save" |
| 6 |
|
| 7 |
description="Sets the local clock to UTC or Local Time." |
| 8 |
description_save="Saves the current time in the BIOS." |
| 9 |
|
| 10 |
depend() { |
| 11 |
# BSD adjkerntz needs to be able to write to /etc |
| 12 |
if [ "${CLOCK}" = "UTC" -a -e /etc/wall_cmos_clock ] || |
| 13 |
[ "${CLOCK}" != "UTC" -a ! -e /etc/wall_cmos_clock ] ; then |
| 14 |
need checkroot |
| 15 |
fi |
| 16 |
} |
| 17 |
|
| 18 |
start() { |
| 19 |
if [ "${TIMEZONE-Factory}" = "Factory" ] ; then |
| 20 |
ewarn "Your TIMEZONE in /etc/conf.d/clock is still set to Factory!" |
| 21 |
fi |
| 22 |
|
| 23 |
local TBLURB="Local Time" |
| 24 |
[ "${CLOCK}" = "UTC" ] && TBLURB="UTC" |
| 25 |
ebegin "Starting the System Clock Adjuster [${TBLURB}]" |
| 26 |
if [ "${CLOCK}" != "UTC" ] ; then |
| 27 |
echo >/etc/wall_cmos_clock |
| 28 |
start-stop-daemon --start --exec /sbin/adjkerntz -- -i |
| 29 |
else |
| 30 |
rm -f /etc/wall_cmos_clock |
| 31 |
/sbin/adjkerntz -i |
| 32 |
fi |
| 33 |
eend $? |
| 34 |
} |
| 35 |
|
| 36 |
save() { |
| 37 |
local TBLURB="Local Time" |
| 38 |
[ "${CLOCK}" = "UTC" ] && TBLURB="UTC" |
| 39 |
ebegin "Setting hardware clock using the system clock" "[${TBLURB}]" |
| 40 |
adjkerntz -a |
| 41 |
eend $? |
| 42 |
} |
| 43 |
|
| 44 |
stop() { |
| 45 |
# Don't tweak the hardware clock on LiveCD halt. |
| 46 |
[ -z "${CDBOOT}" -a "${CLOCK_SYSTOHC}" = "yes" ] && save |
| 47 |
|
| 48 |
ebegin "Stopping the System Clock Adjuster" |
| 49 |
if start-stop-daemon --test --quiet --stop --exec /sbin/adjkerntz ; then |
| 50 |
start-stop-daemon --stop --exec /sbin/adjkerntz |
| 51 |
eend $? |
| 52 |
else |
| 53 |
eend 0 |
| 54 |
fi |
| 55 |
} |
| 56 |
|
| 57 |
# vim: set ts=4 : |