aboutsummaryrefslogtreecommitdiffstats
path: root/bootscripts/contrib/lsb-v3/init.d/setclock
blob: f9cf7a64edaffc36d3655f3ea5e3051861fdd1be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
# Begin /etc/init.d/setclock

### BEGIN INIT INFO
# Provides:            $time
# Required-Start:      modules
# Should-Start:
# Required-Stop:       $syslog
# Should-Stop:
# Default-Start:       S
# Default-Stop: 
# Short-Description:   Stores and restores time from the hardware clock
# Description:         On boot, system time is obtained from hwclock.  The
#                      hardware clock can also be set on shutdown.
# X-LFS-Default-Start: S25
# X-LFS-Default-Stop:  K46
# X-LFS-Provided-By:   LFS BLFS
### END INIT INFO

. /lib/lsb/init-functions

BIN_FILE="/sbin/hwclock"
CONFIGFILE="/etc/sysconfig/clock"

chk_stat

. "${CONFIGFILE}"

CLOCKPARAMS=

case "${UTC}" in
    yes|true|1)
        CLOCKPARAMS="${CLOCKPARAMS} --utc"
        ;;

    no|false|0)
        CLOCKPARAMS="${CLOCKPARAMS} --localtime"
        ;;

esac

case ${1} in
    start)
        message="Setting system clock..."
        ${BIN_FILE} --hctosys ${CLOCKPARAMS} >/dev/null
        evaluate_retval standard
        ;;

    stop)
        message="Setting hardware clock..."
        ${BIN_FILE} --systohc ${CLOCKPARAMS} >/dev/null
        evaluate_retval standard
        ;;

    *)
        echo "Usage: ${0} {start|stop}"
        ;;

esac

# End /etc/init.d/setclock