summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/files/hwclock.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/busybox/files/hwclock.sh')
-rw-r--r--meta/recipes-core/busybox/files/hwclock.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/files/hwclock.sh b/meta/recipes-core/busybox/files/hwclock.sh
new file mode 100644
index 0000000000..2e50425ba8
--- /dev/null
+++ b/meta/recipes-core/busybox/files/hwclock.sh
@@ -0,0 +1,82 @@
1#!/bin/sh
2### BEGIN INIT INFO
3# Provides: hwclock
4# Required-Start:
5# Required-Stop: $local_fs
6# Default-Start: S
7# Default-Stop: 0 6
8# Short-Description: Set system clock
9# Description: Set system clock to hardware clock, according to the UTC
10# setting in /etc/default/rcS (see also rcS(5)).
11### END INIT INFO
12#
13# WARNING: If your hardware clock is not in UTC/GMT, this script
14# must know the local time zone. This information is
15# stored in /etc/localtime. This might be a problem if
16# your /etc/localtime is a symlink to something in
17# /usr/share/zoneinfo AND /usr isn't in the root
18# partition! The workaround is to define TZ either
19# in /etc/default/rcS, or in the proper place below.
20
21[ ! -x /sbin/hwclock ] && exit 0
22
23. /etc/default/rcS
24
25case "$1" in
26 start)
27 if [ "$VERBOSE" != no ]
28 then
29 echo "System time was `date`."
30 echo "Setting the System Clock using the Hardware Clock as reference..."
31 fi
32
33 if [ "$HWCLOCKACCESS" != no ]
34 then
35 if [ -z "$TZ" ]
36 then
37 hwclock --hctosys
38 else
39 TZ="$TZ" hwclock --hctosys
40 fi
41 fi
42
43 if [ "$VERBOSE" != no ]
44 then
45 echo "System Clock set. System local time is now `date`."
46 fi
47 ;;
48 stop|restart|reload|force-reload)
49 #
50 # Updates the Hardware Clock with the System Clock time.
51 # This will *override* any changes made to the Hardware Clock.
52 #
53 # WARNING: If you disable this, any changes to the system
54 # clock will not be carried across reboots.
55 #
56 if [ "$VERBOSE" != no ]
57 then
58 echo "Saving the System Clock time to the Hardware Clock..."
59 fi
60 if [ "$HWCLOCKACCESS" != no ]
61 then
62 hwclock --systohc
63 fi
64 if [ "$VERBOSE" != no ]
65 then
66 echo "Hardware Clock updated to `date`."
67 fi
68 exit 0
69 ;;
70 show)
71 if [ "$HWCLOCKACCESS" != no ]
72 then
73 hwclock --show
74 fi
75 ;;
76 *)
77 echo "Usage: hwclock.sh {start|stop|show|reload|restart}" >&2
78 echo " start sets kernel (system) clock from hardware (RTC) clock" >&2
79 echo " stop and reload set hardware (RTC) clock from kernel (system) clock" >&2
80 exit 1
81 ;;
82esac