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