nanmi-initramfs

nanmi's initramfs
git clone git://xn--q9jzb1c.xn--q9jyb4c/nanmi-initramfs
Log | Files | Refs | README | LICENSE

init (2437B)


      1 #!/bin/busybox sh
      2 set -uo pipefail
      3 export PATH=/sbin:/bin
      4 INSTALL="$(printf '\033[32;01m')"
      5 GENTOO="$(printf '\033[0m')"
      6 LOL="$(printf %101s)"
      7 
      8 text() {
      9 	printf " ${INSTALL}*${GENTOO} $*\n"
     10 }
     11 
     12 installGentoo() {
     13 echo "${INSTALL}"
     14 echo "${LOL}                 __"
     15 echo "${LOL}    ___     __.::::::..__"
     16 echo "${LOL} ,:::::::odP\"::::::::::\"\"Yb."
     17 echo "${LOL}  \`::::d'\":::d::d b::L:::::\`b.   ___"
     18 echo "${LOL} .:::.d':d::d:,P   b:Ib:I::::\`b::::::."
     19 echo "${LOL}  7;' I:d .dP\"      bI bIb::::\`b::::::'"
     20 echo "${LOL}  '   V'     ___     b __ b::::I\`:::::."
     21 echo "${LOL}     ( cI  \"\"   \"\"   \"\"  \`.b:_P   \"\`: '"
     22 echo "${LOL}      \ I                   V \`."
     23 echo "${LOL}       d'    ,\"\"\"\"\"\"\"\".      (, )"
     24 echo "${LOL}      b     :        :     ,  /"
     25 echo "${LOL}     .-\"b    :        ;   .d..\`."
     26 echo "${LOL}    <::::Y._  \`._____/  ,;\"\`::::\\"
     27 echo "${LOL}    /::::' \`\"\"=..__..,=\"'    \:.|\""
     28 echo "${LOL}    \"|:'        )\"\" (         \|\`"
     29 echo "${LOL}"
     30 echo "${LOL}		install_gentoo.exe"
     31 echo "${GENTOO}"
     32 }
     33 
     34 cmdline() {
     35     local value
     36     value=" $(cat /proc/cmdline) "
     37     value="${value##* ${1}=}"
     38     value="${value%% *}"
     39     [ "${value}" != "" ] && echo "${value}"
     40 }
     41 
     42 setUp() {
     43 	sleep 1
     44 	mount -t devtmpfs -o noexec,nosuid none /dev
     45 	mount -t proc -o nodev,noexec,nosuid none /proc
     46 	mount -t sysfs -o nodev,noexec,nosuid none /sys
     47 	echo 0 > /proc/sys/kernel/printk
     48 	clear
     49 	installGentoo
     50 }
     51 
     52 prepareStick() {
     53 	/sbin/cryptsetup luksOpen --tries 1 $(findfs $(cmdline moe)) usb
     54 	text "Mounting USB stick..."
     55 	mount -o ro /dev/mapper/usb /mnt/usb
     56 }
     57 
     58 prepareDisk() {
     59 	text "Decrypting the disk..."
     60 	/sbin/cryptsetup luksOpen /dev/nvme0n1 install --header /mnt/usb/header --key-file /mnt/usb/key --keyfile-offset 1337 --keyfile-size 8386942
     61 	text "Checking integrity..."
     62 	integritysetup open /dev/mapper/install gentoo --integrity hmac-sha256 --integrity-bitmap-mode --integrity-key-file /mnt/usb/nvme/key.bin --integrity-key-size 4096
     63 	text "Mounting disk..."
     64 	mount -o ro,noatime,ssd,compress=lzo,space_cache=v1,subvol=@ /dev/mapper/gentoo /mnt/gentoo
     65 	}
     66 
     67 closeStick() {
     68 	text "Unmounting USB stick..."
     69 	umount /mnt/usb
     70 	test "Closing the USB stick..."
     71 	/sbin/cryptsetup luksClose usb
     72 	}
     73 
     74 cleanUp() {
     75 	text "Cleaning up..."
     76 	umount /proc
     77 	umount /sys
     78 	umount /dev
     79 }
     80 
     81 bootUp() {
     82 	text "Switching root..."
     83 	exec switch_root /mnt/gentoo /sbin/init
     84 }
     85 
     86 setUp
     87 prepareStick
     88 prepareDisk
     89 closeStick
     90 cleanUp
     91 bootUp