/[baselayout]/branches/rc-scripts-1_6/init.d/clock
Gentoo

Contents of /branches/rc-scripts-1_6/init.d/clock

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1231 - (show annotations) (download)
Mon Jun 13 02:25:31 2005 UTC (9 years, 5 months ago) by vapier
File size: 2422 byte(s)
merge cvs Header removal from trunk
1 #!/sbin/runscript
2 # Copyright 1999-2005 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 return 0
16 elif is_vserver_sys ; then
17 TBLURB="VServer"
18 fakeit=1
19 return 0
20 elif grep -q ' cobd$' /proc/devices ; then
21 TBLURB="coLinux"
22 fakeit=1
23 return 0
24 elif [[ ${CLOCK} == "UTC" ]] ; then
25 myopts="--utc"
26 TBLURB="UTC"
27 else
28 myopts="--localtime"
29 TBLURB="Local Time"
30 fi
31
32 if [[ ${readonly} == "yes" ]] ; then
33 myadj="--noadjfile"
34 else
35 myadj="--adjust"
36 fi
37
38 if [[ ${SRM} == "yes" ]] ; then
39 myopts="${myopts} --srm"
40 fi
41 if [[ ${ARC} == "arc" ]] ; then
42 myopts="${myopts} --arc"
43 fi
44 myopts="${myopts} ${CLOCK_OPTS}"
45
46 # Make sure user isn't using rc.conf anymore.
47 if grep -qs ^CLOCK= /etc/rc.conf ; then
48 ewarn "CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"
49 fi
50 }
51
52 start() {
53 local myopts=""
54 local myadj=""
55 local TBLURB="" fakeit=0
56 local errstr=""
57 local readonly="no"
58 local ret=0
59
60 if ! touch /etc/adjtime 2>/dev/null ; then
61 readonly="yes"
62 elif [[ ! -s /etc/adjtime ]] ; then
63 echo "0.0 0 0.0" > /etc/adjtime
64 fi
65
66 setupopts
67
68 ebegin "Setting system clock to hardware clock [${TBLURB}]"
69 if [[ ${fakeit} -eq 1 ]] ; then
70 ret=0
71
72 elif [[ -x /sbin/hwclock ]] ; then
73 # Since hwclock always exit's with a 0, need to check its output.
74 errstr=$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null)
75 errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"
76
77 if [[ -n ${errstr} ]] ; then
78 ewarn "${errstr}"
79 ret=1
80 else
81 ret=0
82 fi
83 errstr="Failed to set system clock to hardware clock"
84 else
85 ret=1
86 errstr="/sbin/hwclock not found"
87 fi
88 eend ${ret} "${errstr}"
89 }
90
91 stop() {
92 # Don't tweak the hardware clock on LiveCD halt.
93 [[ -n ${CDBOOT} ]] && return 0
94
95 [[ ${CLOCK_SYSTOHC} != "yes" ]] && return 0
96
97 local myopts=""
98 local TBLURB=""
99 local errstr=""
100 local ret=0
101
102 setupopts
103
104 ebegin "Syncing system clock to hardware clock [${TBLURB}]"
105 if [[ ${CLOCK} == "UML" ]] ; then
106 ret=0
107
108 elif [[ -x /sbin/hwclock ]] ; then
109 errstr=$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)
110
111 if [[ -n ${errstr} ]] ; then
112 ret=1
113 else
114 ret=0
115 fi
116 errstr="Failed to sync clocks"
117 else
118 ret=1
119 errstr="/sbin/hwclock not found"
120 fi
121 eend ${ret} "${errstr}"
122 }
123
124 save() {
125 CLOCK_SYSTOHC="yes"
126 stop
127 }
128
129
130 # 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