Cleaning up and adding documentation.

This commit is contained in:
proledatarian 2022-02-15 17:00:02 +00:00
parent fb7e77c25f
commit d6c942f7df
1 changed files with 82 additions and 58 deletions

View File

@ -21,12 +21,13 @@ echo
read -p "Do you want to continue? Type [Y]es or [N]o. " -n 1 -r read -p "Do you want to continue? Type [Y]es or [N]o. " -n 1 -r
echo # (optional) move to a new line echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]] if [[ ! $REPLY =~ ^[Yy]$ ]]
then thenarne
exit 1 exit 1
fi fi
echo echo
# Selecting disk. # Selecting disk.
echo "1. PARTITIONING"
echo "Please select a disk to partition:" echo "Please select a disk to partition:"
echo echo
@ -45,6 +46,7 @@ do
break break
done done
echo
# Separate values by spaces. # Separate values by spaces.
IFS=' ' IFS=' '
@ -56,10 +58,13 @@ szmn="${array[1]%?}"
# Setting partition size. # Setting partition size.
echo "Your system partition has a size of $szmn GB." echo "Your system partition has a size of $szmn GB."
echo "What size should your root partition have?" echo "What size should your root partition have (GB) ?"
read szrt read szrt
echo echo
echo "2. ENCRYPTION"
echo
# Setting encryption password. # Setting encryption password.
echo "Choose a strong password for encrypting the primary partition:" echo "Choose a strong password for encrypting the primary partition:"
while [ -z "$pwcr" ]; do while [ -z "$pwcr" ]; do
@ -79,11 +84,17 @@ break
done done
echo echo
echo "3. HOSTNAME"
echo
# Setting hostname. # Setting hostname.
echo "Before installing the system, please enter a hostname:" echo "Before installing the system, please enter a hostname:"
read host read host
echo echo
echo "4. ROOT PASSWORD"
echo
# Setting root password. # Setting root password.
echo "Choose a password for the root account:" echo "Choose a password for the root account:"
while [ -z "$pwr" ]; do while [ -z "$pwr" ]; do
@ -103,8 +114,11 @@ break
done done
echo echo
echo "4. USER"
echo
# Setting username # Setting username
echo "And please enter a username:" echo "Please enter a username:"
read user read user
echo echo
@ -126,8 +140,9 @@ fi
break break
done done
echo
echo "System is getting installed.." echo "5. INSTALLING SYSTEM.."
echo echo
# Starting partitioning. # Starting partitioning.
@ -164,7 +179,6 @@ main=${dev}2
# Encrypting partition. # Encrypting partition.
echo "Encrypting system partition. This might take a while." echo "Encrypting system partition. This might take a while."
echo echo
echo -en "$pwcr\n$pwcr" | cryptsetup -c aes-xts-plain -s 512 luksFormat /dev/$main && echo -en "$pwcr\n$pwcr" | cryptsetup -c aes-xts-plain -s 512 luksFormat /dev/$main &&
echo "Partition successfully encrypted." echo "Partition successfully encrypted."
echo echo
@ -179,9 +193,6 @@ echo
lsblk | grep "$dev" lsblk | grep "$dev"
echo echo
# Lol, this part:
#main=$(</tmp/dev)2 && i=( $(lsblk | grep "$main" | tail -n+1 | awk '{print $4}') ) && szmn="${i%?}"
# Creating physical volume. # Creating physical volume.
echo "Creating physical volume." echo "Creating physical volume."
pvcreate /dev/mapper/lvm && pvcreate /dev/mapper/lvm &&
@ -194,20 +205,13 @@ echo
# Creating logical volumes. # Creating logical volumes.
echo "Creating logical volumes for root and home." echo "Creating logical volumes for root and home."
echo
lvcreate -L ${szrt}G -n root main && lvcreate -L ${szrt}G -n root main &&
lvcreate -l 100%FREE -n home main && lvcreate -l 100%FREE -n home main &&
echo
echo "Logical volumes successfully created." echo "Logical volumes successfully created."
echo echo
echo "Creating the filesystem." echo "Creating the filesystem."
echo
boot=${dev}1 boot=${dev}1
mkfs.fat -F 32 -n UEFI /dev/$boot && mkfs.fat -F 32 -n UEFI /dev/$boot &&
echo "Filesystem for boot successfully created." echo "Filesystem for boot successfully created."
echo echo
@ -218,37 +222,32 @@ echo
mkfs.ext4 -L home /dev/mapper/main-home && mkfs.ext4 -L home /dev/mapper/main-home &&
echo "Filesystem for home successfully created." echo "Filesystem for home successfully created."
echo "Done."
echo echo
echo "Mounting.." echo "Mounting.."
echo mount /dev/mapper/main-root /mnt &&
mkdir /mnt/boot &&
mount /dev/mapper/main-root /mnt mkdir /mnt/home &&
mkdir /mnt/boot mount /dev/$boot /mnt/boot &&
mkdir /mnt/home mount /dev/mapper/main-home /mnt/home &&
mount /dev/$boot /mnt/boot
mount /dev/mapper/main-home /mnt/home
echo "Mounting complete." echo "Mounting complete."
echo echo
lsblk lsblk | grep "$dev"
echo echo
# Updating mirrors using reflector. # Updating mirrors using reflector.
echo "Updating mirrors.." echo "Updating mirrors.."
echo reflector --verbose --latest 10 --country Germany --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist &&
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 && #reflector --verbose --latest 10 --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist &&
echo
echo "Done." echo "Done."
echo
# Installing base system. # Installing base system.
echo "Installing basic packages.." echo "Installing basic packages.."
echo
#pacstrap /mnt base base-devel firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm && #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 nano networkmanager plasma-desktop sddm sddm-kcm sudo && pacstrap /mnt base firefox konsole linux linux-firmware linux-zen lvm2 nano networkmanager plasma-desktop sddm sddm-kcm sudo &&
echo
echo "Base system installed." echo "Base system installed."
echo echo
@ -256,14 +255,16 @@ echo
echo "Generating fstab." echo "Generating fstab."
genfstab -Up /mnt > /mnt/etc/fstab && genfstab -Up /mnt > /mnt/etc/fstab &&
echo "Installed fstab." echo "Installed fstab."
echo
# Setting hostname. # Setting hostname.
echo $host > /mnt/etc/hostname echo "Setting hostname"
echo "Hostname set." echo $host > /mnt/etc/hostname &&
echo "Done."
echo
# Setting locale. # Setting locale.
echo "Setting and generating locale." echo "Setting and generating locale."
echo
#localegen=$(cat /mnt/etc/locale.gen) #localegen=$(cat /mnt/etc/locale.gen)
cat <<EOF >/mnt/etc/locale.gen cat <<EOF >/mnt/etc/locale.gen
en_US.UTF-8 UTF-8 en_US.UTF-8 UTF-8
@ -271,42 +272,47 @@ en_US.UTF-8 UTF-8
EOF EOF
#echo "${localegen}" >>/mnt/etc/locale.gen #echo "${localegen}" >>/mnt/etc/locale.gen
arch-chroot /mnt locale-gen arch-chroot /mnt locale-gen
echo "LANG=en_US.UTF-8" >/mnt/etc/locale.conf echo "LANG=en_US.UTF-8" >/mnt/etc/locale.conf &&
#echo "LANG=de_DE.UTF-8" >/mnt/etc/locale.conf #echo "LANG=de_DE.UTF-8" >/mnt/etc/locale.conf
echo "KEYMAP=de-latin1" > /mnt/etc/vconsole.conf echo "KEYMAP=de-latin1" > /mnt/etc/vconsole.conf &&
echo
echo "Done." echo "Done."
echo
# Editing mkinitcpio.conf. # Editing mkinitcpio.conf.
echo "Editing /etc/mkinitcpio.conf." echo "Editing /etc/mkinitcpio.conf."
echo echo
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf && 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 && sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf &&
echo
echo "Done." echo "Done."
echo
# Creating inital ramdisk. # Creating inital ramdisk.
echo "Creating inital ramdisk for linux-zen." echo "Creating inital ramdisk for linux-zen."
echo
arch-chroot /mnt mkinitcpio -p linux-zen && arch-chroot /mnt mkinitcpio -p linux-zen &&
echo "Done." echo "Done."
echo
# Enable network and display manager. # Enable network and display manager.
echo "Enabling Networkmanager and display manager (sddm)." echo "Enabling Networkmanager and display manager (sddm)."
echo
arch-chroot /mnt systemctl enable NetworkManager sddm && arch-chroot /mnt systemctl enable NetworkManager sddm &&
echo
echo "Done." echo "Done."
echo
# Set root password # Set root password
echo "Setting root password:" echo "Setting root password:"
echo -en "$pwrt\n$pwrt" | arch-chroot /mnt passwd echo -en "$pwrt\n$pwrt" | arch-chroot /mnt passwd
echo "Done."
echo
# Install bootloader. # Install bootloader.
arch-chroot /mnt bootctl install echo "Installing systemd-boot."
arch-chroot /mnt bootctl install &&
echo "Done."
echo
# Set bootloader entry. # Set bootloader entry.
cat << EOF > /mnt/boot/loader/entries/arch.conf echo "Setting up bootloader."
cat << EOF > /mnt/boot/loader/entries/arch.conf &&
title Arch Linux title Arch Linux
linux /vmlinuz-linux-zen linux /vmlinuz-linux-zen
#initrd /amd-ucode.img #initrd /amd-ucode.img
@ -320,7 +326,7 @@ options init=/usr/lib/systemd/systemd
EOF EOF
# Set bootloader fallback entry. # Set bootloader fallback entry.
cat << EOF > /mnt/boot/loader/entries/arch-fallback.conf cat << EOF > /mnt/boot/loader/entries/arch-fallback.conf &&
title Arch Linux Fallback title Arch Linux Fallback
linux /vmlinuz-linux linux /vmlinuz-linux
initrd /initramfs-linux-fallback.img initrd /initramfs-linux-fallback.img
@ -331,18 +337,16 @@ options init=/usr/lib/systemd/systemd
EOF EOF
# Set bootloader. # Set bootloader.
echo "timeout 1" >> /mnt/boot/loader/loader.conf echo "timeout 1" >> /mnt/boot/loader/loader.conf &&
echo "default arch.conf" >> /mnt/boot/loader/loader.conf echo "default arch.conf" >> /mnt/boot/loader/loader.conf &&
echo "Done."
echo
# Set X locale. # Set X locale and keyboard alyout.
arch-chroot /mnt localectl --no-convert set-keymap de-latin1-nodeadkeys echo "Setting locale and keyboard layout."
arch-chroot /mnt localectl --no-convert set-keymap de-latin1-nodeadkeys &&
# Set username, password and group. cat << EOF > /mnt//etc/X11/xorg.conf.d/00-keyboard.conf &&
arch-chroot /mnt useradd -m $user &&
echo -en "$pwur\n$pwur" | arch-chroot /mnt passwd $user &&
arch-chroot /mnt gpasswd -a $user wheel
cat << EOF > /mnt//etc/X11/xorg.conf.d/00-keyboard.conf
# Written by systemd-localed(8), read by systemd-localed and Xorg. It's # Written by systemd-localed(8), read by systemd-localed and Xorg. It's
# probably wise not to edit this file manually. Use localectl(1) to # probably wise not to edit this file manually. Use localectl(1) to
# instruct systemd-localed to update it. # instruct systemd-localed to update it.
@ -354,15 +358,35 @@ Section "InputClass"
Option "XkbVariant" "deadgraveacute" Option "XkbVariant" "deadgraveacute"
EndSection EndSection
EOF EOF
echo "Done."
echo
# Set username, password and group.
echo "Adding user."
arch-chroot /mnt useradd -m $user &&
echo -en "$pwur\n$pwur" | arch-chroot /mnt passwd $user &&
arch-chroot /mnt gpasswd -a $user wheel &&
sed -i '82s/.*/%wheel ALL=(ALL) ALL/' /mnt/etc/sudoers sed -i '82s/.*/%wheel ALL=(ALL) ALL/' /mnt/etc/sudoers
echo "Done."
echo
mkdir /mnt/etc/sddm.conf.d # Enabling sddm auto-login.
echo "Enabling auto-login."
mkdir /mnt/etc/sddm.conf.d &&
cat << EOF > /mnt/etc/sddm.conf.d/autologin.conf
[Autologin]
User=$user
Session=plasma
EOF
echo "Done."
echo
echo "[Autologin]" >> /mnt/etc/sddm.conf.d/autologin.conf # Unmounting and rebooting.
echo "User=$user" >> /mnt/etc/sddm.conf.d/autologin.conf echo "Unmounting system."
echo "Session=plasma" >> /mnt/etc/sddm.conf.d/autologin.conf umount /mnt/boot &&
umount /mnt/home &&#
echo "Done."
echo
umount /mnt/boot echo "Rebooting"
umount /mnt/home
reboot reboot