diff options
Diffstat (limited to '')
-rw-r--r-- | CHANGELOG.txt | 16 | ||||
-rw-r--r-- | VERSION.txt | 2 | ||||
-rwxr-xr-x | lib/container/list | 10 | ||||
-rw-r--r-- | share/bash-completion/container | 1 | ||||
-rwxr-xr-x | share/scripts/debconf | 231 |
5 files changed, 150 insertions, 110 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 38e1b10..0034716 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,19 @@ +2019-04-13 Daniel Baumann <daniel.baumann@open-infrastructure.net> + + * Releasing version 20190413. + + [ Daniel Baumann ] + * Removing explicit protocol for IP adresses in container list command. + * Including gnupg explicitly in debconf container create command, thanks to Nik Lutz <nik@netstyle.ch>. + * Correcting syntax error in container bash-completion. + * Correcting typo when disabling IPv6 RA in debconf container create script, thanks to Simon Spöhel <simon@spoehel.ch>. + + [ Nik Lutz ] + * Unmount bind mounts in reverse order to allow nested bind mounts. + + [ Daniel Baumann ] + * Using trap function to unmount bind mounts etc. on exit with or without error. + 2019-03-19 Daniel Baumann <daniel.baumann@open-infrastructure.net> * Releasing version 20190319. diff --git a/VERSION.txt b/VERSION.txt index a61f3fc..c7d138c 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -20190319 +20190413 diff --git a/lib/container/list b/lib/container/list index 62f6a5b..6b0d771 100755 --- a/lib/container/list +++ b/lib/container/list @@ -146,7 +146,7 @@ cat << EOF { "name": "${CONTAINER}", "status": "${STATE}", - "ipv4Address": "${ADDRESS}", + "address": "${ADDRESS}", }, EOF @@ -179,8 +179,8 @@ EOF yaml) cat << EOF - - name: ${CONTAINER} - ipv4_address: ${ADDRESS} + - name: ${CONTAINER} + address: ${ADDRESS} EOF ;; @@ -190,7 +190,7 @@ EOF cat << EOF <container> <name>${CONTAINER}</name> - <ipv4Address>${ADDRESS}</ipv4Address> + <address>${ADDRESS}</address> </container> EOF @@ -225,7 +225,7 @@ case "${FORMAT}" in NORMAL="$(tput sgr0)" cat << EOF -${WHITE} ${NORMAL} Container IPv4 Address(es) +${WHITE} ${NORMAL} Container IP Address -------------------------------------------------------------------------------- EOF diff --git a/share/bash-completion/container b/share/bash-completion/container index e130710..d791ff6 100644 --- a/share/bash-completion/container +++ b/share/bash-completion/container @@ -102,6 +102,7 @@ _container() opts="-a --add -l --list -r --remove" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 + ;; limit) case "${prev}" in diff --git a/share/scripts/debconf b/share/scripts/debconf index 46f0381..b4b5e18 100755 --- a/share/scripts/debconf +++ b/share/scripts/debconf @@ -126,6 +126,124 @@ then exit 1 fi +Start () +{ + # Mounting rw bind mounts + if [ -n "${BIND}" ] + then + BINDS="$(echo ${BIND} | sed -e 's|;| |g')" + + for ENTRY in ${BINDS} + do + SOURCE="$(echo ${ENTRY} | awk -F: '{ print $1 }')" + TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" + + mkdir -p "${SOURCE}" + mkdir -p "${MACHINES}/${NAME}/${TARGET}" + + mount -o bind "${SOURCE}" "${MACHINES}/${NAME}/${TARGET}" + done + fi + + # Mounting ro bind mounts + if [ -n "${BIND_RO}" ] + then + BINDS_RO="$(echo ${BIND_RO} | sed -e 's|;| |g')" + + for ENTRY in ${BINDS_RO} + do + SOURCE="$(echo ${ENTRY} | awk -F: '{ print $1 }')" + TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" + + mkdir -p "${SOURCE}" + mkdir -p "${MACHINES}/${NAME}/${TARGET}" + + mount -o rbind "${SOURCE}" "${MACHINES}/${NAME}/${TARGET}" + done + fi + + # Mounting overlay mounts + if [ -n "${CNT_OVERLAY}" ] + then + CNT_OVERLAYS="$(echo ${CNT_OVERLAY} | sed -e 's|;| |g')" + + for CNT_OVERLAY in ${CNT_OVERLAYS} + do + DIRECTORY_LOWER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $1 }')" + DIRECTORY_UPPER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $2 }')" + DIRECTORY_WORK="$(echo ${CNT_OVERLAY} | awk -F: '{ print $3 }')" + DIRECTORY_MERGED="$(echo ${CNT_OVERLAY} | awk -F: '{ print $4 }')" + + for DIRECTORY in "${DIRECTORY_LOWER}" "${DIRECTORY_UPPER}" "${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" + do + mkdir -p "${DIRECTORY}" + done + + mount -t overlay overlay-${NAME} -olowerdir="${DIRECTORY_LOWER}",upperdir="${DIRECTORY_UPPER}",workdir="${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" + done + fi + + # Trap function + trap 'Stop' EXIT HUP INT QUIT TERM +} + +Stop () +{ + # Unmounting overlay mounts + if [ -n "${CNT_OVERLAY}" ] + then + CNT_OVERLAYS="$(echo ${CNT_OVERLAY} | sed -e 's|;| |g')" + + for CNT_OVERLAY in ${CNT_OVERLAYS} + do + DIRECTORY_LOWER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $1 }')" + DIRECTORY_UPPER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $2 }')" + DIRECTORY_WORK="$(echo ${CNT_OVERLAY} | awk -F: '{ print $3 }')" + DIRECTORY_MERGED="$(echo ${CNT_OVERLAY} | awk -F: '{ print $4 }')" + + umount -f "${DIRECTORY_MERGED}" > /dev/null 2>&1 || true + + for DIRECTORY in "${DIRECTORY_LOWER}" "${DIRECTORY_UPPER}" "${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" + do + rmdir --ignore-fail-on-non-empty --parents ${DIRECTORY} > /dev/null 2>&1 || true + done + done + fi + + # Unmounting ro bind mounts + if [ -n "${BIND_RO}" ] + then + # unmount in reverse order to allow nested bind mounts + BINDS_RO="$(echo ${BIND_RO} | sed -e 's|;| |g' | awk '{ for (i=NF; i>=1; i--) printf "%s ", $i; print ""}')" + + for ENTRY in ${BINDS_RO} + do + TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" + + umount -f "${MACHINES}/${NAME}/${TARGET}" > /dev/null 2>&1 || true + done + fi + + # Unmounting rw bind mounts + if [ -n "${BIND}" ] + then + # unmount in reverse order to allow nested bind mounts + BINDS="$(echo ${BIND} | sed -e 's|;| |g' | awk '{ for (i=NF; i>=1; i--) printf "%s ", $i; print ""}')" + + for ENTRY in ${BINDS} + do + TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" + + umount -f "${MACHINES}/${NAME}/${TARGET}" > /dev/null 2>&1 || true + done + fi + + # Unmounting pseudo-filesystems + umount -f "${DIRECTORY}/dev/pts" > /dev/null 2>&1 || true + umount -f "${DIRECTORY}/proc" > /dev/null 2>&1 || true + umount -f "${DIRECTORY}/sys" > /dev/null 2>&1 || true +} + Chroot () { CHROOT="${1}" @@ -187,9 +305,9 @@ Cleanup_system () rm -f "${DIRECTORY}/usr/sbin/policy-rc.d" # Unmount pseudo-filesystems - umount "${DIRECTORY}/dev/pts" - umount "${DIRECTORY}/proc" - umount "${DIRECTORY}/sys" + umount -f "${DIRECTORY}/dev/pts" > /dev/null 2>&1 || true + umount -f "${DIRECTORY}/proc" > /dev/null 2>&1 || true + umount -f "${DIRECTORY}/sys" > /dev/null 2>&1 || true } Debconf () @@ -240,6 +358,9 @@ Debootstrap () EXCLUDE="ifupdown" INCLUDE="dbus" + # apt repositories + INCLUDE="${INCLUDE} gnupg" + if ( echo "${MIRROR}" | grep -qs '^https' ) || \ ( echo "${PARENT_MIRROR}" | grep -qs '^https' ) then @@ -824,7 +945,7 @@ EOF cat >> "${DIRECTORY}/etc/systemd/network/eno${NUMBER}.network" << EOF DHCP=no -Ipv6AcceptRA=no +IPv6AcceptRA=no Address=${IPV6_ADDRESS}/${IPV6_NETMASK} EOF @@ -1008,60 +1129,7 @@ Cleanup_system "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" mkdir -p "${MACHINES}" cp -a "${CACHE}/${DISTRIBUTION}_${ARCHITECTURE}" "${MACHINES}/${NAME}" -# Mounting rw bind mounts -if [ -n "${BIND}" ] -then - BINDS="$(echo ${BIND} | sed -e 's|;| |g')" - - for ENTRY in ${BINDS} - do - SOURCE="$(echo ${ENTRY} | awk -F: '{ print $1 }')" - TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" - - mkdir -p "${SOURCE}" - mkdir -p "${MACHINES}/${NAME}/${TARGET}" - - mount -o bind "${SOURCE}" "${MACHINES}/${NAME}/${TARGET}" - done -fi - -# Mounting ro bind mounts -if [ -n "${BIND_RO}" ] -then - BINDS_RO="$(echo ${BIND_RO} | sed -e 's|;| |g')" - - for ENTRY in ${BINDS_RO} - do - SOURCE="$(echo ${ENTRY} | awk -F: '{ print $1 }')" - TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" - - mkdir -p "${SOURCE}" - mkdir -p "${MACHINES}/${NAME}/${TARGET}" - - mount -o rbind "${SOURCE}" "${MACHINES}/${NAME}/${TARGET}" - done -fi - -# Mounting overlay mounts -if [ -n "${CNT_OVERLAY}" ] -then - CNT_OVERLAYS="$(echo ${CNT_OVERLAY} | sed -e 's|;| |g')" - - for CNT_OVERLAY in ${CNT_OVERLAYS} - do - DIRECTORY_LOWER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $1 }')" - DIRECTORY_UPPER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $2 }')" - DIRECTORY_WORK="$(echo ${CNT_OVERLAY} | awk -F: '{ print $3 }')" - DIRECTORY_MERGED="$(echo ${CNT_OVERLAY} | awk -F: '{ print $4 }')" - - for DIRECTORY in "${DIRECTORY_LOWER}" "${DIRECTORY_UPPER}" "${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" - do - mkdir -p "${DIRECTORY}" - done - - mount -t overlay overlay-${NAME} -olowerdir="${DIRECTORY_LOWER}",upperdir="${DIRECTORY_UPPER}",workdir="${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" - done -fi +Start Configure_system "${MACHINES}/${NAME}" Configure_network "${MACHINES}/${NAME}" @@ -1070,52 +1138,7 @@ Cleanup_system "${MACHINES}/${NAME}" Commands "${MACHINES}/${NAME}" -# Unmounting overlay mounts -if [ -n "${CNT_OVERLAY}" ] -then - CNT_OVERLAYS="$(echo ${CNT_OVERLAY} | sed -e 's|;| |g')" - - for CNT_OVERLAY in ${CNT_OVERLAYS} - do - DIRECTORY_LOWER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $1 }')" - DIRECTORY_UPPER="$(echo ${CNT_OVERLAY} | awk -F: '{ print $2 }')" - DIRECTORY_WORK="$(echo ${CNT_OVERLAY} | awk -F: '{ print $3 }')" - DIRECTORY_MERGED="$(echo ${CNT_OVERLAY} | awk -F: '{ print $4 }')" - - umount -f "${DIRECTORY_MERGED}" - - for DIRECTORY in "${DIRECTORY_LOWER}" "${DIRECTORY_UPPER}" "${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" - do - rmdir --ignore-fail-on-non-empty --parents ${DIRECTORY} > /dev/null 2>&1 || true - done - done -fi - -# Unmounting ro bind mounts -if [ -n "${BIND_RO}" ] -then - BINDS_RO="$(echo ${BIND_RO} | sed -e 's|;| |g')" - - for ENTRY in ${BINDS_RO} - do - TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" - - umount "${MACHINES}/${NAME}/${TARGET}" - done -fi - -# Unmounting rw bind mounts -if [ -n "${BIND}" ] -then - BINDS="$(echo ${BIND} | sed -e 's|;| |g')" - - for ENTRY in ${BINDS} - do - TARGET="$(echo ${ENTRY} | awk -F: '{ print $2 }')" - - umount "${MACHINES}/${NAME}/${TARGET}" - done -fi +Stop # remove debconf temporary files rm --preserve-root --one-file-system -rf "${DEBCONF_TMPDIR}" |