]> git.pld-linux.org Git - packages/tzdata.git/blame - timezone.init
- remove /etc/localtime only if we have chance to succeed
[packages/tzdata.git] / timezone.init
CommitLineData
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
16ZONE_FILE="$ZONE_INFO_DIR"
17
18if [ -n "$ZONE_INFO_SCHEME" -a "$ZONE_INFO_SCHEME" != "posix" ]; then
19 ZONE_FILE="$ZONE_FILE/$ZONE_INFO_SCHEME"
20fi
21
22if [ -n "$ZONE_INFO_AREA" ]; then
23 ZONE_FILE="$ZONE_FILE/$ZONE_INFO_AREA"
24fi
25
26ZONE_FILE="$ZONE_FILE/$TIME_ZONE"
27
28[ -L /etc/localtime -a "`resolvesymlink /etc/localtime`" = "$ZONE_FILE" ] && exit 0
29
30start() {
31 if [ ! -f /var/lock/subsys/timezone ]; then
462b45ea 32 if [ -f "$ZONE_FILE" ]; then
fe8f4f97
ER
33 rm -f /etc/localtime
34
462b45ea
ER
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
48stop() {
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
55RETVAL=0
56# See how we were called.
57case "$1" in
58 start)
59 start
60 ;;
61 stop)
62 stop
63 ;;
64 restart|reload)
65 stop
66 start
67 ;;
68 *)
a18d553b 69 msg_usage "$0 {start|stop|restart|reload}"
462b45ea
ER
70 exit 3
71esac
72
462b45ea 73exit $RETVAL
This page took 0.059498 seconds and 4 git commands to generate.