diff options
Diffstat (limited to 'builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone')
-rwxr-xr-x | builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone new file mode 100755 index 00000000..0ccdc45b --- /dev/null +++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone @@ -0,0 +1,48 @@ +# Configure timezone + +: ${localtime:=/etc/localtime} + +set_zoneinfo() +{ + local zoneinfo_dir= zone_file= + + [ -z "$new_tzdb_timezone" ] && return 0 + + for d in \ + /usr/share/zoneinfo \ + /usr/lib/zoneinfo \ + /var/share/zoneinfo \ + /var/zoneinfo \ + ; do + if [ -d "$d" ]; then + zoneinfo_dir="$d" + break + fi + done + + if [ -z "$zoneinfo_dir" ]; then + syslog warning "timezone directory not found" + return 1 + fi + + zone_file="$zoneinfo_dir/$new_tzdb_timezone" + if [ ! -e "$zone_file" ]; then + syslog warning "no timezone definition for $new_tzdb_timezone" + return 1 + fi + + if copy_file "$zone_file" "$localtime"; then + syslog info "timezone changed to $new_tzdb_timezone" + fi +} + +# For ease of use, map DHCP6 names onto our DHCP4 names +case "$reason" in +BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6) + new_tzdb_timezone="$new_dhcp6_tzdb_timezone" + ;; +esac + +if $if_up; then + set_zoneinfo +fi |