diff options
author | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2022-02-27 11:35:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2022-02-27 11:35:36 +0000 |
commit | 221bf95949d4176e5276c7e8bfafa56c9104328b (patch) | |
tree | 5c882566cc9819bbccf07ec233c9185a390e4de9 | |
parent | Releasing version 20211231. (diff) | |
download | compute-tools-221bf95949d4176e5276c7e8bfafa56c9104328b.tar.xz compute-tools-221bf95949d4176e5276c7e8bfafa56c9104328b.zip |
Adding support for deriving IP interface addresses from DNS.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-x | share/build-scripts/debconf | 22 | ||||
-rwxr-xr-x | share/build-scripts/debconf.d/0002-preseed-debconf | 8 | ||||
-rwxr-xr-x | share/build-scripts/debconf.d/0003-debconf | 38 | ||||
-rw-r--r-- | share/build-scripts/debconf.d/0003-debconf.templates | 16 |
4 files changed, 74 insertions, 10 deletions
diff --git a/share/build-scripts/debconf b/share/build-scripts/debconf index 39856ae..688e77d 100755 --- a/share/build-scripts/debconf +++ b/share/build-scripts/debconf @@ -596,26 +596,30 @@ EOF if [ -n "${DIG}" ] then - IPV4_ADDRESS1="$(${DIG} A +short ${NAME} | tail -n1)" + IPV4_ADDRESS1_DNS="${IPV4_ADDRESS1_DNS:-${NAME}}" + IPV4_ADDRESS1="$(${DIG} A +short ${IPV4_ADDRESS1_DNS} | tail -n1)" IPV4_ADDRESS1_PART1="$(echo ${IPV4_ADDRESS1} | cut -d. -f1)" IPV4_ADDRESS1_PART2="$(echo ${IPV4_ADDRESS1} | cut -d. -f2)" IPV4_ADDRESS1_PART3="$(echo ${IPV4_ADDRESS1} | cut -d. -f3)" IPV4_ADDRESS1_PART4="$(echo ${IPV4_ADDRESS1} | cut -d. -f4)" - IPV6_ADDRESS1="$(${DIG} AAAA +short ${NAME} | tail -n1)" + IPV6_ADDRESS1_DNS="${IPV6_ADDRESS1_DNS:-${NAME}}" + IPV6_ADDRESS1="$(${DIG} AAAA +short ${IPV6_ADDRESS1_DNS} | tail -n1)" # FIXME: address parts - export IPV4_ADDRESS1 IPV4_ADDRESS1_PART1 IPV4_ADDRESS1_PART2 IPV4_ADDRESS1_PART3 IPV4_ADDRESS1_PART4 - export IPV6_ADDRESS1 + export IPV4_ADDRESS1_DNS IPV4_ADDRESS1 IPV4_ADDRESS1_PART1 IPV4_ADDRESS1_PART2 IPV4_ADDRESS1_PART3 IPV4_ADDRESS1_PART4 + export IPV6_ADDRESS1_DNS IPV6_ADDRESS1 fi sed -e "s|@FILE@|${FILE}|g" \ -e "s|@NAME@|${NAME}|g" \ + -e "s|@IPV4_ADDRESS1_DNS@|${IPV4_ADDRESS1_DNS}|g" \ -e "s|@IPV4_ADDRESS1@|${IPV4_ADDRESS1}|g" \ -e "s|@IPV4_ADDRESS1_PART1@|${IPV4_ADDRESS1_PART1}|g" \ -e "s|@IPV4_ADDRESS1_PART2@|${IPV4_ADDRESS1_PART2}|g" \ -e "s|@IPV4_ADDRESS1_PART3@|${IPV4_ADDRESS1_PART3}|g" \ -e "s|@IPV4_ADDRESS1_PART4@|${IPV4_ADDRESS1_PART4}|g" \ + -e "s|@IPV6_ADDRESS1_DNS@|${IPV6_ADDRESS1_DNS}|g" \ -e "s|@IPV6_ADDRESS1@|${IPV6_ADDRESS1}|g" \ "${FILE}" >> "${DIRECTORY}/preseed.cfg" done @@ -757,7 +761,7 @@ Configure_network () then cat >> "${DIRECTORY}/etc/hosts.tmp" << EOF -${NETWORK1_IPV4_ADDRESS} ${NAME} +${NETWORK1_IPV4_ADDRESS} ${NETWORK1_IPV4_ADDRESS_DNS} EOF fi @@ -766,7 +770,7 @@ EOF then cat >> "${DIRECTORY}/etc/hosts.tmp" << EOF -${NETWORK1_IPV6_ADDRESS} ${NAME} +${NETWORK1_IPV6_ADDRESS} ${NETWORK1_IPV6_ADDRESS_DNS} EOF fi @@ -781,8 +785,8 @@ EOF # localhost only cat > "${DIRECTORY}/etc/hosts.tmp" << EOF -127.0.0.1 localhost ${NAME} -::1 localhost ${NAME} +127.0.0.1 localhost ${NETWORK1_IPV4_ADDRESS_DNS} +::1 localhost ${NETWORK1_IPV6_ADDRESS_DNS} EOF else @@ -818,6 +822,7 @@ Configure_systemd_networkd () do eval IPV4_COMMENT="$`echo NETWORK${NUMBER}_IPV4_COMMENT`" eval IPV4_METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`" + eval IPV4_ADDRESS_DNS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS_DNS`" eval IPV4_ADDRESS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS`" eval IPV4_GATEWAY="$`echo NETWORK${NUMBER}_IPV4_GATEWAY`" eval IPV4_NETMASK="$`echo NETWORK${NUMBER}_IPV4_NETMASK`" @@ -826,6 +831,7 @@ Configure_systemd_networkd () eval IPV6_COMMENT="$`echo NETWORK${NUMBER}_IPV6_COMMENT`" eval IPV6_METHOD="$`echo NETWORK${NUMBER}_IPV6_METHOD`" + eval IPV6_ADDRESS_DNS="$`echo NETWORK${NUMBER}_IPV6_ADDRESS_DNS`" eval IPV6_ADDRESS="$`echo NETWORK${NUMBER}_IPV6_ADDRESS`" eval IPV6_GATEWAY="$`echo NETWORK${NUMBER}_IPV6_GATEWAY`" eval IPV6_NETMASK="$`echo NETWORK${NUMBER}_IPV6_NETMASK`" diff --git a/share/build-scripts/debconf.d/0002-preseed-debconf b/share/build-scripts/debconf.d/0002-preseed-debconf index 4bc4da6..3f1af64 100755 --- a/share/build-scripts/debconf.d/0002-preseed-debconf +++ b/share/build-scripts/debconf.d/0002-preseed-debconf @@ -83,21 +83,25 @@ do if [ -n "${DIG}" ] then - IPV4_ADDRESS1="$(${DIG} A +short ${NAME} | tail -n1)" + IPV4_ADDRESS1_DNS="${IPV4_ADDRESS1_DNS:-${NAME}}" + IPV4_ADDRESS1="$(${DIG} A +short ${IPV4_ADDRESS1_DNS} | tail -n1)" IPV4_ADDRESS1_PART1="$(echo ${IPV4_ADDRESS1} | cut -d. -f1)" IPV4_ADDRESS1_PART2="$(echo ${IPV4_ADDRESS1} | cut -d. -f2)" IPV4_ADDRESS1_PART3="$(echo ${IPV4_ADDRESS1} | cut -d. -f3)" IPV4_ADDRESS1_PART4="$(echo ${IPV4_ADDRESS1} | cut -d. -f4)" - IPV6_ADDRESS1="$(${DIG} AAAA +short ${NAME} | tail -n1)" + IPV6_ADDRESS1_DNS="${IPV6_ADDRESS1_DNS:-${NAME}}" + IPV6_ADDRESS1="$(${DIG} AAAA +short ${IPV6_ADDRESS1_DNS} | tail -n1)" fi sed -e "s|@NAME@|${NAME}|g" \ + -e "s|@IPV4_ADDRESS1_DNS@|${IPV4_ADDRESS1_DNS}|g" \ -e "s|@IPV4_ADDRESS1@|${IPV4_ADDRESS1}|g" \ -e "s|@IPV4_ADDRESS1_PART1@|${IPV4_ADDRESS1_PART1}|g" \ -e "s|@IPV4_ADDRESS1_PART2@|${IPV4_ADDRESS1_PART2}|g" \ -e "s|@IPV4_ADDRESS1_PART3@|${IPV4_ADDRESS1_PART3}|g" \ -e "s|@IPV4_ADDRESS1_PART4@|${IPV4_ADDRESS1_PART4}|g" \ + -e "s|@IPV6_ADDRESS1_DNS@|${IPV6_ADDRESS1_DNS}|g" \ -e "s|@IPV6_ADDRESS1@|${IPV6_ADDRESS1}|g" \ "${DEBCONF_PRESEED_FILE}" > "${DIRECTORY}/preseed.cfg" diff --git a/share/build-scripts/debconf.d/0003-debconf b/share/build-scripts/debconf.d/0003-debconf index c1c4e79..4b6a57f 100755 --- a/share/build-scripts/debconf.d/0003-debconf +++ b/share/build-scripts/debconf.d/0003-debconf @@ -680,10 +680,12 @@ Network_defaults () NETWORK1_BRIDGE="${NETWORK1_BRIDGE:-bridge0}" NETWORK1_IPV4_METHOD="${NETWORK1_IPV4_METHOD:-dhcp}" + NETWORK1_IPV4_ADDRESS_DNS="${NETWORK1_IPV4_ADDRESS_DNS:-${NAME}}" NETWORK1_IPV4_ADDRESS="${NETWORK1_IPV4_ADDRESS:-192.168.1.2}" NETWORK1_IPV4_NETMASK="${NETWORK1_IPV4_NETMASK:-24}" NETWORK1_IPV6_METHOD="${NETWORK1_IPV6_METHOD:-none}" + NETWORK1_IPV6_ADDRESS_DNS="${NETWORK1_IPV6_ADDRESS_DNS:-${NAME}}" NETWORK1_IPV6_ADDRESS="${NETWORK1_IPV6_ADDRESS:-fc00::2}" NETWORK1_IPV6_NETMASK="${NETWORK1_IPV6_NETMASK:-7}" @@ -716,6 +718,9 @@ Network () db_get container/network1/ipv4-comment NETWORK1_IPV4_COMMENT="${RET}" # string (w/ empty) + db_get container/network1/ipv4-address-dns + NETWORK1_IPV4_ADDRESS_DNS="${RET:-${NAME}}" # string (w/o empty) + db_get container/network1/ipv4-address NETWORK1_IPV4_ADDRESS="${RET}" # string (w/o empty) @@ -737,6 +742,9 @@ Network () db_get container/network1/ipv6-comment NETWORK1_IPV6_COMMENT="${RET}" # string (w/ empty) + db_get container/network1/ipv6-address-dns + NETWORK1_IPV6_ADDRESS_DNS="${RET:-${NAME}}" # string (w/o empty) + db_get container/network1/ipv6-address NETWORK1_IPV6_ADDRESS="${RET}" # string (w/o empty) @@ -778,6 +786,9 @@ Network () db_set container/network1/ipv4-comment "${NETWORK1_IPV4_COMMENT}" db_fset container/network1/ipv4-comment seen false + db_set container/network1/ipv4-address-dns "${NETWORK1_IPV4_ADDRESS_DNS}" + db_fset container/network1/ipv4-address-dns seen false + db_set container/network1/ipv4-address "${NETWORK1_IPV4_ADDRESS}" db_fset container/network1/ipv4-address seen false @@ -799,6 +810,9 @@ Network () db_set container/network1/ipv6-comment "${NETWORK1_IPV6_COMMENT}" db_fset container/network1/ipv6-comment seen false + db_set container/network1/ipv6-address-dns "${NETWORK1_IPV6_ADDRESS_DNS}" + db_fset container/network1/ipv6-address-dns seen false + db_set container/network1/ipv6-address "${NETWORK1_IPV6_ADDRESS}" db_fset container/network1/ipv6-address seen false @@ -849,6 +863,10 @@ Network () db_go db_settitle container/title + db_input high container/network1/ipv4-address-dns || true + db_go + + db_settitle container/title db_input high container/network1/ipv4-address || true db_go @@ -887,6 +905,10 @@ Network () db_go db_settitle container/title + db_input high container/network1/ipv6-address-dns || true + db_go + + db_settitle container/title db_input high container/network1/ipv6-address || true db_go @@ -946,6 +968,11 @@ Network () eval NETWORK${NUMBER}_IPV4_METHOD="\"${RET}\"" # select fi + if db_get container/network${NUMBER}/ipv4-address-dns + then + eval NETWORK${NUMBER}_IPV4_ADDRESS_DNS="\"${RET}\"" # string (w/ empty) + fi + if db_get container/network${NUMBER}/ipv4-address then eval NETWORK${NUMBER}_IPV4_ADDRESS="\"${RET}\"" # string (w/o empty) @@ -984,6 +1011,11 @@ Network () eval NETWORK${NUMBER}_IPV6_METHOD="\"${RET}\"" # select fi + if db_get container/network${NUMBER}/ipv6-address-dns + then + eval NETWORK${NUMBER}_IPV6_ADDRESS_DNS="\"${RET}\"" # string (w/ empty) + fi + if db_get container/network${NUMBER}/ipv6-address then eval NETWORK${NUMBER}_IPV6_ADDRESS="\"${RET}\"" # string (w/o empty) @@ -1040,6 +1072,9 @@ Network () eval METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`" echo "NETWORK${NUMBER}_IPV4_METHOD=\"${METHOD}\"" >> "${DEBCONF_TMPDIR}/debconf.default" + eval ADDRESS_DNS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS_DNS`" + echo "NETWORK${NUMBER}_IPV4_ADDRESS_DNS=\"${ADDRESS_DNS}\"" >> "${DEBCONF_TMPDIR}/debconf.default" + eval ADDRESS="$`echo NETWORK${NUMBER}_IPV4_ADDRESS`" echo "NETWORK${NUMBER}_IPV4_ADDRESS=\"${ADDRESS}\"" >> "${DEBCONF_TMPDIR}/debconf.default" @@ -1061,6 +1096,9 @@ Network () eval METHOD="$`echo NETWORK${NUMBER}_IPV6_METHOD`" echo "NETWORK${NUMBER}_IPV6_METHOD=\"${METHOD}\"" >> "${DEBCONF_TMPDIR}/debconf.default" + eval ADDRESS_DNS="$`echo NETWORK${NUMBER}_IPV6_ADDRESS_DNS`" + echo "NETWORK${NUMBER}_IPV6_ADDRESS_DNS=\"${ADDRESS_DNS}\"" >> "${DEBCONF_TMPDIR}/debconf.default" + eval ADDRESS="$`echo NETWORK${NUMBER}_IPV6_ADDRESS`" echo "NETWORK${NUMBER}_IPV6_ADDRESS=\"${ADDRESS}\"" >> "${DEBCONF_TMPDIR}/debconf.default" diff --git a/share/build-scripts/debconf.d/0003-debconf.templates b/share/build-scripts/debconf.d/0003-debconf.templates index 73952a8..73691ae 100644 --- a/share/build-scripts/debconf.d/0003-debconf.templates +++ b/share/build-scripts/debconf.d/0003-debconf.templates @@ -128,6 +128,14 @@ Description: Ethernet Interface Comment (IPv4)? . This defaults to empty. +Template: container/network1/ipv4-address-dns +Type: string +Default: +Description: IP Address from DNS (IPv4)? + Should the IP address automatically (based on the container name) derived from the DNS? + . + This defaults to empty. + Template: container/network1/ipv4-address Type: string Default: @@ -188,6 +196,14 @@ Description: Ethernet Interface Comment (IPv6)? . This defaults to empty. +Template: container/network1/ipv6-address-dns +Type: string +Default: +Description: IP Address from DNS (IPv6)? + Should the IP address automatically (based on the container name) derived from the DNS? + . + This defaults to empty. + Template: container/network1/ipv6-address Type: string Default: |