Last active
August 16, 2018 21:22
-
-
Save cairesvs/2081f310b73b09db08e7d2e5f1a254de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
PURPLE="\033[1;30;45m install \033[1;35;49m " | |
RESET="\033[0m" | |
USRNAME=${USRNAME:-caires} | |
HOSTNAME=${HOSTNAME:-caires} | |
HOME_DIR=/home/$USRNAME | |
echo -e "${PURPLE}Brazil mirrors${RESET}" | |
grep -A 2 Brazil /etc/pacman.d/mirrorlist > mirrorlist.br | |
cp mirrorlist.br /etc/pacman.d/mirrorlist | |
set -e | |
echo -e "${PURPLE}Formatting disks${RESET}" | |
CREATE_EFI_SYSTEM="g\nn\n\n\n+512M\nt\n1\n" | |
CREATE_LINUX_SYSTEM="n\n\n\n\nw\n" | |
if [ -z "$SKIP_DISK" ]; then | |
if [ -z "$USE_MBR" ]; then | |
echo -e "${CREATE_EFI_SYSTEM}${CREATE_LINUX_SYSTEM}" | fdisk /dev/nvme0n1 | |
else | |
echo -e "o\nn\np\n\n\n+512M\nn\np\n\n\n\nw\n" | fdisk /dev/nvme0n1 | |
fi | |
echo -e "${PURPLE}Setting up cryptography${RESET}" | |
mkfs.vfat -F32 /dev/nvme0n1p1 | |
cryptsetup -v luksFormat /dev/nvme0n1p2 | |
cryptsetup luksOpen /dev/nvme0n1p2 luks | |
pvcreate /dev/mapper/luks | |
vgcreate vg0 /dev/mapper/luks | |
lvcreate -L 4G vg0 -n swap | |
lvcreate -l +100%FREE vg0 -n root | |
mkfs.ext4 /dev/mapper/vg0-root | |
mkswap /dev/mapper/vg0-swap | |
mount /dev/mapper/vg0-root /mnt | |
swapon /dev/mapper/vg0-swap | |
mkdir /mnt/boot | |
mount /dev/nvme0n1p1 /mnt/boot | |
export INSTALL_DEVICE_UUID=$(blkid /dev/nvme0n1p1 | awk ' { print $2 } ' | sed s/\"//g) | |
echo $INSTALL_DEVICE_UUID > ./sda-device-uuid | |
echo -e "${PURPLE}Device UUID${RESET} Your device UUID is stored at ./sda-device-uuid" | |
fi | |
echo -e "${PURPLE}Bootstrapping packages${RESET}" | |
pacstrap /mnt base base-devel git wpa_supplicant iw dialog wpa_actiond | |
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist | |
echo -e "${PURPLE}Gen fstab${RESET}" | |
genfstab -U /mnt >> /mnt/etc/fstab | |
echo -e "${PURPLE}Clock stuff${RESET}" | |
arch-chroot /mnt rm -f /etc/localtime | |
arch-chroot /mnt ln -s /usr/share/zoneinfo/Brazil/East /etc/localtime | |
arch-chroot /mnt hwclock --systohc --utc | |
echo -e "${PURPLE}Locale stuff${RESET}" | |
sed -i s/#en_US\.UTF-8/en_US.UTF-8/ /mnt/etc/locale.gen | |
echo LANG=en_US.UTF-8 > /mnt/etc/locale.conf | |
echo $HOSTNAME > /mnt/etc/hostname | |
echo -e "${PURPLE}Making vmlinuz${RESET}" | |
sed -i "/^HOOKS/s/filesystems/encrypt filesystems/" /mnt/etc/mkinitcpio.conf | |
arch-chroot /mnt mkinitcpio -p linux | |
echo -e "${PURPLE}Set root password${RESET}" | |
arch-chroot /mnt passwd | |
echo -e "${PURPLE}Setting up $USRNAME${RESET}" | |
arch-chroot /mnt useradd -m -g users -G wheel,storage,power -s /bin/bash $USRNAME | |
echo -e "${PURPLE}Set $USRNAME password${RESET}" | |
arch-chroot /mnt passwd $USRNAME | |
if [ -z "$USE_MBR" ]; then | |
echo -e "${PURPLE}Configuring bootloader (bootctl)${RESET}" | |
arch-chroot /mnt bootctl --path=/boot install | |
arch-chroot /mnt cp -f /usr/share/systemd/bootctl/loader.conf /boot/loader/loader.conf | |
echo "editor 0" >> /mnt/boot/loader/loader.conf | |
arch-chroot /mnt bash -c "echo -e \"title Arch Linux\nlinux /vmlinuz-linux\ninitrd /initramfs-linux.img\noptions cryptdevice=UUID=${INSTALL_DEVICE_UUID}:lvm:allow-discards resume=/dev/mapper/vg0-swap root=/dev/mapper/vg0-root rw quiet\" > /boot/loader/entries/arch.conf" | |
else | |
echo -e "${PURPLE}Bootloader not configured${RESET} Given it's a MBR setup, you'll have to configure the bootloader manually." | |
fi | |
echo -e "${PURPLE}Done!${RESET} Instalation finished!" | |
set +e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment