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
nmcli device wifi list
local wifi_ssid
wifi_ssid="$(get_value "wifi_ssid" "wifi ssid")"
local wifi_pw
wifi_pw="$(get_value "wifi_pw" "wifi password" 1)"
wpa_supplicant -B -i "$wifi_if" -c <(wpa_passphrase "$wifi_ssid" "$wifi_pw")
sv restart dhcpcd
nmcli con delete "$wifi_ssid" || true
nmcli device wifi connect "$wifi_ssid" password "$wifi_pw"
}
datetime() {
@ -97,7 +99,10 @@ open_luks() {
local install_dev
install_dev="$(get_value "install_dev" "installation device")"
cryptsetup open "$install_dev"p2 void
if ! dmsetup ls | grep "void\s"; then
cryptsetup open "$install_dev"p2 void
fi
}
create_lvm() {
@ -117,15 +122,38 @@ make_filesystems() {
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() {
local install_dev
install_dev="$(get_value "install_dev" "installation device")"
mount /dev/void/root /mnt
mkdir -p /mnt/boot
mount "$install_dev"p1 /mnt/boot
ensure_mount "/dev/void/root" "/mnt"
swapon /dev/void/swap
mkdir -p /mnt/boot
ensure_mount "$install_dev"p1 "/mnt/boot"
if [ "$(cat /proc/swaps | wc -l)" == 1 ]; then
swapon /dev/void/swap
fi
}
install_basesystem() {
@ -141,10 +169,10 @@ EOF
}
mount_special_filesystems() {
mount --rbind /sys /mnt/sys && mount --make-rslave /mnt/sys
mount --rbind /dev /mnt/dev && mount --make-rslave /mnt/dev
mount --rbind /proc /mnt/proc && mount --make-rslave /mnt/proc
mount --rbind /tmp /mnt/tmp && mount --make-rslave /mnt/tmp
ensure_mount "/sys" "/mnt/sys" 1
ensure_mount "/dev" "/mnt/dev" 1
ensure_mount "/proc" "/mnt/proc" 1
ensure_mount "/tmp" "/mnt/tmp" 1
}
set_fstab() {
@ -275,6 +303,10 @@ EOF
tidy_up() {
umount -R /mnt
lvchange -an void/root
lvchange -an void/swap
vgchange -an void
cryptsetup close void
}
full_install() {

View File

@ -62,8 +62,8 @@ build_img() {
cd "$GIT_DIR"
sudo ./mkrootfs.sh -o "$rootfs_file" aarch64
sudo ./mkplatformfs.sh -p "dracut lvm2 cryptsetup" -o "$platformfs_file" pinebookpro "$rootfs_file"
sudo ./mkimage.sh -B 256MiB -o "$img" "$platformfs_file"
sudo ./mkplatformfs.sh -p "dracut lvm2 cryptsetup dbus NetworkManager" -o "$platformfs_file" pinebookpro "$rootfs_file"
sudo ./mkimage.sh -B 256MiB -s 3GB -o "$img" "$platformfs_file"
# shellcheck disable=SC2024
# 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 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
sudo rm "$TMP_DIR_MOUNT/usr/bin/qemu-aarch64-static"