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

Contents of /trunk/init.d/clock

Parent Directory Parent Directory | Revision Log Revision Log


Revision 484 - (show annotations) (download)
Wed Apr 21 17:09:18 2004 UTC (15 years, 1 month ago) by vapier
File size: 1873 byte(s)
update copyright years

1 #!/sbin/runscript
2 # Copyright 1999-2004 Gentoo Technologies, Inc.
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header$
5
6 opts="${opts} save"
7
8 depend() {
9 need localmount
10 }
11
12 start() {
13 local myopts=""
14 local TBLURB=""
15 local errstr=""
16 if [ ! -f /etc/adjtime ]
17 then
18 echo "0.0 0 0.0" > /etc/adjtime
19 fi
20 if [ "${CLOCK}" = "UTC" ]
21 then
22 myopts="--utc"
23 TBLURB="[UTC]"
24 else
25 myopts="--localtime"
26 TBLURB="[Local Time]"
27 fi
28
29 if [ -n "$(grep 'UML' /proc/cpuinfo)" ]
30 then
31 ebegin "Setting system clock to hardware clock ${TBLURB}"
32 eend 0 "Detected UML Environment; ignoring"
33 return 0
34
35 elif [ -x /sbin/hwclock ]
36 then
37 ebegin "Setting system clock to hardware clock ${TBLURB}"
38 errstr="$(/sbin/hwclock --adjust ${myopts} 2>&1 >/dev/null)"
39 errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)"
40 #hwclock do not return a fail status
41 if [ -n "${errstr}" ]
42 then
43 eend 1 "Failed to set system clock to hardware clock"
44 return 1
45 else
46 eend 0
47 return 0
48 fi
49 else
50 eend 1 "hwclock executable not found"
51 fi
52 }
53
54 stop() {
55 local myopts=""
56 local TBLURB=""
57 local errstr=""
58
59 # Don't tweak hw clock on LiveCD halt
60 [ -n "${CDBOOT}" ] && return 0
61
62 if [ "${CLOCK}" = "UTC" ]
63 then
64 myopts="--utc"
65 TBLURB="[UTC]"
66 else
67 myopts="--localtime"
68 TBLURB="[Local Time]"
69 fi
70
71 if [ -n "$(grep 'UML' /proc/cpuinfo)" ]
72 then
73 ebegin "Syncing hardware clock to system clock ${TBLURB}"
74 eend 0 "Detected UML Environment; ignoring"
75 return 0
76
77 elif [ -x /sbin/hwclock ]
78 then
79 ebegin "Syncing hardware clock to system clock ${TBLURB}"
80 errstr="$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null)"
81 if [ -n "${errstr}" ]
82 then
83 eend 1 "Failed to set hardware clock to system clock"
84 return 1
85 else
86 eend 0
87 return 0
88 fi
89 else
90 eend 1 "hwclock executable not found"
91 fi
92 }
93
94 save() {
95 stop
96 }
97
98
99 # 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