summaryrefslogtreecommitdiffstats
path: root/share/scripts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2017-07-23 08:28:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2017-07-23 08:29:10 +0000
commit098f18a504d97fec24bbe619370cdd2ca0d5b500 (patch)
treeae6f100cedf2537ad070f3fdb9977fa6ada16bcc /share/scripts
parentReleasing debian version 20170701-1. (diff)
downloadopen-infrastructure-compute-tools-098f18a504d97fec24bbe619370cdd2ca0d5b500.tar.xz
open-infrastructure-compute-tools-098f18a504d97fec24bbe619370cdd2ca0d5b500.zip
Merging upstream version 20170722.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/scripts')
-rwxr-xr-xshare/scripts/curl328
-rwxr-xr-xshare/scripts/curl.d/0001-debconf53
-rw-r--r--share/scripts/curl.d/0001-debconf.templates11
-rwxr-xr-xshare/scripts/debconf58
-rwxr-xr-xshare/scripts/debconf.d/0003-debconf106
-rw-r--r--share/scripts/debconf.d/0003-debconf.templates30
6 files changed, 450 insertions, 136 deletions
diff --git a/share/scripts/curl b/share/scripts/curl
index a338020..709e59c 100755
--- a/share/scripts/curl
+++ b/share/scripts/curl
@@ -21,13 +21,14 @@ set -e
SCRIPT="${0}"
HOOKS="/etc/container-tools/hooks"
+KEYS="/etc/container-tools/keys"
MACHINES="/var/lib/machines"
-CACHE="/var/cache/container-tools/images"
+CACHE="/var/cache/container-tools/system"
Parameters ()
{
- GETOPT_LONGOPTIONS="bind:,bind-ro:,script:,name:,clean,image:,server:,password:"
- GETOPT_OPTIONS="b:,s:,n:,p:"
+ GETOPT_LONGOPTIONS="bind:,bind-ro:,script:,name:,architecture:,clean,password:,server:,setup:,system:,"
+ GETOPT_OPTIONS="b:,s:,n:,a:,p:"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${SCRIPT} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -72,13 +73,18 @@ Parameters ()
shift 2
;;
+ -a|--architecture)
+ ARCHITECTURE="${2}"
+ shift 2
+ ;;
+
--clean)
CLEAN="true"
shift 1
;;
- --image)
- IMAGE="${2}"
+ -p|--password)
+ PASSWORD="${2}"
shift 2
;;
@@ -87,8 +93,13 @@ Parameters ()
shift 2
;;
- -p|--password)
- PASSWORD="${2}"
+ --setup)
+ SETUP="${2}"
+ shift 2
+ ;;
+
+ --system)
+ SYSTEM="${2}"
shift 2
;;
@@ -107,7 +118,7 @@ Parameters ()
Usage ()
{
- echo "Usage: container create -n|--name NAME -s|--script ${SCRIPT} -- [--clean] [--image IMAGE] [--server SERVER] [-p|--password PASSWORD}" >&2
+ echo "Usage: container create -n|--name NAME -s|--script ${SCRIPT} -- [--clean] [-p|--password PASSWORD] [--server SERVER] [--setup SETUP] [--system SYSTEM]" >&2
exit 1
}
@@ -136,13 +147,73 @@ then
exit 1
fi
-ARCHITECTURE="${ARCHITECTURE:-$(dpkg --print-architecture)}"
-IMAGE="${IMAGE:-debian-stretch-${ARCHITECTURE}.tar.xz}"
-SERVER="${SERVER:-https://files.open-infrastructure.net/images/container-tools/current}"
+COMPRESSIONS=""
+
+if [ -x /usr/bin/lzip ]
+then
+ COMPRESSIONS="${COMPRESSIONS} lz"
+fi
+
+if [ -x /usr/bin/xz ]
+then
+ COMPRESSIONS="${COMPRESSIONS} xz"
+fi
+
+if [ -x /bin/gzip ]
+then
+ COMPRESSIONS="${COMPRESSIONS} gz"
+fi
+
+if [ -z "${COMPRESSIONS}" ]
+then
+ echo "'${NAME}': no supported compressor available (lz, xz, gz)."
+ exit 1
+fi
+
+SERVER="${SERVER:-https://files.open-infrastructure.net/system/container/debian}"
PASSWORD="${PASSWORD:-$(dd if=/dev/urandom bs=12 count=1 2> /dev/null | base64)}"
VERSION="$(container version)"
+export SERVER
+
+Debconf ()
+{
+ # Configure local debconf
+ mkdir -p "${DEBCONF_TMPDIR}/debconf"
+
+cat > "${DEBCONF_TMPDIR}/debconf.systemrc" << EOF
+Config: configdb
+Templates: templatedb
+
+Name: config
+Driver: File
+Mode: 644
+Reject-Type: password
+Filename: ${DEBCONF_TMPDIR}/debconf/config.dat
+
+Name: passwords
+Driver: File
+Mode: 600
+Backup: false
+Required: false
+Accept-Type: password
+Filename: ${DEBCONF_TMPDIR}/debconf/passwords.dat
+
+Name: configdb
+Driver: Stack
+Stack: config, passwords
+
+Name: templatedb
+Driver: File
+Mode: 644
+Filename: ${DEBCONF_TMPDIR}/debconf/templates.dat
+EOF
+
+ DEBCONF_SYSTEMRC="${DEBCONF_TMPDIR}/debconf.systemrc"
+ export DEBCONF_SYSTEMRC
+}
+
# Pre hooks
for FILE in "${HOOKS}/pre-${SCRIPT}".* "${HOOKS}/${NAME}.pre-${SCRIPT}"
do
@@ -154,65 +225,189 @@ done
# Run
-# FIXME: Show available image directories on server
-# FIXME: Fetch debconf-choices.txt to show debconf select
-# FIXME: gpg verification against debian-keyring or local keyring
# FIXME: default server via configuration file
-echo "Downloading ${IMAGE}"
-mkdir -p "${CACHE}"
+CURL_OPTIONS=""
-if [ -e "${CACHE}/${IMAGE}" ]
+if curl -V | grep -qs http2
then
- CURL_OPTIONS="--time-cond ${CACHE}/${IMAGE}"
+ CURL_OPTIONS="${CURL_OPTIONS} --http2"
fi
-if curl -V | grep -qs http2
+if [ -z "${SYSTEM}" ]
then
- CURL_OPTIONS="${CURL_OPTIONS} --http2"
+ # Downloading container list
+ if curl --fail --head --output /dev/null --silent "${SERVER}/container-list.txt"
+ then
+ mkdir -p /tmp/container-tools
+ DEBCONF_TMPDIR="$(mktemp -d -p /tmp/container-tools -t $(basename ${0}).XXXX)"
+ export DEBCONF_TMPDIR
+
+ if [ -z "${ARCHITECTURE}" ]
+ then
+ case "$(dpkg --print-architecture)" in
+ amd64)
+ GREP_PATTERN="(amd64|i386)"
+ ;;
+ esac
+ fi
+
+ GREP_PATTERN="${GREP_PATTERN:-${ARCHITECTURE}}"
+
+ echo "Downloading $(echo ${SERVER} | awk -F/ '{ print $3 }') container list"
+ curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \
+ "${SERVER}/container-list.txt" | grep -E "${GREP_PATTERN}" > "${DEBCONF_TMPDIR}/container-list.txt"
+
+ umask 0022
+
+ Debconf
+
+ # Run debconf parts
+ for DEBCONF_SCRIPT in /usr/share/container-tools/scripts/curl.d/*
+ do
+ if [ -x "${DEBCONF_SCRIPT}" ]
+ then
+ # FIXME
+ # debconf -ocontainer-tools "${DEBCONF_SCRIPT}"
+ "${DEBCONF_SCRIPT}"
+ fi
+ done
+
+ # Read-in configuration from debconf
+ . "${DEBCONF_TMPDIR}/debconf.default"
+
+ # Remove debconf temporary files
+ rm --preserve-root --one-file-system -rf "${DEBCONF_TMPDIR}"
+ rmdir --ignore-fail-on-non-empty /tmp/container-tools 2>&1 || true
+ fi
fi
-curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \
- "${SERVER}/${IMAGE}" -o "${CACHE}/${IMAGE}"
+for COMPRESSION in ${COMPRESSIONS}
+do
+ if curl --fail --head --output /dev/null --silent "${SERVER}/${SYSTEM}.${COMPRESSION}"
+ then
+ SYSTEM="${SYSTEM}.${COMPRESSION}"
+ break
+ fi
+done
+
+# Downloading container files
+mkdir -p "${CACHE}"
+
+SETUP="${SETUP:-$(echo ${SYSTEM} | sed -e 's|.system.tar.|.setup.tar.|')}"
-curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} \
- "${SERVER}/${IMAGE}.sha512" -o "${CACHE}/${IMAGE}.sha512"
+for FILE in "${SYSTEM}" "${SYSTEM}.gpg" "${SYSTEM}.sha512" \
+ "${SETUP}" "${SETUP}.gpg" "${SETUP}.sha512"
+do
+ if curl --fail --head --output /dev/null --silent "${SERVER}/${FILE}"
+ then
+ case "${FILE}" in
+ *.sha512)
+ if [ -e "${CACHE}/$(basename ${FILE} .sha512).gpg" ]
+ then
+ continue
+ fi
+ ;;
+ esac
+
+ if [ -e "${CACHE}/${FILE}" ]
+ then
+ CURL_TIME_COND="--time-cond ${CACHE}/${FILE}"
+ else
+ CURL_TIME_COND=""
+ fi
+
+ echo "Downloading ${FILE}"
+ curl --fail --location --progress-bar --user-agent container-tools/${VERSION} ${CURL_OPTIONS} ${CURL_TIME_COND} \
+ "${SERVER}/${FILE}" -o "${CACHE}/${FILE}"
+ fi
+done
-echo -n "Verifying ${IMAGE}.sha512"
cd "${CACHE}"
-set +e
-sha512sum --check "${IMAGE}.sha512" --status
-SHA512SUM="${?}"
+for FILE in "${SYSTEM}" "${SETUP}"
+do
+ if [ ! -e "${FILE}" ]
+ then
+ continue
+ fi
-case "${SHA512SUM}" in
- 0)
- echo " ok."
- ;;
+ if [ -e "${FILE}.gpg" ]
+ then
+ echo -n "Verifying ${FILE}:"
- *)
- echo " failed."
- exit 1
- ;;
-esac
+ set +e
+ gpg --homedir "${KEYS}" --verify "${FILE}.gpg" "${FILE}" > /dev/null 2>&1
+ GNUPG="${?}"
+ set -e
-set -e
-cd "${OLDPWD}"
+ case "${GNUPG}" in
+ 0)
+ echo " gpg ok."
+ continue
+ ;;
+
+ *)
+ echo " gpg failed."
+ exit 1
+ ;;
+ esac
+ elif [ -e "${FILE}.sha512" ]
+ then
+ echo -n "Verifying ${FILE}:"
-echo "Unpacking ${IMAGE}"
-mkdir -p "${MACHINES}/${NAME}"
+ set +e
+ sha512sum --check "${FILE}.sha512" --status
+ SHA512SUM="${?}"
+ set -e
-case "${IMAGE}" in
+ case "${SHA512SUM}" in
+ 0)
+ echo " sha512 ok."
+ ;;
+
+ *)
+ echo " sha512 failed."
+ exit 1
+ ;;
+ esac
+ fi
+done
+
+cd "${OLDPWD}"
+
+case "${SYSTEM}" in
*.gz)
TAR_OPTIONS="--gzip"
+
+ if [ ! -e /bin/gzip ]
+ then
+ echo -en "\n"
+ echo "'${NAME}': /bin/lzip - no such file." >&2
+ exit 1
+ fi
;;
*.lz)
TAR_OPTIONS="--lzip"
+
+ if [ ! -e /usr/bin/lzip ]
+ then
+ echo -en "\n"
+ echo "'${NAME}': /usr/bin/lzip - no such file." >&2
+ exit 1
+ fi
;;
*.xz)
TAR_OPTIONS="--xz"
+
+ if [ ! -e /usr/bin/xz ]
+ then
+ echo -en "\n"
+ echo "'${NAME}': /usr/bin/xz - no such file." >&2
+ exit 1
+ fi
;;
*)
@@ -220,11 +415,46 @@ case "${IMAGE}" in
;;
esac
-if [ -e /usr/bin/pv ]
+for FILE in "${SYSTEM}" "${SETUP}"
+do
+ if [ ! -e "${CACHE}/${FILE}" ]
+ then
+ continue
+ fi
+
+ case "${FILE}" in
+ *.system.tar.*)
+ DIRECTORY="${MACHINES}/${NAME}"
+ ;;
+
+ *.setup.tar.*)
+ DIRECTORY="${MACHINES}/${NAME}/setup"
+ ;;
+ esac
+
+ mkdir -p "${DIRECTORY}"
+
+ if [ -e /usr/bin/pv ]
+ then
+ echo "Unpacking ${FILE}"
+ pv --format '%p' --width 77 "${CACHE}/${FILE}" | tar xf - ${TAR_OPTIONS} -C "${DIRECTORY}" --strip 1
+ else
+ echo -n "Unpacking ${FILE}:"
+ tar xf "${CACHE}/${FILE}" ${TAR_OPTIONS} -C "${DIRECTORY}" --strip 1
+ echo " ok."
+ fi
+done
+
+if [ -x "${MACHINES}/${NAME}/setup/container" ]
then
- pv --format '%p' --width 77 "${CACHE}/${IMAGE}" | tar xf - ${TAR_OPTIONS} -C "${MACHINES}/${NAME}" --strip 1
-else
- tar xf "${CACHE}/${IMAGE}" ${TAR_OPTIONS} -C "${MACHINES}/${NAME}" --strip 1
+ chroot "${MACHINES}/${NAME}" /usr/bin/env -i \
+ LC_ALL="C" PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games" TERM="${TERM}" \
+ DEBIAN_FRONTEND="dialog" DEBIAN_PRIORITY="low" \
+ DEBCONF_NONINTERACTIVE_SEEN="true" DEBCONF_NOWARNINGS="true" \
+ NAME="${NAME}" \
+ /setup/container
+
+ rm -rf "${MACHINES}/${NAME}/setup"
fi
# Creating machine-id
@@ -240,11 +470,11 @@ cp -L /etc/resolv.conf "${MACHINES}/${NAME}/etc/resolv.conf"
echo root:${PASSWORD} | chroot "${MACHINES}/${NAME}" chpasswd
echo "${NAME}: root password set to '${PASSWORD}'."
-# Reove cache
+# Remove cache
case "${CLEAN}" in
true)
- rm -f "${CACHE}/${IMAGE}"
- rm -f "${CACHE}/${IMAGE}.sha512"
+ rm -f "${CACHE}/${SYSTEM}" "${CACHE}/${SYSTEM}.sha512"
+ rm -f "${CACHE}/${SETUP}" "${CACHE}/${SETUP}.sha512"
;;
esac
diff --git a/share/scripts/curl.d/0001-debconf b/share/scripts/curl.d/0001-debconf
new file mode 100755
index 0000000..184a5ed
--- /dev/null
+++ b/share/scripts/curl.d/0001-debconf
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# container-tools - Manage systemd-nspawn containers
+# Copyright (C) 2014-2017 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+DEBCONF_NOWARNINGS="true"
+export DEBCONF_NOWARNINGS
+
+. /usr/share/debconf/confmodule
+
+System ()
+{
+ TITLE="$(echo ${SERVER} | awk -F/ '{ print $3 }')"
+
+ SYSTEMS="$(for SYSTEM in $(cat ${DEBCONF_TMPDIR}/container-list.txt | cut -d\| -f2 | sed -e 's| |#|g'); do echo -n "$(echo ${SYSTEM} | sed -e 's|#| |g'), "; done | sed -e 's|, $||')"
+ SYSTEMS_C="$(for SYSTEM_C in $(cat ${DEBCONF_TMPDIR}/container-list.txt | cut -d\| -f1); do echo -n "${SYSTEM_C}, "; done | sed -e 's|, $||')"
+
+ db_subst cnt-curl/title TITLE "${TITLE}"
+
+ db_subst cnt-curl/system CHOICES "${SYSTEMS}"
+ db_subst cnt-curl/system CHOICES_C "${SYSTEMS_C}"
+
+ db_fset cnt-curl/system seen false
+
+ db_settitle cnt-curl/title
+ db_input high cnt-curl/system || true
+ db_go
+
+ db_get cnt-curl/system
+ SYSTEM="${RET}" # select
+
+ echo "SYSTEM=\"${SYSTEM}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+ export SYSTEM
+}
+
+System
+
+db_stop
diff --git a/share/scripts/curl.d/0001-debconf.templates b/share/scripts/curl.d/0001-debconf.templates
new file mode 100644
index 0000000..c87e47e
--- /dev/null
+++ b/share/scripts/curl.d/0001-debconf.templates
@@ -0,0 +1,11 @@
+Template: cnt-curl/title
+Type: title
+Description: ${TITLE}
+
+Template: cnt-curl/system
+Type: select
+Default:
+Choices-C: ${CHOICES_C}
+Choices: ${CHOICES}
+Description: Container list:
+ Select the system to use for creating the container.
diff --git a/share/scripts/debconf b/share/scripts/debconf
index 38bf937..6190c31 100755
--- a/share/scripts/debconf
+++ b/share/scripts/debconf
@@ -19,6 +19,7 @@
set -e
SCRIPT="${0}"
+export SCRIPT
CONFIG="/etc/container-tools/config"
HOOKS="/etc/container-tools/hooks"
@@ -809,7 +810,7 @@ Configure_systemd_networkd ()
chroot "${DIRECTORY}" systemctl enable systemd-networkd
- for NUMBER in $(seq 0 ${NETWORK_NUMBER})
+ for NUMBER in $(seq 1 ${NETWORK_NUMBER})
do
eval IPV4_COMMENT="$`echo NETWORK${NUMBER}_IPV4_COMMENT`"
eval IPV4_METHOD="$`echo NETWORK${NUMBER}_IPV4_METHOD`"
@@ -827,22 +828,22 @@ Configure_systemd_networkd ()
IPV4_SUFFIX="$(CIDR ${IPV4_NETMASK})"
IPV4_CIDR="${IPV4_ADDRESS}/${IPV4_SUFFIX}"
-cat > "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+cat > "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
[Match]
-Name=eth${NUMBER}
+Name=eno${NUMBER}
[Network]
EOF
if [ -n "${IPV4_COMMENT}" ]
then
- echo "Description=${IPV4_COMMENT}" >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network"
+ echo "Description=${IPV4_COMMENT}" >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network"
fi
case "${IPV4_METHOD}" in
dhcp)
-cat >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
DHCP=ipv4
EOF
@@ -850,7 +851,7 @@ EOF
static)
-cat >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
DHCP=no
Address=${IPV4_CIDR}
EOF
@@ -858,7 +859,7 @@ EOF
if [ -n "${IPV4_GATEWAY}" ]
then
-cat >> "${DIRECTORY}/etc/systemd/network/eth${NUMBER}.network" << EOF
+cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF
Gateway=${IPV4_GATEWAY}
EOF
@@ -868,7 +869,7 @@ EOF
if [ -n "${IPV4_POST_UP}" ]
then
-cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-up-eth${NUMBER}.service" << EOF
+cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-up-eno${NUMBER}.service" << EOF
[Unit]
Description=container-tools IPV4_POST_UP
After=network-online.target
@@ -882,13 +883,13 @@ ExecStart=/bin/sh -c "${IPV4_POST_UP}"
WantedBy=multi-user.target
EOF
- chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-up-eth${NUMBER}.service
+ chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-up-eno${NUMBER}.service
fi
if [ -n "${IPV4_POST_DOWN}" ]
then
-cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-down-eth${NUMBER}.service" << EOF
+cat > "${DIRECTORY}/etc/systemd/system/cnt-ipv4-post-down-eno${NUMBER}.service" << EOF
[Unit]
Description=container-tools IPV4_POST_DOWN
After=network.target
@@ -902,7 +903,7 @@ ExecStart=/bin/sh -c "${IPV4_POST_DOWN}"
WantedBy=multi-user.target
EOF
- chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-down-eth${NUMBER}.service
+ chroot "${DIRECTORY}" systemctl enable cnt-ipv4-post-down-eno${NUMBER}.service
fi
NUMBER="$((${NUMBER} + 1))"
@@ -932,11 +933,11 @@ Commands ()
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:-br0}|g" \
+ -e "s|^cnt.network-bridge=.*|cnt.network-bridge=${HOST_INTERFACE_NAME}:${NETWORK0_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}:eth0|g" \
+ -e "s|^network-veth-extra=.*|network-veth-extra=${HOST_INTERFACE_NAME}:eno1|g" \
"${CONFIG}/${NAME}.conf"
for NUMBER in $(seq 1 ${NETWORK_NUMBER})
@@ -951,12 +952,12 @@ Commands ()
eval HOST_INTERFACE_NAME="$`echo NETWORK${NUMBER}_VETH`"
HOST_INTERFACE_NAME="$(echo ${HOST_INTERFACE_NAME:-veth-${HOSTNAME_SHORT}-${NUMBER}})"
- CONTAINER_INTERFACE_NAME="eth${NUMBER}"
+ CONTAINER_INTERFACE_NAME="eno${NUMBER}"
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:-br${NUMBER}}" "${CONFIG}/${NAME}.conf"
+ sed -i -e "/^register=.*/ a cnt.network-bridge=${HOST_INTERFACE_NAME}:${BRIDGE:-bridge${NUMBER}}" "${CONFIG}/${NAME}.conf"
done
# Setting root password
@@ -971,24 +972,10 @@ Commands ()
umask 0022
-# Get distributor from template filename
-MODE="$(basename ${SCRIPT})"
-
-case "${MODE}" in
- debconf)
- MODE="debian"
- ;;
-esac
-
-export MODE
-
-CACHE="/var/cache/container-tools/${MODE}"
-SYSTEM="${MACHINES}/${NAME}"
+export NAME
Debconf
-export NAME
-
# Pre hooks
for FILE in "${HOOKS}/pre-${SCRIPT}".* "${HOOKS}/${NAME}.pre-${SCRIPT}"
do
@@ -999,19 +986,22 @@ do
done
# Run debconf parts
-for SCRIPT in /usr/share/container-tools/scripts/debconf.d/*
+for DEBCONF_SCRIPT in /usr/share/container-tools/scripts/debconf.d/*
do
- if [ -x "${SCRIPT}" ]
+ if [ -x "${DEBCONF_SCRIPT}" ]
then
# FIXME
- # debconf -ocontainer-tools "${SCRIPT}"
- "${SCRIPT}"
+ # debconf -ocontainer-tools "${DEBCONF_SCRIPT}"
+ "${DEBCONF_SCRIPT}"
fi
done
# Read-in configuration from debconf
. "${DEBCONF_TMPDIR}/debconf.default"
+CACHE="/var/cache/container-tools/${MODE}"
+SYSTEM="${MACHINES}/${NAME}"
+
## Generic parts
if [ ! -e "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" ]
then
diff --git a/share/scripts/debconf.d/0003-debconf b/share/scripts/debconf.d/0003-debconf
index 8e78b3e..2592cf6 100755
--- a/share/scripts/debconf.d/0003-debconf
+++ b/share/scripts/debconf.d/0003-debconf
@@ -23,6 +23,26 @@ export DEBCONF_NOWARNINGS
. /usr/share/debconf/confmodule
+Mode ()
+{
+ db_get cnt-debconf/mode
+ MODE="${RET}" # select
+
+ if [ -z "${MODE}" ]
+ then
+ MODE="$(basename ${SCRIPT})"
+
+ case "${MODE}" in
+ debconf)
+ MODE="debian"
+ ;;
+ esac
+ fi
+
+ echo "MODE=\"${MODE}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
+ export MODE
+}
+
Distribution ()
{
db_get cnt-debconf/distribution
@@ -596,7 +616,7 @@ Packages ()
Local_archives ()
{
- NUMBER="0"
+ NUMBER="1"
while db_get cnt-debconf/archive${NUMBER}/repository && [ "${RET}" ]
do
@@ -674,10 +694,10 @@ Network_defaults ()
# * add support for bridges (make interface configuration more generic?)
HOSTNAME_SHORT="$(echo veth-$(echo ${NAME} | cut -c-8)-0)"
- VETH_NAME="$(echo ${HOSTNAME_SHORT:-veth0})"
+ VETH_NAME="${HOSTNAME_SHORT}"
NETWORK0_VETH="${NETWORK0_VETH:-$VETH_NAME}"
- NETWORK0_BRIDGE="${NETWORK0_BRIDGE:-br0}"
+ 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}"
@@ -696,31 +716,31 @@ Network_defaults ()
Network ()
{
- db_get cnt-debconf/network0/bridge
+ db_get cnt-debconf/network1/bridge
NETWORK0_BRIDGE="${RET}" # string (w/o empty)
- db_get cnt-debconf/network0/veth
+ db_get cnt-debconf/network1/veth
NETWORK0_VETH="${RET}" # string (w/o empty)
- db_get cnt-debconf/network0/ipv4-method
+ db_get cnt-debconf/network1/ipv4-method
NETWORK0_IPV4_METHOD="${RET}" # select
- db_get cnt-debconf/network0/ipv4-comment
+ db_get cnt-debconf/network1/ipv4-comment
NETWORK0_IPV4_COMMENT="${RET}" # string (w/ empty)
- db_get cnt-debconf/network0/ipv4-address
+ db_get cnt-debconf/network1/ipv4-address
NETWORK0_IPV4_ADDRESS="${RET}" # string (w/o empty)
- db_get cnt-debconf/network0/ipv4-gateway
+ db_get cnt-debconf/network1/ipv4-gateway
NETWORK0_IPV4_GATEWAY="${RET}" # string (w/ empty)
- db_get cnt-debconf/network0/ipv4-netmask
+ db_get cnt-debconf/network1/ipv4-netmask
NETWORK0_IPV4_NETMASK="${RET}" # string (w/o empty)
- db_get cnt-debconf/network0/ipv4-post-up
+ db_get cnt-debconf/network1/ipv4-post-up
NETWORK0_IPV4_POST_UP="${RET}" # string (w/ empty)
- db_get cnt-debconf/network0/ipv4-post-down
+ db_get cnt-debconf/network1/ipv4-post-down
NETWORK0_IPV4_POST_DOWN="${RET}" # string (w/ empty)
db_get cnt-debconf/nameserver/server
@@ -737,32 +757,32 @@ Network ()
Network_defaults
- db_set cnt-debconf/network0/bridge "${NETWORK0_BRIDGE}"
- db_fset cnt-debconf/network0/bridge seen false
+ db_set cnt-debconf/network1/bridge "${NETWORK0_BRIDGE}"
+ db_fset cnt-debconf/network1/bridge seen false
- db_set cnt-debconf/network0/veth "${NETWORK0_VETH}"
- db_fset cnt-debconf/network0/veth seen false
+ db_set cnt-debconf/network1/veth "${NETWORK0_VETH}"
+ db_fset cnt-debconf/network1/veth seen false
- db_set cnt-debconf/network0/ipv4-method "${NETWORK0_IPV4_METHOD}"
- db_fset cnt-debconf/network0/ipv4-method seen false
+ db_set cnt-debconf/network1/ipv4-method "${NETWORK0_IPV4_METHOD}"
+ db_fset cnt-debconf/network1/ipv4-method seen false
- db_set cnt-debconf/network0/ipv4-comment "${NETWORK0_IPV4_COMMENT}"
- db_fset cnt-debconf/network0/ipv4-comment seen false
+ db_set cnt-debconf/network1/ipv4-comment "${NETWORK0_IPV4_COMMENT}"
+ db_fset cnt-debconf/network1/ipv4-comment seen false
- db_set cnt-debconf/network0/ipv4-address "${NETWORK0_IPV4_ADDRESS}"
- db_fset cnt-debconf/network0/ipv4-address seen false
+ db_set cnt-debconf/network1/ipv4-address "${NETWORK0_IPV4_ADDRESS}"
+ db_fset cnt-debconf/network1/ipv4-address seen false
- db_set cnt-debconf/network0/ipv4-gateway "${NETWORK0_IPV4_GATEWAY}"
- db_fset cnt-debconf/network0/ipv4-gateway seen false
+ db_set cnt-debconf/network1/ipv4-gateway "${NETWORK0_IPV4_GATEWAY}"
+ db_fset cnt-debconf/network1/ipv4-gateway seen false
- db_set cnt-debconf/network0/ipv4-netmask "${NETWORK0_IPV4_NETMASK}"
- db_fset cnt-debconf/network0/ipv4-netmask seen false
+ db_set cnt-debconf/network1/ipv4-netmask "${NETWORK0_IPV4_NETMASK}"
+ db_fset cnt-debconf/network1/ipv4-netmask seen false
- db_set cnt-debconf/network0/ipv4-post-up "${NETWORK0_IPV4_POST_UP}"
- db_fset cnt-debconf/network0/ipv4-post-up seen false
+ db_set cnt-debconf/network1/ipv4-post-up "${NETWORK0_IPV4_POST_UP}"
+ db_fset cnt-debconf/network1/ipv4-post-up seen false
- db_set cnt-debconf/network0/ipv4-post-down "${NETWORK0_IPV4_POST_DOWN}"
- db_fset cnt-debconf/network0/ipv4-post-down seen false
+ db_set cnt-debconf/network1/ipv4-post-down "${NETWORK0_IPV4_POST_DOWN}"
+ db_fset cnt-debconf/network1/ipv4-post-down seen false
db_set cnt-debconf/nameserver/server "${NAMESERVER_SERVER}"
db_fset cnt-debconf/nameserver/server seen false
@@ -777,16 +797,16 @@ Network ()
db_fset cnt-debconf/nameserver/options seen false
db_settitle cnt-debconf/title
- db_input high cnt-debconf/network0/ipv4-method || true
+ db_input high cnt-debconf/network1/ipv4-method || true
db_go
- db_get cnt-debconf/network0/bridge
+ db_get cnt-debconf/network1/bridge
NETWORK0_BRIDGE="${RET}" # select
- db_get cnt-debconf/network0/veth
+ db_get cnt-debconf/network1/veth
NETWORK0_VETH="${RET}" # select
- db_get cnt-debconf/network0/ipv4-method
+ db_get cnt-debconf/network1/ipv4-method
NETWORK0_IPV4_METHOD="${RET}" # select
case "${NETWORK0_IPV4_METHOD}" in
@@ -795,27 +815,27 @@ Network ()
static)
db_settitle cnt-debconf/title
- db_input high cnt-debconf/network0/ipv4-comment || true
+ db_input high cnt-debconf/network1/ipv4-comment || true
db_go
db_settitle cnt-debconf/title
- db_input high cnt-debconf/network0/ipv4-address || true
+ db_input high cnt-debconf/network1/ipv4-address || true
db_go
db_settitle cnt-debconf/title
- db_input high cnt-debconf/network0/ipv4-gateway || true
+ db_input high cnt-debconf/network1/ipv4-gateway || true
db_go
db_settitle cnt-debconf/title
- db_input high cnt-debconf/network0/ipv4-netmask || true
+ db_input high cnt-debconf/network1/ipv4-netmask || true
db_go
db_settitle cnt-debconf/title
- db_input high cnt-debconf/network0/ipv4-post-up || true
+ db_input high cnt-debconf/network1/ipv4-post-up || true
db_go
db_settitle cnt-debconf/title
- db_input high cnt-debconf/network0/ipv4-post-down || true
+ db_input high cnt-debconf/network1/ipv4-post-down || true
db_go
db_settitle cnt-debconf/title
@@ -824,7 +844,7 @@ Network ()
;;
esac
- NUMBER="0"
+ NUMBER="1"
while db_get cnt-debconf/network${NUMBER}/ipv4-method && [ "${RET}" ]
do
@@ -894,7 +914,7 @@ Network ()
echo "NETWORK_NUMBER=\"${NETWORK_NUMBER}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
- for NUMBER in $(seq 0 ${NETWORK_NUMBER})
+ for NUMBER in $(seq 1 ${NETWORK_NUMBER})
do
eval BRIDGE="$`echo NETWORK${NUMBER}_BRIDGE`"
echo "NETWORK${NUMBER}_BRIDGE=\"${BRIDGE}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
@@ -1044,6 +1064,8 @@ Internal_options ()
echo "CNT_OVERLAY=\"${CNT_OVERLAY}\"" >> "${DEBCONF_TMPDIR}/debconf.default"
}
+Mode
+
Distribution
Parent_distribution
diff --git a/share/scripts/debconf.d/0003-debconf.templates b/share/scripts/debconf.d/0003-debconf.templates
index e46fa88..e3dbc24 100644
--- a/share/scripts/debconf.d/0003-debconf.templates
+++ b/share/scripts/debconf.d/0003-debconf.templates
@@ -2,6 +2,14 @@ Template: cnt-debconf/title
Type: title
Description: container-tools
+Template: cnt-debconf/mode
+Type: select
+Default:
+Choices-C: ${CHOICES_C}
+Choices: ${CHOICES}
+Description: Mode
+ Mode.
+
Template: cnt-debconf/distribution
Type: select
Default:
@@ -92,19 +100,19 @@ Default:
Description: Root password
Root password.
-Template: cnt-debconf/network0/bridge
+Template: cnt-debconf/network1/bridge
Type: string
Default:
Description: Bridge
Bridge.
-Template: cnt-debconf/network0/veth
+Template: cnt-debconf/network1/veth
Type: string
Default:
Description: Veth name
Veth name.
-Template: cnt-debconf/network0/ipv4-method
+Template: cnt-debconf/network1/ipv4-method
Type: select
Choices: dhcp, static, none
Default:
@@ -114,7 +122,7 @@ Description: Ethernet Interface Method (IPv4)?
This defaults to dhcp and will require that you run a dhcp-server in your
network.
-Template: cnt-debconf/network0/ipv4-comment
+Template: cnt-debconf/network1/ipv4-comment
Type: string
Default:
Description: Ethernet Interface Comment (IPv4)?
@@ -122,7 +130,7 @@ Description: Ethernet Interface Comment (IPv4)?
.
This defaults to empty.
-Template: cnt-debconf/network0/ipv4-address
+Template: cnt-debconf/network1/ipv4-address
Type: string
Default:
Description: Ethernet IP Address (IPv4)?
@@ -130,7 +138,7 @@ Description: Ethernet IP Address (IPv4)?
.
This defaults to 192.168.1.2.
-Template: cnt-debconf/network0/ipv4-gateway
+Template: cnt-debconf/network1/ipv4-gateway
Type: string
Default:
Description: Ethernet Gateway Address (IPv4)?
@@ -138,7 +146,7 @@ Description: Ethernet Gateway Address (IPv4)?
.
This defaults to empty.
-Template: cnt-debconf/network0/ipv4-netmask
+Template: cnt-debconf/network1/ipv4-netmask
Type: string
Default:
Description: Ethernet Network Mask (IPv4)?
@@ -146,19 +154,19 @@ Description: Ethernet Network Mask (IPv4)?
.
This defaults to empty.
-Template: cnt-debconf/network0/ipv4-post-up
+Template: cnt-debconf/network1/ipv4-post-up
Type: string
Default:
Description: Ethernet post-up Command (IPv4)?
- What should be the post-up command for eth0?
+ What should be the post-up command for eno1?
.
This defaults to empty.
-Template: cnt-debconf/network0/ipv4-post-down
+Template: cnt-debconf/network1/ipv4-post-down
Type: string
Default:
Description: Ethernet post-down Command (IPv4)?
- What should be the post-down command for eth0?
+ What should be the post-down command for eno1?
.
This defaults to empty.