From 3675664a50757ef20a7a139dc63293e6fd52bfe9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 24 Jul 2017 11:56:44 +0200 Subject: Fixing issues from network0 -> network1 transition in debconf container create script. Signed-off-by: Daniel Baumann --- share/scripts/debconf | 39 +++++++++++++----------- share/scripts/debconf.d/0003-debconf | 58 ++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 47 deletions(-) (limited to 'share') diff --git a/share/scripts/debconf b/share/scripts/debconf index 6190c31..0b80353 100755 --- a/share/scripts/debconf +++ b/share/scripts/debconf @@ -762,7 +762,7 @@ Configure_network () fi # Create /etc/hosts - case "${NETWORK0_IPV4_METHOD}" in + case "${NETWORK1_IPV4_METHOD}" in none|dhcp) cat > "${DIRECTORY}/etc/hosts.tmp" << EOF @@ -782,7 +782,7 @@ EOF cat > "${DIRECTORY}/etc/hosts.tmp" << EOF 127.0.0.1 localhost -${NETWORK0_IPV4_ADDRESS} ${NAME} +${NETWORK1_IPV4_ADDRESS} ${NAME} # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback @@ -929,36 +929,39 @@ Commands () # maximum of 15 characters, prefix is 'veth-' HOSTNAME_SHORT="$(echo ${NAME} | cut -c-8)" - HOST_INTERFACE_NAME="$(echo ${NETWORK0_VETH:-veth-${HOSTNAME_SHORT}-0})" + HOST_INTERFACE_NAME="$(echo ${NETWORK1_VETH:-veth-${HOSTNAME_SHORT}-0})" sed -i -e "s|^cnt.auto=.*|cnt.auto=${CNT_AUTO}|g" \ -e "s|^cnt.container-server=.*|cnt.container-server=${CNT_CONTAINER_SERVER}|g" \ - -e "s|^cnt.network-bridge=.*|cnt.network-bridge=${HOST_INTERFACE_NAME}:${NETWORK0_BRIDGE:-bridge0}|g" \ + -e "s|^cnt.network-bridge=.*|cnt.network-bridge=${HOST_INTERFACE_NAME}:${NETWORK1_BRIDGE:-bridge0}|g" \ -e "s|^cnt.overlay=.*|cnt.overlay=${CNT_OVERLAY}|g" \ -e "s|^bind=.*|bind=${BIND}|g" \ -e "s|^bind-ro=.*|bind-ro=${BIND_RO}|g" \ -e "s|^network-veth-extra=.*|network-veth-extra=${HOST_INTERFACE_NAME}:eno1|g" \ "${CONFIG}/${NAME}.conf" - for NUMBER in $(seq 1 ${NETWORK_NUMBER}) - do - eval IPV4_METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`" + if [ "${NETWORK_NUMBER}" -ge 2 ] + then + for NUMBER in $(seq 2 ${NETWORK_NUMBER}) + do + eval IPV4_METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`" - if [ -z "${IPV4_METHOD}" ] - then - continue - fi + if [ -z "${IPV4_METHOD}" ] + then + continue + fi - eval HOST_INTERFACE_NAME="$`echo NETWORK${NUMBER}_VETH`" + eval HOST_INTERFACE_NAME="$`echo NETWORK${NUMBER}_VETH`" - HOST_INTERFACE_NAME="$(echo ${HOST_INTERFACE_NAME:-veth-${HOSTNAME_SHORT}-${NUMBER}})" - CONTAINER_INTERFACE_NAME="eno${NUMBER}" + HOST_INTERFACE_NAME="$(echo ${HOST_INTERFACE_NAME:-veth-${HOSTNAME_SHORT}-${NUMBER}})" + CONTAINER_INTERFACE_NAME="eno${NUMBER}" - sed -i -e "/^register=.*/ a network-veth-extra=${HOST_INTERFACE_NAME}:${CONTAINER_INTERFACE_NAME}" "${CONFIG}/${NAME}.conf" + sed -i -e "/^register=.*/ a network-veth-extra=${HOST_INTERFACE_NAME}:${CONTAINER_INTERFACE_NAME}" "${CONFIG}/${NAME}.conf" - eval BRIDGE="$`echo NETWORK${NUMBER}_BRIDGE`" - sed -i -e "/^register=.*/ a cnt.network-bridge=${HOST_INTERFACE_NAME}:${BRIDGE:-bridge${NUMBER}}" "${CONFIG}/${NAME}.conf" - done + eval BRIDGE="$`echo NETWORK${NUMBER}_BRIDGE`" + sed -i -e "/^register=.*/ a cnt.network-bridge=${HOST_INTERFACE_NAME}:${BRIDGE:-bridge${NUMBER}}" "${CONFIG}/${NAME}.conf" + done + fi # Setting root password echo root:${ROOT_PASSWORD} | chroot "${DIRECTORY}" chpasswd diff --git a/share/scripts/debconf.d/0003-debconf b/share/scripts/debconf.d/0003-debconf index 2592cf6..1773b09 100755 --- a/share/scripts/debconf.d/0003-debconf +++ b/share/scripts/debconf.d/0003-debconf @@ -696,13 +696,13 @@ Network_defaults () HOSTNAME_SHORT="$(echo veth-$(echo ${NAME} | cut -c-8)-0)" VETH_NAME="${HOSTNAME_SHORT}" - NETWORK0_VETH="${NETWORK0_VETH:-$VETH_NAME}" - NETWORK0_BRIDGE="${NETWORK0_BRIDGE:-bridge0}" - NETWORK0_IPV4_METHOD="${NETWORK0_IPV4_METHOD:-dhcp}" - NETWORK0_IPV4_ADDRESS="${NETWORK0_IPV4_ADDRESS:-192.168.1.2}" - NETWORK0_IPV4_NETMASK="${NETWORK0_IPV4_NETMASK:-255.255.255.0}" + 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}" - if [ "${NETWORK0_IPV4_METHOD}" = "static" ] && [ -e /etc/resolv.conf ] + if [ "${NETWORK1_IPV4_METHOD}" = "static" ] && [ -e /etc/resolv.conf ] 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 @@ -717,31 +717,31 @@ Network_defaults () Network () { db_get cnt-debconf/network1/bridge - NETWORK0_BRIDGE="${RET}" # string (w/o empty) + NETWORK1_BRIDGE="${RET}" # string (w/o empty) db_get cnt-debconf/network1/veth - NETWORK0_VETH="${RET}" # string (w/o empty) + NETWORK1_VETH="${RET}" # string (w/o empty) db_get cnt-debconf/network1/ipv4-method - NETWORK0_IPV4_METHOD="${RET}" # select + NETWORK1_IPV4_METHOD="${RET}" # select db_get cnt-debconf/network1/ipv4-comment - NETWORK0_IPV4_COMMENT="${RET}" # string (w/ empty) + NETWORK1_IPV4_COMMENT="${RET}" # string (w/ empty) db_get cnt-debconf/network1/ipv4-address - NETWORK0_IPV4_ADDRESS="${RET}" # string (w/o empty) + NETWORK1_IPV4_ADDRESS="${RET}" # string (w/o empty) db_get cnt-debconf/network1/ipv4-gateway - NETWORK0_IPV4_GATEWAY="${RET}" # string (w/ empty) + NETWORK1_IPV4_GATEWAY="${RET}" # string (w/ empty) db_get cnt-debconf/network1/ipv4-netmask - NETWORK0_IPV4_NETMASK="${RET}" # string (w/o empty) + NETWORK1_IPV4_NETMASK="${RET}" # string (w/o empty) db_get cnt-debconf/network1/ipv4-post-up - NETWORK0_IPV4_POST_UP="${RET}" # string (w/ empty) + NETWORK1_IPV4_POST_UP="${RET}" # string (w/ empty) db_get cnt-debconf/network1/ipv4-post-down - NETWORK0_IPV4_POST_DOWN="${RET}" # string (w/ empty) + NETWORK1_IPV4_POST_DOWN="${RET}" # string (w/ empty) db_get cnt-debconf/nameserver/server NAMESERVER_SERVER="${RET}" # string (w/ empty) @@ -757,31 +757,31 @@ Network () Network_defaults - db_set cnt-debconf/network1/bridge "${NETWORK0_BRIDGE}" + db_set cnt-debconf/network1/bridge "${NETWORK1_BRIDGE}" db_fset cnt-debconf/network1/bridge seen false - db_set cnt-debconf/network1/veth "${NETWORK0_VETH}" + db_set cnt-debconf/network1/veth "${NETWORK1_VETH}" db_fset cnt-debconf/network1/veth seen false - db_set cnt-debconf/network1/ipv4-method "${NETWORK0_IPV4_METHOD}" + db_set cnt-debconf/network1/ipv4-method "${NETWORK1_IPV4_METHOD}" db_fset cnt-debconf/network1/ipv4-method seen false - db_set cnt-debconf/network1/ipv4-comment "${NETWORK0_IPV4_COMMENT}" + db_set cnt-debconf/network1/ipv4-comment "${NETWORK1_IPV4_COMMENT}" db_fset cnt-debconf/network1/ipv4-comment seen false - db_set cnt-debconf/network1/ipv4-address "${NETWORK0_IPV4_ADDRESS}" + db_set cnt-debconf/network1/ipv4-address "${NETWORK1_IPV4_ADDRESS}" db_fset cnt-debconf/network1/ipv4-address seen false - db_set cnt-debconf/network1/ipv4-gateway "${NETWORK0_IPV4_GATEWAY}" + db_set cnt-debconf/network1/ipv4-gateway "${NETWORK1_IPV4_GATEWAY}" db_fset cnt-debconf/network1/ipv4-gateway seen false - db_set cnt-debconf/network1/ipv4-netmask "${NETWORK0_IPV4_NETMASK}" + db_set cnt-debconf/network1/ipv4-netmask "${NETWORK1_IPV4_NETMASK}" db_fset cnt-debconf/network1/ipv4-netmask seen false - db_set cnt-debconf/network1/ipv4-post-up "${NETWORK0_IPV4_POST_UP}" + db_set cnt-debconf/network1/ipv4-post-up "${NETWORK1_IPV4_POST_UP}" db_fset cnt-debconf/network1/ipv4-post-up seen false - db_set cnt-debconf/network1/ipv4-post-down "${NETWORK0_IPV4_POST_DOWN}" + db_set cnt-debconf/network1/ipv4-post-down "${NETWORK1_IPV4_POST_DOWN}" db_fset cnt-debconf/network1/ipv4-post-down seen false db_set cnt-debconf/nameserver/server "${NAMESERVER_SERVER}" @@ -801,15 +801,15 @@ Network () db_go db_get cnt-debconf/network1/bridge - NETWORK0_BRIDGE="${RET}" # select + NETWORK1_BRIDGE="${RET}" # select db_get cnt-debconf/network1/veth - NETWORK0_VETH="${RET}" # select + NETWORK1_VETH="${RET}" # select db_get cnt-debconf/network1/ipv4-method - NETWORK0_IPV4_METHOD="${RET}" # select + NETWORK1_IPV4_METHOD="${RET}" # select - case "${NETWORK0_IPV4_METHOD}" in + case "${NETWORK1_IPV4_METHOD}" in none|dhcp) ;; @@ -896,7 +896,7 @@ Network () NUMBER="$((${NUMBER} + 1))" done - NETWORK_NUMBER="${NUMBER}" + NETWORK_NUMBER="$((${NUMBER} - 1))" db_get cnt-debconf/nameserver/server NAMESERVER_SERVER="${RET}" # string (w/ empty) -- cgit v1.2.3