summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-10-27 11:43:55 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-11-01 03:35:15 +0000
commita02687bc62af697cce2d505921608ae3160a2540 (patch)
tree389fd30df4ab6d6b79b4d75866f64c2c0de88753
parentSupporting using IP address from DNS lookup of the container name in preseed ... (diff)
downloadcompute-tools-a02687bc62af697cce2d505921608ae3160a2540.tar.xz
compute-tools-a02687bc62af697cce2d505921608ae3160a2540.zip
Supporting using IP address parts of the container name in preseed files for container debconf create script.
This is usefull to automatically construct IP gateway addresses or veth interface names in a diff-friendly way. Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rwxr-xr-xshare/scripts/debconf8
-rwxr-xr-xshare/scripts/debconf.d/0002-preseed-debconf8
2 files changed, 16 insertions, 0 deletions
diff --git a/share/scripts/debconf b/share/scripts/debconf
index 2edd543..619d84c 100755
--- a/share/scripts/debconf
+++ b/share/scripts/debconf
@@ -629,10 +629,18 @@ EOF
if [ -n "${DIG}" ]
then
IPV4_ADDRESS="$(${DIG} +short ${NAME} | tail -n1)"
+ IPV4_ADDRESS_PART1="$(echo ${IPV4_ADDRESS} | cut -d. -f1)"
+ IPV4_ADDRESS_PART2="$(echo ${IPV4_ADDRESS} | cut -d. -f2)"
+ IPV4_ADDRESS_PART3="$(echo ${IPV4_ADDRESS} | cut -d. -f3)"
+ IPV4_ADDRESS_PART4="$(echo ${IPV4_ADDRESS} | cut -d. -f4)"
fi
sed -e "s|@NAME@|${NAME}|g" \
-e "s|@IPV4_ADDRESS@|${IPV4_ADDRESS}|g" \
+ -e "s|@IPV4_ADDRESS_PART1@|${IPV4_ADDRESS_PART1}|g" \
+ -e "s|@IPV4_ADDRESS_PART2@|${IPV4_ADDRESS_PART2}|g" \
+ -e "s|@IPV4_ADDRESS_PART3@|${IPV4_ADDRESS_PART3}|g" \
+ -e "s|@IPV4_ADDRESS_PART4@|${IPV4_ADDRESS_PART4}|g" \
"${FILE}" >> "${DIRECTORY}/preseed.cfg"
done
diff --git a/share/scripts/debconf.d/0002-preseed-debconf b/share/scripts/debconf.d/0002-preseed-debconf
index 36cf948..93841b6 100755
--- a/share/scripts/debconf.d/0002-preseed-debconf
+++ b/share/scripts/debconf.d/0002-preseed-debconf
@@ -83,10 +83,18 @@ do
if [ -n "${DIG}" ]
then
IPV4_ADDRESS="$(${DIG} +short ${NAME} | tail -n1)"
+ IPV4_ADDRESS_PART1="$(echo ${IPV4_ADDRESS} | cut -d. -f1)"
+ IPV4_ADDRESS_PART2="$(echo ${IPV4_ADDRESS} | cut -d. -f2)"
+ IPV4_ADDRESS_PART3="$(echo ${IPV4_ADDRESS} | cut -d. -f3)"
+ IPV4_ADDRESS_PART4="$(echo ${IPV4_ADDRESS} | cut -d. -f4)"
fi
sed -e "s|@NAME@|${NAME}|g" \
-e "s|@IPV4_ADDRESS@|${IPV4_ADDRESS}|g" \
+ -e "s|@IPV4_ADDRESS_PART1@|${IPV4_ADDRESS_PART1}|g" \
+ -e "s|@IPV4_ADDRESS_PART2@|${IPV4_ADDRESS_PART2}|g" \
+ -e "s|@IPV4_ADDRESS_PART3@|${IPV4_ADDRESS_PART3}|g" \
+ -e "s|@IPV4_ADDRESS_PART4@|${IPV4_ADDRESS_PART4}|g" \
"${DEBCONF_PRESEED_FILE}" > "${DIRECTORY}/preseed.cfg"
# Apply user specified preseed files