clean up everything correctly

This commit is contained in:
Sebastian Hugentobler 2021-02-10 21:09:50 +01:00
parent 511bed496e
commit 6a3cecda84
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
2 changed files with 47 additions and 14 deletions

View File

@ -49,13 +49,15 @@ network() {
ip link set "$wifi_if" up ip link set "$wifi_if" up
nmcli device wifi list
local wifi_ssid local wifi_ssid
wifi_ssid="$(get_value "wifi_ssid" "wifi ssid")" wifi_ssid="$(get_value "wifi_ssid" "wifi ssid")"
local wifi_pw local wifi_pw
wifi_pw="$(get_value "wifi_pw" "wifi password" 1)" wifi_pw="$(get_value "wifi_pw" "wifi password" 1)"
wpa_supplicant -B -i "$wifi_if" -c <(wpa_passphrase "$wifi_ssid" "$wifi_pw") nmcli con delete "$wifi_ssid" || true
sv restart dhcpcd nmcli device wifi connect "$wifi_ssid" password "$wifi_pw"
} }
datetime() { datetime() {
@ -97,7 +99,10 @@ 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() {
@ -117,15 +122,38 @@ make_filesystems() {
mkfs.xfs -f -L ROOT /dev/void/root mkfs.xfs -f -L ROOT /dev/void/root
} }
ensure_mount() {
local src="$1"
local dest="$2"
local with_rbind="$3"
local rbind=""
if [ ! -z "$with_rbind" ]; then
rbind="--rbind"
fi
if grep -qs "$dest " /proc/mounts; then
mount "$rbind" "$src" "$dest"
if [ ! -z "$with_rbind"]; then
mount --make-rslave "$dest"
fi
fi
}
mount_filesystems() { mount_filesystems() {
local install_dev local install_dev
install_dev="$(get_value "install_dev" "installation device")" install_dev="$(get_value "install_dev" "installation device")"
mount /dev/void/root /mnt ensure_mount "/dev/void/root" "/mnt"
mkdir -p /mnt/boot
mount "$install_dev"p1 /mnt/boot
mkdir -p /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() {
@ -141,10 +169,10 @@ EOF
} }
mount_special_filesystems() { mount_special_filesystems() {
mount --rbind /sys /mnt/sys && mount --make-rslave /mnt/sys ensure_mount "/sys" "/mnt/sys" 1
mount --rbind /dev /mnt/dev && mount --make-rslave /mnt/dev ensure_mount "/dev" "/mnt/dev" 1
mount --rbind /proc /mnt/proc && mount --make-rslave /mnt/proc ensure_mount "/proc" "/mnt/proc" 1
mount --rbind /tmp /mnt/tmp && mount --make-rslave /mnt/tmp ensure_mount "/tmp" "/mnt/tmp" 1
} }
set_fstab() { set_fstab() {
@ -275,6 +303,10 @@ EOF
tidy_up() { tidy_up() {
umount -R /mnt umount -R /mnt
lvchange -an void/root
lvchange -an void/swap
vgchange -an void
cryptsetup close void
} }
full_install() { full_install() {

View File

@ -62,8 +62,8 @@ build_img() {
cd "$GIT_DIR" cd "$GIT_DIR"
sudo ./mkrootfs.sh -o "$rootfs_file" aarch64 sudo ./mkrootfs.sh -o "$rootfs_file" aarch64
sudo ./mkplatformfs.sh -p "dracut lvm2 cryptsetup" -o "$platformfs_file" pinebookpro "$rootfs_file" sudo ./mkplatformfs.sh -p "dracut lvm2 cryptsetup dbus NetworkManager" -o "$platformfs_file" pinebookpro "$rootfs_file"
sudo ./mkimage.sh -B 256MiB -o "$img" "$platformfs_file" sudo ./mkimage.sh -B 256MiB -s 3GB -o "$img" "$platformfs_file"
# shellcheck disable=SC2024 # shellcheck disable=SC2024
# it is correct that the decompressed image is written as the unprivileged user # it is correct that the decompressed image is written as the unprivileged user
@ -81,7 +81,8 @@ build_img() {
sudo cp "$(which qemu-aarch64-static)" "$TMP_DIR_MOUNT/usr/bin/" sudo cp "$(which qemu-aarch64-static)" "$TMP_DIR_MOUNT/usr/bin/"
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/dhcpcd /etc/runit/runsvdir/default/ ln -s /etc/sv/dbus /etc/runit/runsvdir/default/
ln -s /etc/sv/NetworkManager /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"