diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-04-13 03:50:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-04-13 03:50:46 +0000 |
commit | e2f4b1bdd37de42d4dc6abc906ff3e8c4838cd7d (patch) | |
tree | c44aac9fc705ef1b72c48d18da76f5bc831dfb88 /share/scripts | |
parent | Releasing debian version 20190319-1. (diff) | |
download | open-infrastructure-compute-tools-e2f4b1bdd37de42d4dc6abc906ff3e8c4838cd7d.tar.xz open-infrastructure-compute-tools-e2f4b1bdd37de42d4dc6abc906ff3e8c4838cd7d.zip |
Merging upstream version 20190413.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/scripts')
-rwxr-xr-x | share/scripts/debconf | 231 |
1 files changed, 127 insertions, 104 deletions
diff --git a/share/scripts/debconf b/share/scripts/debconf index 46f0381..5d6e464 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}" + + 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}" + 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}" + done + fi + + # Unmounting pseudo-filesystems + umount -f "${DIRECTORY}/dev/pts" + umount -f "${DIRECTORY}/proc" + umount -f "${DIRECTORY}/sys" +} + 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" + umount -f "${DIRECTORY}/proc" + umount -f "${DIRECTORY}/sys" } 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}" |