HOSTNAME="ELFLaptop" UEFI_DISK="/dev/sdb" DISK="/dev/sda" USERNAME="freenen" 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 10 } echo >>install.log } function run-chroot(){ echo "[ ] $1" echo "# $1" >>install.log echo "> chroot /mnt $2" >>install.log arch-chroot /mnt 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 20 } 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 1 fi echo -n "password for freenen: " read -s PASS echo echo -n "retype password: " read -s PASSRE echo if [ "$PASS" != "$PASSRE" ]; then echo "password do not match" exit 2 fi echo 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 === set locals echo run-chroot "set timezone" "ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime" run-chroot "set hwclock to UTC" "hwclock --systohc" run-chroot "generate locals" "locale-gen" run-chroot "config locals" "echo \"LANG=en_GB.UTF-8\" >/etc/locale.conf" run-chroot "set hostname" "echo \"$HOSTNAME\" >/etc/hostname" run-chroot "create hosts file" "cat >/etc/hosts </boot/loader/entries/arch.conf </boot/loader/entries/arch-fallback.conf </boot/loader/loader.conf <>/etc/sudoers" run-chroot "touch authoized keys" "touch /home/${USERNAME}/.ssh/authorized_keys" run-chroot "add sshkeys for new user" "curl -o /home/${USERNAME}/.ssh/authorized_keys https://github.com/FReenen.keys" echo echo === umount and reboot echo run "umount drives" "umount -R /mnt" run "close cryptroot" "cryptsetup close cryptroot" run "reboot" "shutdown -r now"