]>
Commit | Line | Data |
---|---|---|
462b45ea ER |
1 | #!/bin/sh |
2 | # | |
3 | # timezone Set time zone information. | |
4 | # chkconfig: 2345 10 70 | |
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 | ||
23 | if [ -n "$ZONE_INFO_AREA" ]; then | |
24 | ZONE_FILE="$ZONE_FILE/$ZONE_INFO_AREA" | |
25 | fi | |
26 | ||
27 | ZONE_FILE="$ZONE_FILE/$TIME_ZONE" | |
28 | ||
b1e44da8 | 29 | [ -L /etc/localtime ] && [ "$(resolvesymlink /etc/localtime)" = "$ZONE_FILE" ] && exit 0 |
462b45ea ER |
30 | |
31 | start() { | |
32 | if [ ! -f /var/lock/subsys/timezone ]; then | |
462b45ea | 33 | if [ -f "$ZONE_FILE" ]; then |
fe8f4f97 ER |
34 | rm -f /etc/localtime |
35 | ||
462b45ea ER |
36 | if [ -n "$ZONE_INFO_AREA" ]; then |
37 | MESSAGE="`nls 'Setting time zone information (%s, %s)' "$ZONE_INFO_AREA" "$TIME_ZONE"`" | |
38 | else | |
39 | MESSAGE="`nls 'Setting time zone information (%s)' "$TIME_ZONE"`" | |
40 | fi | |
41 | run_cmd "$MESSAGE" cp -af $ZONE_FILE /etc/localtime | |
42 | RETVAL=$? | |
43 | fi | |
44 | ||
45 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timezone | |
46 | fi | |
47 | } | |
48 | ||
49 | stop() { | |
50 | if [ -f /var/lock/subsys/timezone ]; then | |
462b45ea ER |
51 | rm -f /var/lock/subsys/timezone |
52 | fi | |
53 | } | |
54 | ||
a9d82c32 ER |
55 | disable() { |
56 | run_cmd "Unsetting time zone information" rm -f /etc/localtime | |
57 | } | |
58 | ||
462b45ea ER |
59 | RETVAL=0 |
60 | # See how we were called. | |
61 | case "$1" in | |
62 | start) | |
63 | start | |
64 | ;; | |
65 | stop) | |
66 | stop | |
67 | ;; | |
68 | restart|reload) | |
69 | stop | |
70 | start | |
71 | ;; | |
a9d82c32 ER |
72 | disable) |
73 | disable | |
74 | ;; | |
462b45ea | 75 | *) |
a9d82c32 | 76 | msg_usage "$0 {start|stop|restart|reload|disable}" |
462b45ea ER |
77 | exit 3 |
78 | esac | |
79 | ||
462b45ea | 80 | exit $RETVAL |