/[baselayout]/branches/baselayout-1_12/init.d/clock
Gentoo

Contents of /branches/baselayout-1_12/init.d/clock

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20