]> git.pld-linux.org Git - packages/tzdata.git/blob - timezone.init
- remove /etc/localtime only if we have chance to succeed
[packages/tzdata.git] / timezone.init
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                 if [ -f "$ZONE_FILE" ]; then
33                         rm -f /etc/localtime
34
35                         if [ -n "$ZONE_INFO_AREA" ]; then
36                                 MESSAGE="`nls 'Setting time zone information (%s, %s)' "$ZONE_INFO_AREA" "$TIME_ZONE"`"
37                         else
38                                 MESSAGE="`nls 'Setting time zone information (%s)' "$TIME_ZONE"`"
39                         fi
40                         run_cmd "$MESSAGE" cp -af $ZONE_FILE /etc/localtime
41                         RETVAL=$?
42                 fi
43
44                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timezone
45         fi
46 }
47
48 stop() {
49         if [ -f /var/lock/subsys/timezone ]; then
50                 run_cmd "Unsetting time zone information" rm -f /etc/localtime
51                 rm -f /var/lock/subsys/timezone
52         fi
53 }
54
55 RETVAL=0
56 # See how we were called.
57 case "$1" in
58   start)
59         start
60         ;;
61   stop)
62         stop
63         ;;
64   restart|reload)
65         stop
66         start
67         ;;
68   *)
69         msg_usage "$0 {start|stop|restart|reload}"
70         exit 3
71 esac
72
73 exit $RETVAL
This page took 0.090878 seconds and 4 git commands to generate.