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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2725 - (show annotations) (download)
Sat Jun 2 12:23:43 2007 UTC (7 years, 5 months ago) by vapier
File size: 3070 byte(s)
Use -q option with modprobe rather than sending to /dev/null.
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 depend() {
8 case "${CLOCK_ADJTIME}" in
9 "") before *;;
10 /etc/*) need checkroot;;
11 *) need localmount;;
12 esac
13 }
14
15 setupopts() {
16 case "${RC_SYS}" in
17 UML|VPS|XEN)
18 TBLURB="${RC_SYS}"
19 fakeit=1
20 ;;
21 *)
22 case "$(uname -m)" in
23 s390*)
24 TBLURB="s390"
25 fakeit=1
26 ;;
27 *)
28 if [ -e /proc/devices ] && grep -q " cobd$" /proc/devices ; then
29 TBLURB="coLinux"
30 fakeit=1
31 elif [ "${CLOCK}" = "UTC" ] ; then
32 myopts="--utc"
33 TBLURB="UTC"
34 else
35 myopts="--localtime"
36 TBLURB="Local Time"
37 fi
38 ;;
39 esac
40 ;;
41 esac
42 [ ${fakeit} -eq 1 ] && return 0
43
44 if [ -z "${CLOCK_ADJTIME}" -o ! -w /etc ] ; then
45 myadj="--noadjfile"
46 else
47 myadj="--adjust"
48 fi
49
50 [ "${SRM}" = "yes" ] && myopts="${myopts} --srm"
51 [ "${ARC}" = "arc" ] && myopts="${myopts} --arc"
52 myopts="${myopts} ${CLOCK_OPTS}"
53
54 # Make sure user isn't using rc.conf anymore.
55 if grep -q "^CLOCK=" /etc/rc.conf ; then
56 ewarn $"CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"
57 fi
58
59 # Make sure people set their timezone ... we do it here
60 # even though we don't actually use the variable so that
61 # people see the warning on boot.
62 if [ -z "${CDBOOT}" -a "${TIMEZONE-Factory}" = "Factory" ] ; then
63 ewarn "Your TIMEZONE in /etc/conf.d/clock is still set to Factory!"
64 fi
65 }
66
67 start() {
68 local myopts= myadj= TBLURB= fakeit=0 errstr="" retval=0
69
70 if [ -x /sbin/hwclock ] ; then
71 [ -w "${CLOCK_ADJTIME}" ] && echo "0.0 0 0.0" > "${CLOCK_ADJTIME}"
72 fi
73
74 setupopts
75
76 if [ ${fakeit} -ne 1 -a -e /proc/modules -a ! -e /dev/rtc ] ; then
77 modprobe -q rtc || modprobe -q genrtc
78 fi
79
80 ebegin "Setting system clock using the hardware clock" "[${TBLURB}]"
81 if [ ${fakeit} -eq 1 ] ; then
82 retval=0
83 elif [ -x /sbin/hwclock ] ; then
84 # Don't call hwclock unless we need to
85 if [ "${TBLURB}" != "UTC" -o "${myadj}" != "--noadjfile" ] ; then
86 # Since hwclock always exit's with a 0, need to check its output.
87 errstr="$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null)"
88 errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"
89
90 if [ -n "${errstr}" ] ; then
91 ewarn "${errstr}"
92 retval=1
93 fi
94 errstr="Failed to set clock"
95 fi
96 else
97 retval=1
98 errstr="/sbin/hwclock not found"
99 fi
100 eend ${retval} "${errstr}" "You will need to set the clock yourself"
101
102 return 0
103 }
104
105 stop() {
106 # Don't tweak the hardware clock on LiveCD halt.
107 [ -n "${CDBOOT}" -o "${CLOCK_SYSTOHC}" != "yes" ] && return 0
108
109 local myopts= myadj= TBLURB= fakeit=0 errstr="" retval=0
110
111 setupopts
112
113 ebegin "Setting hardware clock using the system clock" "[${TBLURB}]"
114 if [ ${fakeit} -eq 1 ] ; then
115 retval=0
116 elif [ -x /sbin/hwclock ] ; then
117 [ -z "$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)" ]
118 retval=$?
119 errstr="Failed to sync clocks"
120 else
121 retval=1
122 errstr="/sbin/hwclock not found"
123 fi
124 eend ${retval} "${errstr}"
125 }
126
127 save() {
128 CLOCK_SYSTOHC="yes"
129 stop
130 }
131
132 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20