diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-11-30 22:25:33 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-12-12 00:36:37 +0000 |
commit | 0ebbd14c7c570cf6475975c727eae7f94bf7b34f (patch) | |
tree | d4af664698cfbee3a72e82aa516e92ede7723682 /etc/init | |
parent | 42bc3c1ee1fe8af9b77fe0ebbdbc9ab484a18a4e (diff) | |
download | spectrum-0ebbd14c7c570cf6475975c727eae7f94bf7b34f.tar spectrum-0ebbd14c7c570cf6475975c727eae7f94bf7b34f.tar.gz spectrum-0ebbd14c7c570cf6475975c727eae7f94bf7b34f.tar.bz2 spectrum-0ebbd14c7c570cf6475975c727eae7f94bf7b34f.tar.lz spectrum-0ebbd14c7c570cf6475975c727eae7f94bf7b34f.tar.xz spectrum-0ebbd14c7c570cf6475975c727eae7f94bf7b34f.tar.zst spectrum-0ebbd14c7c570cf6475975c727eae7f94bf7b34f.zip |
Break out files from live.nix
This is the first step towards adding a proper build system.
Diffstat (limited to 'etc/init')
-rw-r--r-- | etc/init | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/etc/init b/etc/init new file mode 100644 index 0000000..083a0ea --- /dev/null +++ b/etc/init @@ -0,0 +1,56 @@ +#!/bin/execlineb -S0 + +export PATH /bin + +if { mount -t devtmpfs none /dev } +if { mount -t proc none /proc } +if { mount -t sysfs none /sys } +if { mount -t efivarfs none /sys/firmware/efi/efivars } + +if { mkfifo /dev/esp.poll } + +background { + fdclose 3 + mdevd -C +} +importas -iu mdevd_pid ! + +if { modprobe ext4 } + +if { + redirfd -r 0 /dev/esp.poll + redirfd -w 1 /dev/null + head -c 1 +} +background { rm /dev/esp.poll } +background { kill $mdevd_pid } + +backtick -E partname { readlink /dev/esp } +backtick -E partpath { realpath /sys/class/block/${partname} } +backtick -E diskpath { realpath ${partpath}/.. } +backtick -E diskname { basename $diskpath } + +backtick -E rootdev { + pipeline { lsblk -lnpo NAME,PARTTYPE /dev/${diskname} } + pipeline { grep -m 1 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 } + cut -d " " -f 1 +} + +backtick -E hashdev { + pipeline { lsblk -lnpo NAME,PARTTYPE /dev/${diskname} } + pipeline { grep -m 1 2c7357ed-ebd2-46d9-aec1-23d437ec2bf5 } + cut -d " " -f 1 +} + +background { rm /dev/esp } + +backtick -E roothash { cat /etc/roothash } + +if { veritysetup open $rootdev root-verity $hashdev $roothash } +if { mount /dev/mapper/root-verity /mnt } +if { mount --move /proc /mnt/proc } +if { mount --move /sys /mnt/sys } +if { mount --move /dev /mnt/dev } + +switch_root /mnt +/etc/init |