]>
Commit | Line | Data |
---|---|---|
462b45ea ER |
1 | #!/bin/sh |
2 | # | |
3 | # timezone Set time zone information. | |
315b0b3a | 4 | # chkconfig: 2345 10 90 |
462b45ea ER |
5 | # description: This script is setting time zone information for your machine. |
6 | # Author: Pawel Wilk <siefca@pld-linux.org> | |
7 | # | |
8 | # $Id$ | |
9 | ||
b1e44da8 ER |
10 | [ -f /etc/sysconfig/timezone ] || exit 0 |
11 | ||
462b45ea ER |
12 | # Source function library. |
13 | . /etc/rc.d/init.d/functions | |
14 | ||
462b45ea ER |
15 | . /etc/sysconfig/timezone |
16 | ||
17 | ZONE_FILE="$ZONE_INFO_DIR" | |
18 | ||
19 | if [ -n "$ZONE_INFO_SCHEME" -a "$ZONE_INFO_SCHEME" != "posix" ]; then | |
20 | ZONE_FILE="$ZONE_FILE/$ZONE_INFO_SCHEME" | |
21 | fi | |
22 | ||
9074097d | 23 | ZONE_FILE="$ZONE_FILE/$TIMEZONE" |
462b45ea | 24 | |
b1e44da8 | 25 | [ -L /etc/localtime ] && [ "$(resolvesymlink /etc/localtime)" = "$ZONE_FILE" ] && exit 0 |
462b45ea ER |
26 | |
27 | start() { | |
96bffd52 ER |
28 | if [ -f /var/lock/subsys/timezone ]; then |
29 | return | |
30 | fi | |
fe8f4f97 | 31 | |
96bffd52 ER |
32 | if [ -f "$ZONE_FILE" ]; then |
33 | rm -f /etc/localtime | |
9074097d | 34 | |
96bffd52 | 35 | MESSAGE=$(nls 'Setting time zone information (%s)' "$TIMEZONE") |
462b45ea | 36 | |
96bffd52 ER |
37 | run_cmd "$MESSAGE" cp -af $ZONE_FILE /etc/localtime |
38 | RETVAL=$? | |
39 | restorecon /etc/localtime >/dev/null 2>&1 | |
462b45ea | 40 | fi |
96bffd52 ER |
41 | |
42 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timezone | |
462b45ea ER |
43 | } |
44 | ||
45 | stop() { | |
46 | if [ -f /var/lock/subsys/timezone ]; then | |
462b45ea ER |
47 | rm -f /var/lock/subsys/timezone |
48 | fi | |
49 | } | |
50 | ||
a9d82c32 ER |
51 | disable() { |
52 | run_cmd "Unsetting time zone information" rm -f /etc/localtime | |
53 | } | |
54 | ||
462b45ea ER |
55 | RETVAL=0 |
56 | # See how we were called. | |
57 | case "$1" in | |
58 | start) | |
59 | start | |
60 | ;; | |
61 | stop) | |
62 | stop | |
63 | ;; | |
c5e2e190 | 64 | restart|try-restart|reload|force-reload) |
462b45ea ER |
65 | stop |
66 | start | |
67 | ;; | |
a9d82c32 ER |
68 | disable) |
69 | disable | |
70 | ;; | |
64534ab1 | 71 | status) |
9074097d | 72 | nls 'Time zone configured to (%s)' "$TIMEZONE" |
64534ab1 | 73 | ;; |
462b45ea | 74 | *) |
c5e2e190 | 75 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|disable|status}" |
462b45ea ER |
76 | exit 3 |
77 | esac | |
78 | ||
462b45ea | 79 | exit $RETVAL |