clean up everything correctly

This commit is contained in:
Sebastian Hugentobler 2021-02-11 00:45:29 +01:00
parent 6a3cecda84
commit 46be773a1d
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
2 changed files with 20 additions and 18 deletions

View File

@ -99,10 +99,7 @@ open_luks() {
local install_dev
install_dev="$(get_value "install_dev" "installation device")"
if ! dmsetup ls | grep "void\s"; then
cryptsetup open "$install_dev"p2 void
fi
cryptsetup open "$install_dev"p2 void
}
create_lvm() {
@ -133,12 +130,10 @@ ensure_mount() {
rbind="--rbind"
fi
if grep -qs "$dest " /proc/mounts; then
mount "$rbind" "$src" "$dest"
mount $rbind "$src" "$dest"
if [ ! -z "$with_rbind"]; then
mount --make-rslave "$dest"
fi
if [ ! -z "$with_rbind" ]; then
mount --make-rslave "$dest"
fi
}
@ -151,9 +146,7 @@ mount_filesystems() {
mkdir -p /mnt/boot
ensure_mount "$install_dev"p1 "/mnt/boot"
if [ "$(cat /proc/swaps | wc -l)" == 1 ]; then
swapon /dev/void/swap
fi
swapon /dev/void/swap
}
install_basesystem() {
@ -245,7 +238,7 @@ set_base_conf() {
local locale
locale="$(get_value "locale" "locale")"
echo "$locale" >> /etc/default/libc-locales
echo "$locale" >> /mnt/etc/default/libc-locales
chroot /mnt /bin/env -i \
timezone="$timezone" \
@ -302,11 +295,17 @@ EOF
}
tidy_up() {
umount -R /mnt
lvchange -an void/root
lvchange -an void/swap
vgchange -an void
cryptsetup close void
sync
if grep -qe "/mnt " /proc/mounts; then
umount -R /mnt
fi
swapoff /dev/void/swap > /dev/null 2>&1 || true
vgchange --activate n
cryptsetup close void > /dev/null 2>&1 || true
}
full_install() {
@ -404,6 +403,8 @@ cmd_loop() {
done
}
trap tidy_up 0 SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
if [ "$1" == "full" ]; then
full_install
else

View File

@ -83,6 +83,7 @@ build_img() {
sudo chroot "$TMP_DIR_MOUNT" qemu-aarch64-static /bin/bash <<"EOT"
ln -s /etc/sv/dbus /etc/runit/runsvdir/default/
ln -s /etc/sv/NetworkManager /etc/runit/runsvdir/default/
ln -s /etc/sv/sshd /etc/runit/runsvdir/default/
EOT
sudo rm "$TMP_DIR_MOUNT/usr/bin/qemu-aarch64-static"