diff --git a/src/confd/share/migrate/1.4/10-dhcp-client-option-name.sh b/src/confd/share/migrate/1.4/10-dhcp-client-option-name.sh index 5b1d4cb3..70b90d6b 100755 --- a/src/confd/share/migrate/1.4/10-dhcp-client-option-name.sh +++ b/src/confd/share/migrate/1.4/10-dhcp-client-option-name.sh @@ -1,5 +1,6 @@ #!/bin/sh -# Rename DHCP client option attribute 'name' -> 'id' to make DHCP server. +# Rename DHCP client option attribute 'name' -> 'id' +# to match the DHCP server nomenclature. file=$1 temp=${file}.tmp diff --git a/src/confd/share/migrate/1.4/20-dhcp-client-option-remap.sh b/src/confd/share/migrate/1.4/20-dhcp-client-option-remap.sh new file mode 100755 index 00000000..a6252f3a --- /dev/null +++ b/src/confd/share/migrate/1.4/20-dhcp-client-option-remap.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Remap DHCP client options to match DHCP server nomenclature. + +file=$1 +temp=${file}.tmp + +jq '( + .["infix-dhcp-client:dhcp-client"]?."client-if"[]?.option[]? |= + if has("id") then + .id = ({ + "subnet" : "netmask", + "dns" : "dns-server", + "ntpsrv" : "ntp-server", + "clientid" : "client-id", + "staticroutes" : "classless-static-route", + "msstaticroutes" : "ms-classless-static-route" + }[.id] // .id) + else + . + end +)' "$file" > "$temp" && + mv "$temp" "$file" diff --git a/src/confd/share/migrate/1.4/Makefile.am b/src/confd/share/migrate/1.4/Makefile.am index 9c4e0ec2..c81d82db 100644 --- a/src/confd/share/migrate/1.4/Makefile.am +++ b/src/confd/share/migrate/1.4/Makefile.am @@ -1,2 +1,3 @@ migratedir = $(pkgdatadir)/migrate/1.4 -dist_migrate_DATA = 10-dhcp-client-option-name.sh +dist_migrate_DATA = 10-dhcp-client-option-name.sh \ + 20-dhcp-client-option-remap.sh