summaryrefslogtreecommitdiffstats
path: root/share/scripts/debconf.d/0003-debconf
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2019-03-19 13:12:05 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2019-03-19 19:51:21 +0000
commit84cc416d5db2ed05bdb22471690ec9e443b41e3c (patch)
tree8ba97b10e4df3aa19facb1351ee6171a06460e85 /share/scripts/debconf.d/0003-debconf
parentUsing C.UTF-8 in container enter command as fallback locale. (diff)
downloadcompute-tools-84cc416d5db2ed05bdb22471690ec9e443b41e3c.tar.xz
compute-tools-84cc416d5db2ed05bdb22471690ec9e443b41e3c.zip
Adding initial support for IPv6 in debconf container create script.
Note that this also removes support for non-CIDR IPv4 subnetmasks, e.g. '255.255.255.0' now has to be specified as '24'. Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'share/scripts/debconf.d/0003-debconf')
-rwxr-xr-xshare/scripts/debconf.d/0003-debconf187
1 files changed, 170 insertions, 17 deletions
diff --git a/share/scripts/debconf.d/0003-debconf b/share/scripts/debconf.d/0003-debconf
index 684261a..02f80a6 100755
--- a/share/scripts/debconf.d/0003-debconf
+++ b/share/scripts/debconf.d/0003-debconf
@@ -674,19 +674,27 @@ Network_defaults ()
NETWORK1_VETH="${NETWORK1_VETH:-$VETH_NAME}"
NETWORK1_BRIDGE="${NETWORK1_BRIDGE:-bridge0}"
+
NETWORK1_IPV4_METHOD="${NETWORK1_IPV4_METHOD:-dhcp}"
NETWORK1_IPV4_ADDRESS="${NETWORK1_IPV4_ADDRESS:-192.168.1.2}"
- NETWORK1_IPV4_NETMASK="${NETWORK1_IPV4_NETMASK:-255.255.255.0}"
+ NETWORK1_IPV4_NETMASK="${NETWORK1_IPV4_NETMASK:-24}"
+
+ NETWORK1_IPV6_METHOD="${NETWORK1_IPV6_METHOD:-none}"
+ NETWORK1_IPV6_ADDRESS="${NETWORK1_IPV6_ADDRESS:-fc00::2}"
+ NETWORK1_IPV6_NETMASK="${NETWORK1_IPV6_NETMASK:-7}"
- if [ "${NETWORK1_IPV4_METHOD}" = "static" ] && [ -e /etc/resolv.conf ]
+ if [ "${NETWORK1_IPV4_METHOD}" = "static" ] || [ "${NETWORK1_IPV6_METHOD}" = "static" ]
then
- NAMESERVER_SERVER="${NAMESERVER_SERVER:-$(if [ -e /etc/resolv.conf ]; then awk '/^nameserver / {$1=""; print $0}' /etc/resolv.conf; fi)}"
- # Workaround to get rid of newlines since debconf can not handle multiline return value in assignments
- NAMESERVER_SERVER="$(echo ${NAMESERVER_SERVER})"
+ if [ -e /etc/resolv.conf ]
+ then
+ NAMESERVER_SERVER="${NAMESERVER_SERVER:-$(awk '/^nameserver / {$1=""; print $0}' /etc/resolv.conf)}"
+ # Workaround to get rid of newlines since debconf can not handle multiline return value in assignments
+ NAMESERVER_SERVER="$(echo ${NAMESERVER_SERVER})"
- NAMESERVER_DOMAIN="${NAMESERVER_DOMAIN:-$(if [ -e /etc/resolv.conf ]; then awk '/^domain / {$1=""; print $0}' /etc/resolv.conf; fi)}"
- NAMESERVER_SEARCH="${NAMESERVER_SEARCH:-$(if [ -e /etc/resolv.conf ]; then awk '/^search / {$1=""; print $0}' /etc/resolv.conf; fi)}"
- NAMESERVER_OPTIONS="${NAMESERVER_OPTIONS:-$(if [ -e /etc/resolv.conf ]; then awk '/^options / {$1=""; print $0}' /etc/resolv.conf; fi)}"
+ NAMESERVER_DOMAIN="${NAMESERVER_DOMAIN:-$(awk '/^domain / {$1=""; print $0}' /etc/resolv.conf)}"
+ NAMESERVER_SEARCH="${NAMESERVER_SEARCH:-$(awk '/^search / {$1=""; print $0}' /etc/resolv.conf)}"
+ NAMESERVER_OPTIONS="${NAMESERVER_OPTIONS:-$(awk '/^options / {$1=""; print $0}' /etc/resolv.conf)}"
+ fi
fi
}
@@ -719,6 +727,27 @@ Network ()
db_get container/network1/ipv4-post-down
NETWORK1_IPV4_POST_DOWN="${RET}" # string (w/ empty)
+ db_get container/network1/ipv6-method
+ NETWORK1_IPV6_METHOD="${RET}" # select
+
+ db_get container/network1/ipv6-comment
+ NETWORK1_IPV6_COMMENT="${RET}" # string (w/ empty)
+
+ db_get container/network1/ipv6-address
+ NETWORK1_IPV6_ADDRESS="${RET}" # string (w/o empty)
+
+ db_get container/network1/ipv6-gateway
+ NETWORK1_IPV6_GATEWAY="${RET}" # string (w/ empty)
+
+ db_get container/network1/ipv6-netmask
+ NETWORK1_IPV6_NETMASK="${RET}" # string (w/o empty)
+
+ db_get container/network1/ipv6-post-up
+ NETWORK1_IPV6_POST_UP="${RET}" # string (w/ empty)
+
+ db_get container/network1/ipv6-post-down
+ NETWORK1_IPV6_POST_DOWN="${RET}" # string (w/ empty)
+
db_get container/nameserver/server
NAMESERVER_SERVER="${RET}" # string (w/ empty)
@@ -760,6 +789,27 @@ Network ()
db_set container/network1/ipv4-post-down "${NETWORK1_IPV4_POST_DOWN}"
db_fset container/network1/ipv4-post-down seen false
+ db_set container/network1/ipv6-method "${NETWORK1_IPV6_METHOD}"
+ db_fset container/network1/ipv6-method seen false
+
+ db_set container/network1/ipv6-comment "${NETWORK1_IPV6_COMMENT}"
+ db_fset container/network1/ipv6-comment seen false
+
+ db_set container/network1/ipv6-address "${NETWORK1_IPV6_ADDRESS}"
+ db_fset container/network1/ipv6-address seen false
+
+ db_set container/network1/ipv6-gateway "${NETWORK1_IPV6_GATEWAY}"
+ db_fset container/network1/ipv6-gateway seen false
+
+ db_set container/network1/ipv6-netmask "${NETWORK1_IPV6_NETMASK}"
+ db_fset container/network1/ipv6-netmask seen false
+
+ db_set container/network1/ipv6-post-up "${NETWORK1_IPV6_POST_UP}"
+ db_fset container/network1/ipv6-post-up seen false
+
+ db_set container/network1/ipv6-post-down "${NETWORK1_IPV6_POST_DOWN}"
+ db_fset container/network1/ipv6-post-down seen false
+
db_set container/nameserver/server "${NAMESERVER_SERVER}"
db_fset container/nameserver/server seen false
@@ -772,16 +822,16 @@ Network ()
db_set container/nameserver/options "${NAMESERVER_OPTIONS}"
db_fset container/nameserver/options seen false
- db_settitle container/title
- db_input high container/network1/ipv4-method || true
- db_go
-
db_get container/network1/bridge
NETWORK1_BRIDGE="${RET}" # select
db_get container/network1/veth
NETWORK1_VETH="${RET}" # select
+ db_settitle container/title
+ db_input high container/network1/ipv4-method || true
+ db_go
+
db_get container/network1/ipv4-method
NETWORK1_IPV4_METHOD="${RET}" # select
@@ -813,16 +863,57 @@ Network ()
db_settitle container/title
db_input high container/network1/ipv4-post-down || true
db_go
+ ;;
+ esac
+
+ db_settitle container/title
+ db_input high container/network1/ipv6-method || true
+ db_go
+
+ db_get container/network1/ipv6-method
+ NETWORK1_IPV6_METHOD="${RET}" # select
+
+ case "${NETWORK1_IPV6_METHOD}" in
+ none|dhcp)
+ ;;
+
+ static)
+ db_settitle container/title
+ db_input high container/network1/ipv6-comment || true
+ db_go
+
+ db_settitle container/title
+ db_input high container/network1/ipv6-address || true
+ db_go
+
+ db_settitle container/title
+ db_input high container/network1/ipv6-gateway || true
+ db_go
+
+ db_settitle container/title
+ db_input high container/network1/ipv6-netmask || true
+ db_go
db_settitle container/title
- db_input high container/nameserver/server || true
+ db_input high container/network1/ipv6-post-up || true
+ db_go
+
+ db_settitle container/title
+ db_input high container/network1/ipv6-post-down || true
db_go
;;
esac
+ if [ "${NETWORK1_IPV4_METHOD}" = "static" ] || [ "${NETWORK1_IPV6_METHOD}" = "static" ]
+ then
+ db_settitle container/title
+ db_input high container/nameserver/server || true
+ db_go
+ fi
+
NUMBER="1"
- while db_get container/network${NUMBER}/ipv4-method && [ "${RET}" ]
+ while ( db_get container/network${NUMBER}/ipv4-method && [ "${RET}" ] ) || ( db_get container/network${NUMBER}/ipv6-method && [ "${RET}" ] )
do
if db_get container/network${NUMBER}/bridge
then
@@ -834,6 +925,13 @@ Network ()
eval NETWORK${NUMBER}_VETH="\"${RET}\"" # string (w/o empty)
fi
+ NUMBER="$((${NUMBER} + 1))"
+ done
+
+ NETWORK_NUMBER="$((${NUMBER} - 1))"
+
+ for NUMBER in $(seq 1 ${NETWORK_NUMBER})
+ do
if db_get container/network${NUMBER}/ipv4-comment
then
eval NETWORK${NUMBER}_IPV4_COMMENT="\"${RET}\"" # string (w/ empty)
@@ -868,11 +966,45 @@ Network ()
then
eval NETWORK${NUMBER}_IPV4_POST_DOWN="\"${RET}\"" # string (w/ empty)
fi
-
- NUMBER="$((${NUMBER} + 1))"
done
- NETWORK_NUMBER="$((${NUMBER} - 1))"
+ for NUMBER in $(seq 1 ${NETWORK_NUMBER})
+ do
+ if db_get container/network${NUMBER}/ipv6-comment
+ then
+ eval NETWORK${NUMBER}_IPV6_COMMENT="\"${RET}\"" # string (w/ empty)
+ fi
+
+ if db_get container/network${NUMBER}/ipv6-method
+ then
+ eval NETWORK${NUMBER}_IPV6_METHOD="\"${RET}\"" # select
+ fi
+
+ if db_get container/network${NUMBER}/ipv6-address
+ then
+ eval NETWORK${NUMBER}_IPV6_ADDRESS="\"${RET}\"" # string (w/o empty)
+ fi
+
+ if db_get container/network${NUMBER}/ipv6-gateway
+ then
+ eval NETWORK${NUMBER}_IPV6_GATEWAY="\"${RET}\"" # string (w/ empty)
+ fi
+
+ if db_get container/network${NUMBER}/ipv6-netmask
+ then
+ eval NETWORK${NUMBER}_IPV6_NETMASK="\"${RET}\"" # string (w/o empty)
+ fi
+
+ if db_get container/network${NUMBER}/ipv6-post-up
+ then
+ eval NETWORK${NUMBER}_IPV6_POST_UP="\"${RET}\"" # string (w/ empty)
+ fi
+
+ if db_get container/network${NUMBER}/ipv6-post-down
+ then
+ eval NETWORK${NUMBER}_IPV6_POST_DOWN="\"${RET}\"" # string (w/ empty)
+ fi
+ done
db_get container/nameserver/server
NAMESERVER_SERVER="${RET}" # string (w/ empty)
@@ -918,6 +1050,27 @@ Network ()
eval POST_DOWN="$`echo NETWORK${NUMBER}_IPV4_POST_DOWN`"
echo "NETWORK${NUMBER}_IPV4_POST_DOWN=\"${POST_DOWN}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+
+ eval COMMENT="$`echo NETWORK${NUMBER}_IPV6_COMMENT`"
+ echo "NETWORK${NUMBER}_IPV6_COMMENT=\"${COMMENT}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+
+ eval METHOD="$`echo NETWORK${NUMBER}_IPV6_METHOD`"
+ echo "NETWORK${NUMBER}_IPV6_METHOD=\"${METHOD}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+
+ eval ADDRESS="$`echo NETWORK${NUMBER}_IPV6_ADDRESS`"
+ echo "NETWORK${NUMBER}_IPV6_ADDRESS=\"${ADDRESS}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+
+ eval GATEWAY="$`echo NETWORK${NUMBER}_IPV6_GATEWAY`"
+ echo "NETWORK${NUMBER}_IPV6_GATEWAY=\"${GATEWAY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+
+ eval NETMASK="$`echo NETWORK${NUMBER}_IPV6_NETMASK`"
+ echo "NETWORK${NUMBER}_IPV6_NETMASK=\"${NETMASK}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+
+ eval POST_UP="$`echo NETWORK${NUMBER}_IPV6_POST_UP`"
+ echo "NETWORK${NUMBER}_IPV6_POST_UP=\"${POST_UP}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+
+ eval POST_DOWN="$`echo NETWORK${NUMBER}_IPV6_POST_DOWN`"
+ echo "NETWORK${NUMBER}_IPV6_POST_DOWN=\"${POST_DOWN}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
done
echo "NAMESERVER_SERVER=\"${NAMESERVER_SERVER}\"" >> "${DEBCONF_TMPDIR}/debconf.default"