Merge pull request #25 from fawzakin/user-account

Ask for user account
This commit is contained in:
Tommaso Chiti 2021-09-28 20:38:16 +02:00 committed by GitHub
commit e71d771b64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,6 +154,9 @@ genfstab -U /mnt >> /mnt/etc/fstab
read -r -p "Please enter the hostname: " hostname read -r -p "Please enter the hostname: " hostname
echo "$hostname" > /mnt/etc/hostname echo "$hostname" > /mnt/etc/hostname
# Setting username.
read -r -p "Please enter name for a user account (enter empty to not create one): " username
# Setting up locales. # Setting up locales.
read -r -p "Please insert the locale you use (format: xx_XX): " locale read -r -p "Please insert the locale you use (format: xx_XX): " locale
echo "$locale.UTF-8 UTF-8" > /mnt/etc/locale.gen echo "$locale.UTF-8 UTF-8" > /mnt/etc/locale.gen
@ -177,7 +180,7 @@ sed -i -e 's,modconf block filesystems keyboard,keyboard keymap modconf block en
# Setting up LUKS2 encryption and apparmor. # Setting up LUKS2 encryption and apparmor.
UUID=$(blkid $Cryptroot | cut -f2 -d'"') UUID=$(blkid $Cryptroot | cut -f2 -d'"')
sed -i "s/quiet/quiet cryptdevice=UUID=$UUID:cryptroot root=$BTRFS/g" /mnt/etc/default/grub sed -i "s,quiet,quiet cryptdevice=UUID=$UUID:cryptroot root=$BTRFS,g" /mnt/etc/default/grub
# Configuring the system. # Configuring the system.
arch-chroot /mnt /bin/bash -e <<EOF arch-chroot /mnt /bin/bash -e <<EOF
@ -213,11 +216,19 @@ 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
# Adding user with sudo privilege
if [ -n "$username" ]; then
echo "Adding $username with root privilege."
useradd -m $username
usermod -aG wheel $username
echo "$username ALL=(ALL) ALL" >> /etc/sudoers.d/$username
fi
EOF EOF
# Setting root password. # Setting root password.
echo "Setting root password." echo "Setting root password."
arch-chroot /mnt /bin/passwd arch-chroot /mnt /bin/passwd
[ -n "$username" ] && echo "Setting user password for ${username}." && arch-chroot /mnt /bin/passwd $username
# Enabling Reflector timer. # Enabling Reflector timer.
echo "Enabling Reflector." echo "Enabling Reflector."