]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/init.d/timezone
- preparation for upcoming 0.4.0.1 release
[projects/rc-scripts.git] / rc.d / init.d / timezone
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 # NLS
11 NLS_DOMAIN="rc-scripts"
12
13 # Source function library.
14 . /etc/rc.d/init.d/functions
15
16 [ ! -f /etc/sysconfig/timezone ] && exit 0
17 . /etc/sysconfig/timezone
18
19 ZONE_FILE="$ZONE_INFO_DIR"
20
21 if [ -n "$ZONE_INFO_SCHEME" -a "$ZONE_INFO_SCHEME" != "posix" ]; then
22     ZONE_FILE="$ZONE_FILE/$ZONE_INFO_SCHEME"
23 fi
24
25 if [ -n "$ZONE_INFO_AREA" ]; then
26     ZONE_FILE="$ZONE_FILE/$ZONE_INFO_AREA"
27 fi
28
29 ZONE_FILE="$ZONE_FILE/$TIME_ZONE"
30
31 [ -L /etc/localtime -a "`resolvesymlink /etc/localtime`" = "$ZONE_FILE" ] && exit 0
32
33 # See how we were called.
34 case "$1" in
35   start)
36         rm -f /etc/localtime
37         if [ -f "$ZONE_FILE" ]; then
38                 if [ -n "$ZONE_INFO_AREA" ]; then
39                     MESSAGE="`nls 'Setting time zone information (%s, %s)' "$ZONE_INFO_AREA" "$TIME_ZONE"`"
40                 else
41                     MESSAGE="`nls 'Setting time zone information (%s)' "$TIME_ZONE"`"
42                 fi
43                 run_cmd "$MESSAGE" ln -s $ZONE_FILE /etc/localtime
44                 RETVAL=$?
45         fi
46         ;;
47   stop)
48             run_cmd "Unsetting time zone information" rm -f /etc/localtime
49             RETVAL=$?
50         ;;
51   restart)
52           $0 stop
53           $0 start
54         ;;
55   reload)
56           $0 restart
57         ;;
58   *)
59         echo "Usage: $0 {start|stop|restart|reload}"
60         exit 1
61 esac
62
63 unset ZONE_FILE ZONE_INFO_DIR ZONE_INFO_SCHEME ZONE_INFO_AREA TIME_ZONE MESSAGE
64
65 exit $RETVAL
66
67 # This must be last line !
68 # vi:syntax=sh:tw=78:ts=8:sw=4
This page took 0.031154 seconds and 3 git commands to generate.