/[vps]/baselayout-vserver/trunk/init.d/clock
Gentoo

Contents of /baselayout-vserver/trunk/init.d/clock

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Sat Sep 3 16:10:27 2005 UTC (9 years, 3 months ago) by hollow
File size: 2698 byte(s)
import initial baselayout sources (1.12.0_pre8)
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 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 grep -q ' cobd$' /proc/devices ; then
22 TBLURB="coLinux"
23 fakeit=1
24 elif [[ ${CLOCK} == "UTC" ]] ; then
25 myopts="--utc"
26 TBLURB="UTC"
27 else
28 myopts="--localtime"
29 TBLURB="Local Time"
30 fi
31 [[ ${fakeit} -eq 1 ]] && return 0
32
33 if [[ ${readonly} == "yes" ]] ; then
34 myadj="--noadjfile"
35 else
36 myadj="--adjust"
37 fi
38
39 if [[ ${SRM} == "yes" ]] ; then
40 myopts="${myopts} --srm"
41 fi
42 if [[ ${ARC} == "arc" ]] ; then
43 myopts="${myopts} --arc"
44 fi
45 myopts="${myopts} ${CLOCK_OPTS}"
46
47 # Make sure user isn't using rc.conf anymore.
48 if grep -qs ^CLOCK= /etc/rc.conf ; then
49 ewarn "CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"
50 fi
51 }
52
53 start() {
54 local myopts=""
55 local myadj=""
56 local TBLURB="" fakeit=0
57 local errstr=""
58 local readonly="no"
59 local ret=0
60
61 if ! touch /etc/adjtime 2>/dev/null ; then
62 readonly="yes"
63 elif [[ ! -s /etc/adjtime ]] ; then
64 echo "0.0 0 0.0" > /etc/adjtime
65 fi
66
67 setupopts
68
69 if [[ ${fakeit} -ne 1 && ! -e /dev/rtc ]] ; then
70 local x
71 einfon "Waiting for /dev/rtc to appear"
72 for x in $(seq 10) ; do
73 if [[ ! -e /dev/rtc ]] ; then
74 echo -n "."
75 sleep 1
76 else
77 echo
78 fi
79 done
80 fi
81
82 ebegin "Setting system clock to hardware clock [${TBLURB}]"
83 if [[ ${fakeit} -eq 1 ]] ; then
84 ret=0
85
86 elif [[ -x /sbin/hwclock ]] ; then
87 # Since hwclock always exit's with a 0, need to check its output.
88 errstr=$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null)
89 errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"
90
91 if [[ -n ${errstr} ]] ; then
92 ewarn "${errstr}"
93 ret=1
94 else
95 ret=0
96 fi
97 errstr="Failed to set system clock to hardware clock"
98 else
99 ret=1
100 errstr="/sbin/hwclock not found"
101 fi
102 eend ${ret} "${errstr}"
103 }
104
105 stop() {
106 # Don't tweak the hardware clock on LiveCD halt.
107 [[ -n ${CDBOOT} ]] && return 0
108
109 [[ ${CLOCK_SYSTOHC} != "yes" ]] && return 0
110
111 local myopts=""
112 local TBLURB=""
113 local errstr=""
114 local ret=0
115
116 setupopts
117
118 ebegin "Syncing system clock to hardware clock [${TBLURB}]"
119 if [[ ${fakeit} -eq 1 ]] ; then
120 ret=0
121
122 elif [[ -x /sbin/hwclock ]] ; then
123 errstr=$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)
124
125 if [[ -n ${errstr} ]] ; then
126 ret=1
127 else
128 ret=0
129 fi
130 errstr="Failed to sync clocks"
131 else
132 ret=1
133 errstr="/sbin/hwclock not found"
134 fi
135 eend ${ret} "${errstr}"
136 }
137
138 save() {
139 CLOCK_SYSTOHC="yes"
140 stop
141 }
142
143
144 # vim:ts=4

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20