Cleaning code.

This commit is contained in:
Tommaso Chiti 2021-11-03 20:05:25 +01:00
parent c5f30b8aa6
commit 91e57fe2c9

View file

@ -191,7 +191,7 @@ fi
# Pacstrap (setting up a base sytem onto the new root). # Pacstrap (setting up a base sytem onto the new root).
print "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 pacstrap /mnt base $kernel $microcode linux-firmware btrfs-progs grub grub-btrfs rsync efibootmgr snapper reflector base-devel snap-pac zram-generator
# Virtualization check # Virtualization check
hypervisor=$(systemd-detect-virt) hypervisor=$(systemd-detect-virt)
@ -202,7 +202,7 @@ case $hypervisor in
print "Enabling specific services for the guest tools." print "Enabling specific services for the guest tools."
systemctl enable qemu-guest-agent --root=/mnt &>/dev/null systemctl enable qemu-guest-agent --root=/mnt &>/dev/null
;; ;;
vmware ) print "VMWare Workstation/ESXi has been detected." vmware ) print "VMWare Workstation/ESXi has been detected."
print "Installing guest tools." print "Installing guest tools."
pacstrap /mnt open-vm-tools pacstrap /mnt open-vm-tools
print "Enabling specific services for the guest tools." print "Enabling specific services for the guest tools."
@ -223,6 +223,7 @@ case $hypervisor in
systemctl enable hv_kvp_daemon --root=/mnt &>/dev/null systemctl enable hv_kvp_daemon --root=/mnt &>/dev/null
systemctl enable hv_vss_daemon --root=/mnt &>/dev/null systemctl enable hv_vss_daemon --root=/mnt &>/dev/null
;; ;;
* ) ;;
esac esac
# Setting up the network. # Setting up the network.
@ -264,8 +265,6 @@ sed -i "s,quiet,quiet cryptdevice=UUID=$UUID:cryptroot root=$BTRFS,g" /mnt/etc/d
# Configuring the system. # Configuring the system.
arch-chroot /mnt /bin/bash -e <<EOF arch-chroot /mnt /bin/bash -e <<EOF
print "test"
# Setting up timezone. # Setting up timezone.
echo "Setting up the timezone." echo "Setting up the timezone."
ln -sf /usr/share/zoneinfo/$(curl -s http://ip-api.com/line?fields=timezone) /etc/localtime &>/dev/null ln -sf /usr/share/zoneinfo/$(curl -s http://ip-api.com/line?fields=timezone) /etc/localtime &>/dev/null
@ -300,20 +299,38 @@ arch-chroot /mnt /bin/bash -e <<EOF
echo "Creating GRUB config file." echo "Creating GRUB config file."
grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null grub-mkconfig -o /boot/grub/grub.cfg &>/dev/null
# Setting root password.
echo "Setting root password."
passwd
# Adding user with sudo privileges. # Adding user with sudo privileges.
if [ -n "$username" ]; then if [ -n "$username" ]; then
echo "Adding $username with root privilege." echo "Adding $username with root privilege."
useradd -m "$username" useradd -m "$username"
usermod -aG wheel "$username" usermod -aG wheel "$username"
echo "Setting user password for $username."
passwd $username
echo "$username ALL=(ALL) ALL" >> /etc/sudoers.d/"$username" echo "$username ALL=(ALL) ALL" >> /etc/sudoers.d/"$username"
fi fi
EOF EOF
# Setting root password. # Boot backup hook.
print "Setting root password." print "Configuring /boot backup when pacman transactions are made."
arch-chroot /mnt /bin/passwd cat > /mnt/etc/pacman.d/hooks/50-bootbackup.hook <<EOF
[ -n "$username" ] && print "Setting user password for ${username}." && arch-chroot /mnt /bin/passwd "$username" [Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Path
Target = usr/lib/modules/*/vmlinuz
[Action]
Depends = rsync
Description = Backing up /boot...
When = PostTransaction
Exec = /usr/bin/rsync -a --delete /boot /.bootbackup
EOF
# ZRAM configuration. # ZRAM configuration.
print "Configuring ZRAM." print "Configuring ZRAM."