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

View File

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