]>
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 | ||
10 | # Source function library. | |
11 | . /etc/rc.d/init.d/functions | |
12 | ||
13 | [ ! -f /etc/sysconfig/timezone ] && exit 0 | |
14 | . /etc/sysconfig/timezone | |
15 | ||
16 | ZONE_FILE="$ZONE_INFO_DIR" | |
17 | ||
18 | if [ -n "$ZONE_INFO_SCHEME" -a "$ZONE_INFO_SCHEME" != "posix" ]; then | |
19 | ZONE_FILE="$ZONE_FILE/$ZONE_INFO_SCHEME" | |
20 | fi | |
21 | ||
22 | if [ -n "$ZONE_INFO_AREA" ]; then | |
23 | ZONE_FILE="$ZONE_FILE/$ZONE_INFO_AREA" | |
24 | fi | |
25 | ||
26 | ZONE_FILE="$ZONE_FILE/$TIME_ZONE" | |
27 | ||
28 | [ -L /etc/localtime -a "`resolvesymlink /etc/localtime`" = "$ZONE_FILE" ] && exit 0 | |
29 | ||
30 | start() { | |
31 | if [ ! -f /var/lock/subsys/timezone ]; then | |
32 | rm -f /etc/localtime | |
33 | if [ -f "$ZONE_FILE" ]; then | |
34 | if [ -n "$ZONE_INFO_AREA" ]; then | |
35 | MESSAGE="`nls 'Setting time zone information (%s, %s)' "$ZONE_INFO_AREA" "$TIME_ZONE"`" | |
36 | else | |
37 | MESSAGE="`nls 'Setting time zone information (%s)' "$TIME_ZONE"`" | |
38 | fi | |
39 | run_cmd "$MESSAGE" cp -af $ZONE_FILE /etc/localtime | |
40 | RETVAL=$? | |
41 | fi | |
42 | ||
43 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timezone | |
44 | fi | |
45 | } | |
46 | ||
47 | stop() { | |
48 | if [ -f /var/lock/subsys/timezone ]; then | |
49 | run_cmd "Unsetting time zone information" rm -f /etc/localtime | |
50 | rm -f /var/lock/subsys/timezone | |
51 | fi | |
52 | } | |
53 | ||
54 | RETVAL=0 | |
55 | # See how we were called. | |
56 | case "$1" in | |
57 | start) | |
58 | start | |
59 | ;; | |
60 | stop) | |
61 | stop | |
62 | ;; | |
63 | restart|reload) | |
64 | stop | |
65 | start | |
66 | ;; | |
67 | *) | |
68 | echo "Usage: $0 {start|stop|restart|reload}" | |
69 | exit 3 | |
70 | esac | |
71 | ||
72 | unset ZONE_FILE ZONE_INFO_DIR ZONE_INFO_SCHEME ZONE_INFO_AREA TIME_ZONE MESSAGE | |
73 | ||
74 | exit $RETVAL |