]> git.pld-linux.org Git - packages/tzdata.git/blame - timezone.init
up to 2013c
[packages/tzdata.git] / timezone.init
CommitLineData
462b45ea
ER
1#!/bin/sh
2#
3# timezone Set time zone information.
315b0b3a 4# chkconfig: 2345 10 90
462b45ea 5# description: This script is setting time zone information for your machine.
462b45ea
ER
6#
7# $Id$
8
b1e44da8
ER
9[ -f /etc/sysconfig/timezone ] || exit 0
10
462b45ea
ER
11# Source function library.
12. /etc/rc.d/init.d/functions
13
f2cdc68f
ER
14upstart_controlled --except status disable
15
462b45ea
ER
16. /etc/sysconfig/timezone
17
18ZONE_FILE="$ZONE_INFO_DIR"
19
20if [ -n "$ZONE_INFO_SCHEME" -a "$ZONE_INFO_SCHEME" != "posix" ]; then
21 ZONE_FILE="$ZONE_FILE/$ZONE_INFO_SCHEME"
22fi
23
9074097d 24ZONE_FILE="$ZONE_FILE/$TIMEZONE"
462b45ea 25
b1e44da8 26[ -L /etc/localtime ] && [ "$(resolvesymlink /etc/localtime)" = "$ZONE_FILE" ] && exit 0
462b45ea
ER
27
28start() {
96bffd52 29 if [ -f /var/lock/subsys/timezone ]; then
8c564fe6 30 msg_already_running timezone
96bffd52
ER
31 return
32 fi
fe8f4f97 33
96bffd52
ER
34 if [ -f "$ZONE_FILE" ]; then
35 rm -f /etc/localtime
9074097d 36
96bffd52 37 MESSAGE=$(nls 'Setting time zone information (%s)' "$TIMEZONE")
462b45ea 38
8c564fe6 39 run_cmd "$MESSAGE" cp -af "$ZONE_FILE" /etc/localtime
96bffd52
ER
40 RETVAL=$?
41 restorecon /etc/localtime >/dev/null 2>&1
8c564fe6
TP
42 else
43 show "Missing %s file" "$ZONE_FILE"
44 fail
27ab39d6 45 RETVAL=2
462b45ea 46 fi
96bffd52
ER
47
48 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timezone
462b45ea
ER
49}
50
51stop() {
038f1b94 52 rm -f /var/lock/subsys/timezone >/dev/null 2>&1
462b45ea
ER
53}
54
a9d82c32
ER
55disable() {
56 run_cmd "Unsetting time zone information" rm -f /etc/localtime
57}
58
9b59d724
ER
59# return true if FILE1 and FILE2 are identical
60identical() {
61 local crc1 crc2
62 crc1=$(cksum "$1" | awk '{print $1}')
63 crc2=$(cksum "$2" | awk '{print $1}')
64 [ "$crc1" = "$crc2" ]
65}
66
462b45ea
ER
67RETVAL=0
68# See how we were called.
69case "$1" in
70 start)
71 start
72 ;;
73 stop)
8c564fe6 74 stop
462b45ea 75 ;;
c5e2e190 76 restart|try-restart|reload|force-reload)
462b45ea
ER
77 stop
78 start
79 ;;
a9d82c32
ER
80 disable)
81 disable
82 ;;
64534ab1 83 status)
f2cdc68f 84 nls 'Timezone is configured to %s' "$TIMEZONE"
7e337acd
ER
85 if [ ! -f "$ZONE_FILE" ]; then
86 nls "Missing %s file" "$ZONE_FILE"
87 elif ! identical "$ZONE_FILE" /etc/localtime; then
8c564fe6 88 nls 'Current time zone differs from %s!' "$TIMEZONE"
8c564fe6 89 fi
64534ab1 90 ;;
462b45ea 91 *)
c5e2e190 92 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|disable|status}"
462b45ea
ER
93 exit 3
94esac
95
462b45ea 96exit $RETVAL
This page took 0.077136 seconds and 4 git commands to generate.