1# $NetBSD: 15-timezone,v 1.6 2014/11/07 20:51:03 roy Exp $
2
3# Configure timezone
4
5: ${localtime:=/etc/localtime}
6
7set_zoneinfo()
8{
9	local zoneinfo_dir= zone_file=
10
11	[ -z "$new_tzdb_timezone" ] && return 0
12
13	for d in \
14		/usr/share/zoneinfo	\
15		/usr/lib/zoneinfo	\
16		/var/share/zoneinfo	\
17		/var/zoneinfo		\
18	; do
19		if [ -d "$d" ]; then
20			zoneinfo_dir="$d"
21			break
22		fi
23	done
24
25	if [ -z "$zoneinfo_dir" ]; then
26		syslog warning "timezone directory not found"
27		return 1
28	fi
29
30	zone_file="$zoneinfo_dir/$new_tzdb_timezone"
31	if [ ! -e "$zone_file" ]; then
32		syslog warning "no timezone definition for $new_tzdb_timezone"
33		return 1
34	fi
35
36	if copy_file "$zone_file" "$localtime"; then
37		syslog info "timezone changed to $new_tzdb_timezone"
38	fi
39}
40
41# For ease of use, map DHCP6 names onto our DHCP4 names
42case "$reason" in
43BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
44	new_tzdb_timezone="$new_dhcp6_tzdb_timezone"
45	;;
46esac
47
48if $if_up; then
49 	set_zoneinfo
50fi
51