]> git.pld-linux.org Git - packages/tzdata.git/blame - timezone.init
- use cksum from coreutils for identical-file test
[packages/tzdata.git] / timezone.init
CommitLineData
462b45ea
ER
1#!/bin/sh
2#
3# timezone Set time zone information.
315b0b3a 4# chkconfig: 2345 10 90
462b45ea 5# description: This script is setting time zone information for your machine.
462b45ea
ER
6#
7# $Id$
8
b1e44da8
ER
9[ -f /etc/sysconfig/timezone ] || exit 0
10
462b45ea
ER
11# Source function library.
12. /etc/rc.d/init.d/functions
13
462b45ea
ER
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
9074097d 22ZONE_FILE="$ZONE_FILE/$TIMEZONE"
462b45ea 23
b1e44da8 24[ -L /etc/localtime ] && [ "$(resolvesymlink /etc/localtime)" = "$ZONE_FILE" ] && exit 0
462b45ea
ER
25
26start() {
96bffd52 27 if [ -f /var/lock/subsys/timezone ]; then
8c564fe6 28 msg_already_running timezone
96bffd52
ER
29 return
30 fi
fe8f4f97 31
96bffd52
ER
32 if [ -f "$ZONE_FILE" ]; then
33 rm -f /etc/localtime
9074097d 34
96bffd52 35 MESSAGE=$(nls 'Setting time zone information (%s)' "$TIMEZONE")
462b45ea 36
8c564fe6 37 run_cmd "$MESSAGE" cp -af "$ZONE_FILE" /etc/localtime
96bffd52
ER
38 RETVAL=$?
39 restorecon /etc/localtime >/dev/null 2>&1
8c564fe6
TP
40 else
41 show "Missing %s file" "$ZONE_FILE"
42 fail
462b45ea 43 fi
96bffd52
ER
44
45 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/timezone
462b45ea
ER
46}
47
48stop() {
038f1b94 49 rm -f /var/lock/subsys/timezone >/dev/null 2>&1
462b45ea
ER
50}
51
a9d82c32
ER
52disable() {
53 run_cmd "Unsetting time zone information" rm -f /etc/localtime
54}
55
9b59d724
ER
56# return true if FILE1 and FILE2 are identical
57identical() {
58 local crc1 crc2
59 crc1=$(cksum "$1" | awk '{print $1}')
60 crc2=$(cksum "$2" | awk '{print $1}')
61 [ "$crc1" = "$crc2" ]
62}
63
462b45ea
ER
64RETVAL=0
65# See how we were called.
66case "$1" in
67 start)
68 start
69 ;;
70 stop)
8c564fe6 71 stop
462b45ea 72 ;;
c5e2e190 73 restart|try-restart|reload|force-reload)
462b45ea
ER
74 stop
75 start
76 ;;
a9d82c32
ER
77 disable)
78 disable
79 ;;
64534ab1 80 status)
9b59d724
ER
81 nls 'Time zone is configured to %s' "$TIMEZONE"
82 if ! identical "$ZONE_FILE" /etc/localtime; then
8c564fe6 83 nls 'Current time zone differs from %s!' "$TIMEZONE"
8c564fe6 84 fi
64534ab1 85 ;;
462b45ea 86 *)
c5e2e190 87 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|disable|status}"
462b45ea
ER
88 exit 3
89esac
90
462b45ea 91exit $RETVAL
This page took 0.085533 seconds and 4 git commands to generate.