]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add new hook script.
authorRoy Marples <roy@marples.name>
Fri, 3 May 2013 13:45:21 +0000 (13:45 +0000)
committerRoy Marples <roy@marples.name>
Fri, 3 May 2013 13:45:21 +0000 (13:45 +0000)
dhcpcd-hooks/15-timezone [new file with mode: 0644]

diff --git a/dhcpcd-hooks/15-timezone b/dhcpcd-hooks/15-timezone
new file mode 100644 (file)
index 0000000..d831004
--- /dev/null
@@ -0,0 +1,52 @@
+# 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 "$interface: timezone directory not found"
+               return 1
+       fi
+
+       zone_file="$zoneinfo_dir/$new_tzdb_timezone"
+       if [ ! -e "$zone_file" ]; then
+               syslog warning \
+                   "$interface: no timezone definition for $new_tzdb_timezone"
+               return 1
+       fi
+
+       syslog info "$interface: timezone changed to $new_tzdb_timezone"
+       if [ -h "$localtime" ]; then
+               ln -sf "$zone_file" "$localtime"
+       else
+               cp "$zone_file" "$localtime"
+       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