Update install.sh

This commit is contained in:
proledatarian 2022-02-13 23:37:10 +00:00
parent 0e32eb30ec
commit 08b250784e
1 changed files with 89 additions and 53 deletions

View File

@ -1,7 +1,20 @@
#!/bin/bash
#PS3="Please select a disk to partition:"
# Friendly introduction.
echo "Welcome to the Arch Linux installation script!"
echo "This script will ERASE ALL DATA on the partition you choose in the next step."
echo
read -p "Do you want to continue? Type [Y]es or [N]o. " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
# Partitioning.
echo
echo "Please select a disk to partition:"
echo
# Don't separate values by space.
IFS=$'\n'
@ -22,79 +35,67 @@ IFS=' '
# Create new variable of selection.
array=($disk)
dev="${array[0]}"
echo -e
echo
# Starting partitioning.
echo "Partitioning /dev/$dev.."
echo -e
echo
# Clearing partition table of selected disk.
echo "Clearing existing partitioning table."
sgdisk -Z /dev/$dev &&
echo -e
echo
# Creating boot partition.
size="${array[1]%?}"
echo "Creating boot partition of 256 MB."
sgdisk -n 1:0:+256M /dev/$dev &&
echo
# Setting type for EFI.
sgdisk -t 1:ef00 /dev/$dev &&
echo -e
# Creating system partition.
echo "Creating system partition of $size GB."
sgdisk -n 2:0:0 /dev/$dev
echo -e
echo
# Print partitions.
echo "This is your new partition table:"
lsblk | grep "$dev"
sleep 1
echo
# This needs to be deleted.
echo $dev > /tmp/disk
# Exit.
break
done
# This needs to be deleted.
# Get variable from filesystem.
part=$(</tmp/disk)2
# Encrypting partition.
echo "Encrypting system partition."
echo -e
echo "Encrypting system partition. This might take a while."
echo
cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/$part &&
echo "Partition successfully encrypted."
echo -e
echo
# Opening encrypted partition and mounting at /dev/mapper/lvm.
echo "Opening and mounting encrypted partition."
echo -e
echo "Decrypting.. This might take a while."
echo -e
echo "Decrypting.. This also might take a while."
echo
cryptsetup luksOpen /dev/$part lvm &&
echo "Partition opened and mounted:"
echo -e
echo "Partition successfully opened."
echo
disk="${part%?}"
lsblk | grep "$disk"
echo -e
echo
# Creating physical volume.
echo "Creating physical volume."
pvcreate /dev/mapper/lvm &&
echo -e
# Creating volume group "main".
echo "Creating volume group."
vgcreate main /dev/mapper/lvm &&
echo -e
# Creating logical volumes.
echo "Creating logical volumes for root and home."
echo -e
# Lol, this part:
part=$(</tmp/disk)2 && i=( $(lsblk | grep "$part" | tail -n+1 | awk '{print $4}') ) && size="${i%?}"
@ -102,35 +103,70 @@ part=$(</tmp/disk)2 && i=( $(lsblk | grep "$part" | tail -n+1 | awk '{print $4}'
echo "Your system partition has a size of $size GB."
echo "What size should your root partition have?"
read root
echo "Creating a $root GB root volume."
echo -e
echo "Creating a $root GB root volume.."
echo
# Ask for everything that is necessary later.
echo "Before installing the system, please enter a hostname:"
echo
read host
echo
echo "Please enter a password for the root account:"
read pwr
echo
echo "And please enter a username:"
read user
echo
echo "Also please enter a password for your user:"
read pwu
echo
echo "System is getting installed.."
echo
# Creating physical volume.
echo "Creating physical volume."
pvcreate /dev/mapper/lvm &&
echo
# Creating volume group "main".
echo "Creating volume group."
vgcreate main /dev/mapper/lvm &&
echo
# Creating logical volumes.
echo "Creating logical volumes for root and home."
echo
lvcreate -L ${root}G -n root main &&
lvcreate -l 100%FREE -n home main &&
echo -e
echo
echo "Logical volumes successfully created."
echo -e
echo
echo "Creating the filesystem."
echo -e
echo
boot=$(</tmp/disk)1
mkfs.fat -F 32 -n UEFI /dev/$boot &&
echo "Filesystem for boot successfully created."
echo -e
echo
mkfs.ext4 -L root /dev/mapper/main-root &&
echo "Filesystem for root successfully created."
echo -e
echo
mkfs.ext4 -L home /dev/mapper/main-home &&
echo "Filesystem for home successfully created."
echo -e
echo
echo "Mounting.."
echo -e
echo
mount /dev/mapper/main-root /mnt
mkdir /mnt/boot
@ -139,27 +175,27 @@ mount /dev/$boot /mnt/boot
mount /dev/mapper/main-home /mnt/home
echo "Mounting complete."
echo -e
echo
lsblk
echo -e
echo
# Updating mirrors using reflector.
echo "Updating mirrors.."
echo -e
echo
#reflector --verbose --latest 10 --country Germany --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
reflector --verbose --latest 10 --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist &&
echo -e
echo
echo "Done."
# Installing base system.
echo "Installing basic packages.."
echo -e
echo
#pacstrap /mnt base base-devel firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm &&
pacstrap /mnt base firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm sudo &&
echo -e
echo
echo "Base system installed."
echo -e
echo
# Generating fstab.
echo "Generating fstab."
@ -174,7 +210,7 @@ echo "Hostname set."
# Setting locale.
echo "Setting and generating locale."
echo -e
echo
#localegen=$(cat /mnt/etc/locale.gen)
cat <<EOF >/mnt/etc/locale.gen
en_US.UTF-8 UTF-8
@ -184,28 +220,28 @@ EOF
arch-chroot /mnt locale-gen
echo "LANG=de_DE.UTF-8" >/mnt/etc/locale.conf
echo "KEYMAP=de-latin1" > /mnt/etc/vconsole.conf
echo -e
echo
echo "Done."
# Editing mkinitcpio.conf.
echo "Editing /etc/mkinitcpio.conf."
echo -e
echo
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf &&
sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf &&
echo -e
echo
echo "Done."
# Creating inital ramdisk.
echo "Creating inital ramdisk for linux-zen."
echo -e
echo
arch-chroot /mnt mkinitcpio -p linux-zen &&
echo "Done."
# Enable network and display manager.
echo "Enabling Networkmanager and display manager (sddm)."
echo -e
echo
arch-chroot /mnt systemctl enable NetworkManager sddm &&
echo -e
echo
echo "Done."
echo "Setting root password:"