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