]> git.pld-linux.org Git - packages/tzdata.git/blame - timezone.init
- add from rc-scripts
[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
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
47stop() {
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
54RETVAL=0
55# See how we were called.
56case "$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
70esac
71
72unset ZONE_FILE ZONE_INFO_DIR ZONE_INFO_SCHEME ZONE_INFO_AREA TIME_ZONE MESSAGE
73
74exit $RETVAL
This page took 0.240971 seconds and 4 git commands to generate.