]> git.pld-linux.org Git - packages/tzdata.git/blob - timezone.init
- ignore /var/lock/subsys remove readonly fs errors (after fsck wants to reboot system)
[packages/tzdata.git] / timezone.init
1 #!/bin/sh
2 #
3 # timezone      Set time zone information.
4 # chkconfig:    2345 10 90
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 [ -f /etc/sysconfig/timezone ] || exit 0
11
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 . /etc/sysconfig/timezone
16
17 ZONE_FILE="$ZONE_INFO_DIR"
18
19 if [ -n "$ZONE_INFO_SCHEME" -a "$ZONE_INFO_SCHEME" != "posix" ]; then
20         ZONE_FILE="$ZONE_FILE/$ZONE_INFO_SCHEME"
21 fi
22
23 ZONE_FILE="$ZONE_FILE/$TIMEZONE"
24
25 [ -L /etc/localtime ] && [ "$(resolvesymlink /etc/localtime)" = "$ZONE_FILE" ] && exit 0
26
27 start() {
28         if [ -f /var/lock/subsys/timezone ]; then
29                 return
30         fi
31
32         if [ -f "$ZONE_FILE" ]; then
33                 rm -f /etc/localtime
34
35                 MESSAGE=$(nls 'Setting time zone information (%s)' "$TIMEZONE")
36
37                 run_cmd "$MESSAGE" cp -af $ZONE_FILE /etc/localtime
38                 RETVAL=$?
39                 restorecon /etc/localtime >/dev/null 2>&1
40         fi
41
42         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timezone
43 }
44
45 stop() {
46         rm -f /var/lock/subsys/timezone >/dev/null 2>&1
47 }
48
49 disable() {
50         run_cmd "Unsetting time zone information" rm -f /etc/localtime
51 }
52
53 RETVAL=0
54 # See how we were called.
55 case "$1" in
56   start)
57         start
58         ;;
59   stop)
60         stop
61         ;;
62   restart|try-restart|reload|force-reload)
63         stop
64         start
65         ;;
66   disable)
67         disable
68         ;;
69   status)
70         nls 'Time zone configured to (%s)' "$TIMEZONE"
71         ;;
72   *)
73         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|disable|status}"
74         exit 3
75 esac
76
77 exit $RETVAL
This page took 0.032208 seconds and 4 git commands to generate.