chroot.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. while true; do
  3. passwd && break
  4. done
  5. TZuser=$(cat tzfinal.tmp)
  6. DRIVE=$(cat drive)
  7. PVALUE=$(echo "${DRIVE}" | grep "^nvme" | sed 's/.*[0-9]/p/')
  8. echo KEYMAP=de_CH-latin1 > /etc/vconsole.conf
  9. ln -sf /usr/share/zoneinfo/"$TZuser" /etc/localtime
  10. hwclock --systohc
  11. echo "LANG=en_GB.UTF-8" >> /etc/locale.conf
  12. echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen
  13. locale-gen
  14. pacman --noconfirm --needed -S networkmanager
  15. systemctl enable NetworkManager
  16. ls /sys/firmware/efi/efivars && EFI=yes
  17. if [ "$EFI" = "yes" ]; then
  18. SWAP_LETTER="2"
  19. ROOT_LETTER="3"
  20. else
  21. SWAP_LETTER="1"
  22. ROOT_LETTER="2"
  23. fi
  24. dd bs=512 count=4 if=/dev/urandom of=/crypto_keyfile.bin
  25. while true; do
  26. cryptsetup luksAddKey /dev/"${DRIVE}${PVALUE}${ROOT_LETTER}" /crypto_keyfile.bin &&
  27. break
  28. done
  29. chmod 000 /crypto_keyfile.bin
  30. sed -i 's/FILES=()/FILES=(\/crypto_keyfile.bin)/' /etc/mkinitcpio.conf
  31. sed -i 's/block filesystems/block encrypt filesystems/' /etc/mkinitcpio.conf
  32. mkinitcpio -P
  33. pacman --noconfirm --needed -S grub
  34. sed -i "s/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=\/dev\/${DRIVE}${PVALUE}${ROOT_LETTER}:cryptroot\"/" /etc/default/grub
  35. sed -i 's/#GRUB_ENABLE_CRYPTODISK/GRUB_ENABLE_CRYPTODISK/' /etc/default/grub
  36. echo "swap /dev/${DRIVE}${PVALUE}${SWAP_LETTER} /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256" >> /etc/crypttab
  37. if [ "$EFI" = "yes" ]; then
  38. pacman -S grub efibootmgr
  39. mkdir /boot/efi
  40. mount /dev/"${DRIVE}${PVALUE}1" /boot/efi
  41. grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi
  42. else
  43. grub-install --target=i386-pc /dev/"${DRIVE}" --recheck
  44. grub-mkconfig -o /boot/grub/grub.cfg
  45. fi
  46. rm drive tzfinal.tmp