summaryrefslogtreecommitdiffstats
path: root/share/scripts/debconf
diff options
context:
space:
mode:
Diffstat (limited to 'share/scripts/debconf')
-rwxr-xr-xshare/scripts/debconf231
1 files changed, 127 insertions, 104 deletions
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}"