ElfOS/elfLaptop.sh
FReenen 8b16854029 Revert "combine main and in-boot script and update vscode installer"
This reverts commit 3548086c29a3b4b1c6912a6d438a8a511ce22194.
2024-11-29 17:35:02 +01:00

85 lines
2.6 KiB
Bash

HOSTNAME="ELFLaptop"
UEFI_DISK="/dev/sdb"
DISK="/dev/sda"
UEFI_PARTITION="${UEFI_DISK}1"
SWAP_PARTITION="${DISK}3"
ROOT_PARTITION="${DISK}4"
function run(){
echo "[ ] $1"
echo "# $1" >>install.log
echo "> $2" >>install.log
bash -c "$2" &>>install.log \
&& echo -e "\e[1A\e[K[ \e[32mOK\e[0m ] $1" \
|| {
echo -e "\e[1A\e[K[\e[31mFAIL\e[0m] $1"
bash -c "$3"
exit
}
echo >>install.log
}
echo "" >install.log
echo -n "disk encryption password: "
read -s PASS
echo
echo -n "retype password: "
read -s PASSRE
echo
if [ "$PASS" != "$PASSRE" ]; then
echo "password do not match"
exit
fi
echo
echo === setup localisation
echo
run "enable ntp" "timedatectl set-ntp true"
run "set timezone" "timedatectl set-timezone Europe/Amsterdam"
echo
echo === setup partitions
echo
#run "applly partion table" "sfdisk $DISK <./elfLaptop.sfdisk"
run "format boot partition" "mkfs.fat -F 32 ${UEFI_PARTITION}"
run "format swap partition" "mkswap ${SWAP_PARTITION}"
echo -n "$PASS" >keyfile.luks
run "encrypt root partition" "cryptsetup luksFormat --batch-mode --key-file keyfile.luks ${ROOT_PARITION}" "rm keyfile.luks"
run "map root partitaion" "cryptsetup open --batch-mode --key-file keyfile.luks ${ROOT_PARTITION} cryptroot" "rm keyfile.luks"
rm keyfile.luks
run "format root partition" "mkfs.btrfs /dev/mapper/cryptroot"
run "mount root partition" "mount /dev/mapper/cryptroot /mnt"
run "create root btrfs subvolume" "btrfs subvolume create /mnt/@"
run "create home btrfs subvolume" "btrfs subvolume create /mnt/@home"
run "unmount btrfs" "umount /mnt"
run "mount root subvolume" "mount -o subvol=@ /dev/mapper/cryptroot /mnt"
run "mount boot partition" "mount --mkdir ${UEFI_PARITION} /mnt/boot"
run "mount home subvolume" "mount --mkdir -o subvol=@home /dev/mapper/cryptroot /mnt/home"
run "enable swap" "swapon ${SWAP_PARTITION}"
echo
echo === install arch
echo
run "install base of arch" "pacstrap /mnt base linux linux-firmware"
run "intall utitlities" "pacstrap /mnt btrfs-progs man vim sudo"
run "generate fstab" "genfstab -U /mnt >>/mnt/etc/fstab"
run "copy in-root script" "cp in-root.sh /mnt/root"
echo
echo === chroot config
echo
arch-chroot /mnt bash /root/in-root.sh "$HOSTNAME" "$DISK" || exit
run "umount drives" "umount -R /mnt"
run "close cryptroot" "cryptsetup close cryptroot"
run "reboot" "shutdown -r now"