3481
by Colin Watson
Reorganise clock handling. The system wall clock is now set as early as |
1 |
#! /bin/sh
|
2 |
set -e
|
|
3 |
||
4 |
# Much of this is cloned-and-hacked from
|
|
5 |
# clock-setup/finish-install.d/10clock-setup.
|
|
6 |
||
7 |
. /usr/share/debconf/confmodule |
|
8 |
||
9 |
if [ "$UBIQUITY_OEM_USER_CONFIG" ]; then |
|
10 |
roots=/ |
|
11 |
else
|
|
12 |
roots='/ /target' |
|
13 |
fi
|
|
14 |
||
5477
by Colin Watson
Sync up scripts/clock-setup-apply with changes in clock-setup 0.110. |
15 |
if [ -f /etc/default/hwclock ]; then |
16 |
utcfile=/etc/default/hwclock |
|
17 |
else
|
|
18 |
utcfile=/etc/default/rcS |
|
19 |
fi
|
|
3481
by Colin Watson
Reorganise clock handling. The system wall clock is now set as early as |
20 |
adjtimefile=/etc/adjtime |
21 |
||
22 |
db_get clock-setup/utc |
|
23 |
for root in $roots; do |
|
24 |
if [ "$RET" = true ]; then |
|
5477
by Colin Watson
Sync up scripts/clock-setup-apply with changes in clock-setup 0.110. |
25 |
sed -i -e 's:^UTC="no":UTC="yes":' -e 's:^UTC=no:UTC=yes:' $root$utcfile |
3481
by Colin Watson
Reorganise clock handling. The system wall clock is now set as early as |
26 |
if [ -e "$root$adjtimefile" ]; then |
27 |
sed -i -e 's:^LOCAL:UTC:' $root$adjtimefile |
|
28 |
fi
|
|
29 |
UTC='--utc' |
|
30 |
else
|
|
5477
by Colin Watson
Sync up scripts/clock-setup-apply with changes in clock-setup 0.110. |
31 |
sed -i -e 's:^UTC="yes":UTC="no":' -e 's:^UTC=yes:UTC=no:' $root$utcfile |
3481
by Colin Watson
Reorganise clock handling. The system wall clock is now set as early as |
32 |
if [ -e "$root$adjtimefile" ]; then |
33 |
sed -i -e 's:^UTC:LOCAL:' $root$adjtimefile |
|
34 |
fi
|
|
35 |
UTC='--localtime' |
|
36 |
fi
|
|
37 |
done
|
|
38 |
||
39 |
# It isn't strictly necessary to set the hardware clock here, but we do it
|
|
40 |
# anyway in case the system crashes before being shut down.
|
|
41 |
# TODO: progress information?
|
|
42 |
||
43 |
log-output -t clock-setup hwclock --systohc --debug --noadjfile $UTC & |
|
44 |
pid="$!" |
|
45 |
count=0 |
|
46 |
||
47 |
stop_hwclock () { |
|
48 |
kill $pid || return |
|
49 |
sleep 1
|
|
50 |
if [ -e /proc/$pid ]; then |
|
51 |
kill -9 $pid || return |
|
52 |
fi
|
|
53 |
}
|
|
54 |
||
55 |
while sleep 1; do |
|
56 |
if [ ! -e /proc/$pid ]; then |
|
57 |
break
|
|
58 |
fi
|
|
59 |
count=$(expr $count + 1) |
|
60 |
if [ "$count" = 30 ]; then |
|
61 |
stop_hwclock |
|
62 |
break
|
|
63 |
fi
|
|
64 |
done
|
|
65 |
||
66 |
exit 0 |