mirror of
https://github.com/classy-giraffe/easy-arch.git
synced 2025-11-17 11:30:55 +00:00
Pretty print.
This commit is contained in:
parent
61617beb60
commit
e522bc1090
1 changed files with 38 additions and 26 deletions
64
easy-arch.sh
64
easy-arch.sh
|
|
@ -3,7 +3,12 @@
|
|||
# Cleaning the TTY.
|
||||
clear
|
||||
|
||||
# Selecting a kernel to install.
|
||||
# Pretty print (function).
|
||||
print () {
|
||||
echo -e "\e[1m\e[93m[ \e[92m•\e[93m ] \e[4m$1\e[0m"
|
||||
}
|
||||
|
||||
# Selecting a kernel to install (function).
|
||||
kernel_selector () {
|
||||
echo "List of kernels:"
|
||||
echo "1) Stable — Vanilla Linux kernel and modules, with a few patches applied."
|
||||
|
|
@ -26,7 +31,7 @@ kernel_selector () {
|
|||
esac
|
||||
}
|
||||
|
||||
# Selecting a way to handle internet connection.
|
||||
# Selecting a way to handle internet connection (function).
|
||||
network_selector () {
|
||||
echo "Network utilities:"
|
||||
echo "1) IWD — iNet wireless daemon is a wireless daemon for Linux written by Intel (WiFi-only)."
|
||||
|
|
@ -73,7 +78,7 @@ PS3="Select the disk where Arch Linux is going to be installed: "
|
|||
select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd");
|
||||
do
|
||||
DISK=$ENTRY
|
||||
echo "Installing Arch Linux on $DISK."
|
||||
print "Installing Arch Linux on $DISK."
|
||||
break
|
||||
done
|
||||
|
||||
|
|
@ -85,12 +90,12 @@ then
|
|||
wipefs -af "$DISK" &>/dev/null
|
||||
sgdisk -Zo "$DISK" &>/dev/null
|
||||
else
|
||||
echo "Quitting."
|
||||
print "Quitting."
|
||||
exit
|
||||
fi
|
||||
|
||||
# Creating a new partition scheme.
|
||||
echo "Creating new partition scheme on $DISK."
|
||||
print "Creating new partition scheme on $DISK."
|
||||
parted -s "$DISK" \
|
||||
mklabel gpt \
|
||||
mkpart ESP fat32 1MiB 513MiB \
|
||||
|
|
@ -101,27 +106,27 @@ ESP="/dev/disk/by-partlabel/ESP"
|
|||
Cryptroot="/dev/disk/by-partlabel/Cryptroot"
|
||||
|
||||
# Informing the Kernel of the changes.
|
||||
echo "Informing the Kernel about the disk changes."
|
||||
print "Informing the Kernel about the disk changes."
|
||||
partprobe "$DISK"
|
||||
|
||||
# Formatting the ESP as FAT32.
|
||||
echo "Formatting the EFI Partition as FAT32."
|
||||
print "Formatting the EFI Partition as FAT32."
|
||||
mkfs.fat -F 32 $ESP &>/dev/null
|
||||
|
||||
# Creating a LUKS Container for the root partition.
|
||||
echo "Creating LUKS Container for the root partition"
|
||||
print "Creating LUKS Container for the root partition"
|
||||
cryptsetup luksFormat $Cryptroot
|
||||
echo "Opening the newly created LUKS Container."
|
||||
print "Opening the newly created LUKS Container."
|
||||
cryptsetup open $Cryptroot cryptroot
|
||||
BTRFS="/dev/mapper/cryptroot"
|
||||
|
||||
# Formatting the LUKS Container as BTRFS.
|
||||
echo "Formatting the LUKS container as BTRFS."
|
||||
print "Formatting the LUKS container as BTRFS."
|
||||
mkfs.btrfs $BTRFS &>/dev/null
|
||||
mount $BTRFS /mnt
|
||||
|
||||
# Creating BTRFS subvolumes.
|
||||
echo "Creating BTRFS subvolumes."
|
||||
print "Creating BTRFS subvolumes."
|
||||
btrfs su cr /mnt/@ &>/dev/null
|
||||
btrfs su cr /mnt/@home &>/dev/null
|
||||
btrfs su cr /mnt/@snapshots &>/dev/null
|
||||
|
|
@ -129,7 +134,7 @@ btrfs su cr /mnt/@var_log &>/dev/null
|
|||
|
||||
# Mounting the newly created subvolumes.
|
||||
umount /mnt
|
||||
echo "Mounting the newly created subvolumes."
|
||||
print "Mounting the newly created subvolumes."
|
||||
mount -o ssd,noatime,space_cache,compress=zstd,subvol=@ $BTRFS /mnt
|
||||
mkdir -p /mnt/{home,.snapshots,/var/log,boot}
|
||||
mount -o ssd,noatime,space_cache=v2,compress=zstd,discard=async,subvol=@home $BTRFS /mnt/home
|
||||
|
|
@ -141,13 +146,13 @@ mount $ESP /mnt/boot/
|
|||
kernel_selector
|
||||
|
||||
# Pacstrap (setting up a base sytem onto the new root).
|
||||
echo "Installing the base system (it may take a while)."
|
||||
print "Installing the base system (it may take a while)."
|
||||
pacstrap /mnt base $kernel $microcode linux-firmware btrfs-progs grub grub-btrfs efibootmgr snapper reflector base-devel snap-pac zram-generator
|
||||
|
||||
network_selector
|
||||
|
||||
# Generating /etc/fstab.
|
||||
echo "Generating a new fstab."
|
||||
print "Generating a new fstab."
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
|
||||
# Setting hostname.
|
||||
|
|
@ -167,7 +172,7 @@ read -r -p "Please insert the keyboard layout you use: " kblayout
|
|||
echo "KEYMAP=$kblayout" > /mnt/etc/vconsole.conf
|
||||
|
||||
# Setting hosts file.
|
||||
echo "Setting hosts file."
|
||||
print "Setting hosts file."
|
||||
cat > /mnt/etc/hosts <<EOF
|
||||
127.0.0.1 localhost
|
||||
::1 localhost
|
||||
|
|
@ -175,10 +180,11 @@ cat > /mnt/etc/hosts <<EOF
|
|||
EOF
|
||||
|
||||
# Configuring /etc/mkinitcpio.conf.
|
||||
echo "Configuring /etc/mkinitcpio.conf for LUKS hook."
|
||||
print "Configuring /etc/mkinitcpio.conf for LUKS hook."
|
||||
sed -i -e 's,modconf block filesystems keyboard,keyboard keymap modconf block encrypt filesystems,g' /mnt/etc/mkinitcpio.conf
|
||||
|
||||
# Setting up LUKS2 encryption and apparmor.
|
||||
# Setting up LUKS2 encryption in grub.
|
||||
print "Setting up grub config."
|
||||
UUID=$(blkid $Cryptroot | cut -f2 -d'"')
|
||||
sed -i "s,quiet,quiet cryptdevice=UUID=$UUID:cryptroot root=$BTRFS,g" /mnt/etc/default/grub
|
||||
|
||||
|
|
@ -190,12 +196,15 @@ arch-chroot /mnt /bin/bash -e <<EOF
|
|||
|
||||
# Setting up clock.
|
||||
hwclock --systohc
|
||||
|
||||
# Generating locales.
|
||||
echo "Generating locales."
|
||||
locale-gen &>/dev/null
|
||||
|
||||
# Generating a new initramfs.
|
||||
echo "Creating a new initramfs."
|
||||
mkinitcpio -P &>/dev/null
|
||||
|
||||
# Snapper configuration
|
||||
umount /.snapshots
|
||||
rm -r /.snapshots
|
||||
|
|
@ -204,13 +213,15 @@ arch-chroot /mnt /bin/bash -e <<EOF
|
|||
mkdir /.snapshots
|
||||
mount -a
|
||||
chmod 750 /.snapshots
|
||||
|
||||
# Installing GRUB.
|
||||
echo "Installing GRUB on /boot."
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=GRUB &>/dev/null
|
||||
|
||||
|
||||
# Creating grub config file.
|
||||
echo "Creating GRUB config file."
|
||||
grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null
|
||||
|
||||
# Adding user with sudo privilege
|
||||
if [ -n "$username" ]; then
|
||||
echo "Adding $username with root privilege."
|
||||
|
|
@ -218,34 +229,35 @@ arch-chroot /mnt /bin/bash -e <<EOF
|
|||
usermod -aG wheel $username
|
||||
echo "$username ALL=(ALL) ALL" >> /etc/sudoers.d/$username
|
||||
fi
|
||||
|
||||
EOF
|
||||
|
||||
# Setting root password.
|
||||
echo "Setting root password."
|
||||
print "Setting root password."
|
||||
arch-chroot /mnt /bin/passwd
|
||||
[ -n "$username" ] && echo "Setting user password for ${username}." && arch-chroot /mnt /bin/passwd "$username"
|
||||
|
||||
# Enabling Reflector timer.
|
||||
echo "Enabling Reflector."
|
||||
print "Enabling Reflector."
|
||||
systemctl enable reflector.timer --root=/mnt &>/dev/null
|
||||
|
||||
# Enabling Snapper automatic snapshots.
|
||||
echo "Enabling Snapper and automatic snapshots entries."
|
||||
print "Enabling Snapper and automatic snapshots entries."
|
||||
systemctl enable snapper-timeline.timer --root=/mnt &>/dev/null
|
||||
systemctl enable snapper-cleanup.timer --root=/mnt &>/dev/null
|
||||
systemctl enable grub-btrfs.path --root=/mnt &>/dev/null
|
||||
|
||||
# Enabling systemd-oomd.
|
||||
echo "Enabling systemd-oomd."
|
||||
print "Enabling systemd-oomd."
|
||||
systemctl enable systemd-oomd --root=/mnt &>/dev/null
|
||||
|
||||
# ZRAM configuration
|
||||
bash -c 'cat > /mnt/etc/systemd/zram-generator.conf' <<-'EOF'
|
||||
# ZRAM configuration.
|
||||
cat > /mnt/etc/systemd/zram-generator.conf <<EOF
|
||||
[zram0]
|
||||
zram-fraction = 1
|
||||
max-zram-size = 8192
|
||||
EOF
|
||||
|
||||
# Finishing up
|
||||
echo "Done, you may now wish to reboot (further changes can be done by chrooting into /mnt)."
|
||||
# Finishing up.
|
||||
print "Done, you may now wish to reboot (further changes can be done by chrooting into /mnt)."
|
||||
exit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue