/[baselayout]/trunk/init.d.Linux/clock
Gentoo

Contents of /trunk/init.d.Linux/clock

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3061 - (show annotations) (download)
Wed Oct 24 08:50:14 2007 UTC (6 years, 10 months ago) by uberlord
File size: 3085 byte(s)
Advise not syncing time when running ntp daemons
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 show"
6
7 description="Sets the local clock to UTC or Local Time."
8 description_save="Saves the current time in the BIOS."
9 description_show="Displays the current time in the BIOS."
10
11 depend() {
12 if [ "${CLOCK_ADJFILE}" = "yes" ]; then
13 use checkroot
14 else
15 before *
16 fi
17 }
18
19 setupopts() {
20 utc=
21 case "${RC_SYS}" in
22 UML|VPS|XEN)
23 TBLURB="${RC_SYS}"
24 ;;
25 *)
26 case "$(uname -m)" in
27 s390*)
28 TBLURB="s390"
29 ;;
30 *)
31 if [ -e /proc/devices ] && grep -q " cobd$" /proc/devices ; then
32 TBLURB="coLinux"
33 elif [ "${CLOCK}" = "UTC" ] ; then
34 utc="--utc"
35 TBLURB="UTC"
36 else
37 utc="--localtime"
38 TBLURB="Local Time"
39 fi
40 ;;
41 esac
42 ;;
43 esac
44 [ -n "${utc}" ] || return 0
45
46 # Make sure user isn't using rc.conf anymore.
47 if [ -e /etc/rc.conf ] && \
48 [ -n "$(unset CLOCK; . /etc/rc.conf; echo "${CLOCK}")" ] ; then
49 ewarn "CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"
50 fi
51
52 # Make sure people set their timezone ... we do it here
53 # even though we don't actually use the variable so that
54 # people see the warning on boot.
55 if [ -z "${CDBOOT}" -a "${TIMEZONE-Factory}" = "Factory" ] ; then
56 ewarn "Your TIMEZONE in /etc/conf.d/clock is still set to Factory!"
57 fi
58 }
59
60 start() {
61 local utc= TBLURB= errstr="" retval=0
62
63 setupopts
64
65 ebegin "Setting system clock using the hardware clock [${TBLURB}]"
66 if [ -n "${utc}" ]; then
67 if [ -e /proc/modules -a ! -e /dev/rtc ] ; then
68 modprobe -q rtc || modprobe -q genrtc
69 fi
70
71 # Since hwclock always exit's with a 0, need to check its output.
72 if [ -e /etc/adjtime -a "${CLOCK_ADJFILE}" = "yes" ]; then
73 errstr="$(hwclock --adjust ${utc} 2>&1 >/dev/null)"
74 fi
75 # If setting UTC, don't bother to run hwclock when first booting
76 # as that's the default
77 if [ "${PREVLEVEL}" != "N" -o "${utc}" != "--utc" -o -n "${CLOCK_OPTS}" ]; then
78 errstr="${errstr}$(hwclock --hctosys ${utc} ${CLOCK_OPTS} 2>&1 >/dev/null)"
79 fi
80 fi
81 if [ -n "${errstr}" ]; then
82 ewarn "${errstr}"
83 retval=1
84 fi
85 errstr="Failed to set clock"
86 eend ${retval} "${errstr}" "You will need to set the clock yourself"
87
88 return 0
89 }
90
91 stop() {
92 # Don't tweak the hardware clock on LiveCD halt.
93 [ -n "${CDBOOT}" -o "${CLOCK_SYSTOHC}" != "yes" ] && return 0
94
95 local utc= TBLURB= errstr="" retval=0
96
97 setupopts
98
99 ebegin "Setting hardware clock using the system clock" "[${TBLURB}]"
100 if [ -n "${utc}" ]; then
101 if [ "${CLOCK_ADJFILE}" != "yes" ]; then
102 # Some implementations don't handle adjustments
103 if LC_ALL=C hwclock --help | grep -q "\-\-noadjfile"; then
104 utc="${utc} --noadjfile"
105 fi
106 fi
107 errstr="$(LC_ALL=C hwclock --systohc ${utc} ${CLOCK_OPTS} 2>&1 >/dev/null)"
108 fi
109 if [ -n "${errstr}" ] ; then
110 ewarn "${errstr}"
111 retval=1
112 fi
113 errstr="Failed to sync clocks"
114 eend ${retval} "${errstr}"
115 }
116
117 save() {
118 CLOCK_SYSTOHC="yes"
119 stop
120 }
121
122 show() {
123 local utc= TBLURB=
124 setupopts
125 /sbin/hwclock --show "${utc}" ${CLOCK_OPTS}
126 }
127
128 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20