Fix some issues

This commit is contained in:
Augusto Gunsch 2021-08-12 12:02:11 -03:00
parent 2243052b3d
commit 19766ceac4
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
2 changed files with 13 additions and 6 deletions

View File

@ -72,7 +72,7 @@ readonly INIT_SYS
readonly UEFI readonly UEFI
right_chroot() { right_chroot() {
[ "$DISTRO" = "arch" ] && arch-chroot $@ || chroot $@ [ "$DISTRO" = "arch" ] && arch-chroot $@ || artix-chroot $@
} }
right_fstabgen() { right_fstabgen() {
@ -201,7 +201,7 @@ install_base() {
} }
set_timezone() { set_timezone() {
ln -sf "/mnt/usr/share/zoneinfo/$TIMEZONE" /mnt/etc/localtime ln -sf "/usr/share/zoneinfo/$TIMEZONE" /mnt/etc/localtime
quiet right_chroot /mnt hwclock --systohc quiet right_chroot /mnt hwclock --systohc
} }
@ -229,7 +229,14 @@ setup_grub() {
setup_users() { setup_users() {
echo -n "Configuring users..." echo -n "Configuring users..."
right_chroot /mnt useradd -m "$PERSONAL_USER"
set +e
# There might be a group with the user's name
awk -F: '$1 ~ /^'$PERSONAL_USER'$/ { exit 1 }' /etc/group
[ $? -eq 0 ] && right_chroot /mnt useradd --badnames -m "$PERSONAL_USER" || \
right_chroot /mnt useradd --badnames -m -g "$PERSONAL_USER" "$PERSONAL_USER"
set -e
echo -e "root:$ROOT_PASSWORD\n$PERSONAL_USER:$PERSONAL_PASSWORD" | chpasswd -R /mnt echo -e "root:$ROOT_PASSWORD\n$PERSONAL_USER:$PERSONAL_PASSWORD" | chpasswd -R /mnt
echo "done" echo "done"
} }
@ -241,11 +248,11 @@ setup_network() {
echo "::1 localhost" >> /mnt/etc/hosts echo "::1 localhost" >> /mnt/etc/hosts
echo "127.0.1.1 $MACHINE_HOSTNAME.localdomain $MACHINE_HOSTNAME" >> /mnt/etc/hosts echo "127.0.1.1 $MACHINE_HOSTNAME.localdomain $MACHINE_HOSTNAME" >> /mnt/etc/hosts
quiet right_chroot /mnt pacman -S dhcpcd wpa_supplicant quiet right_basestrap /mnt dhcpcd wpa_supplicant
if [ "$DISTRO" = "artix" ]; then if [ "$DISTRO" = "artix" ]; then
if [ "$INIT_SYS" = "openrc-init" ]; then if [ "$INIT_SYS" = "openrc-init" ]; then
echo "hostname=\"$MACHINE_HOSTNAME\"" > /mnt/etc/conf.d/hostname echo "hostname=\"$MACHINE_HOSTNAME\"" > /mnt/etc/conf.d/hostname
quiet right_chroot /mnt pacman -S connman-openrc quiet right_basestrap /mnt connman-openrc
quiet right_chroot /mnt rc-update add connmand quiet right_chroot /mnt rc-update add connmand
fi fi
else else

View File

@ -115,7 +115,7 @@ shift $((OPTIND-1))
[ -z "$INSTALL_USER" ] && [ "$INSTALL" != "PACKAGES" ] && echo "Error: <user> required" && usage [ -z "$INSTALL_USER" ] && [ "$INSTALL" != "PACKAGES" ] && echo "Error: <user> required" && usage
check_user() { check_user() {
HOME_DIR="$(awk -F: '$1 ~ /^'$1'$/ {print $6}' < /etc/passwd)" HOME_DIR="$(awk -F: '$1 ~ /^'$1'$/ {print $6}' /etc/passwd)"
[ -z "$HOME_DIR" ] && echo "Error: User $1 does not exist" && return 1 [ -z "$HOME_DIR" ] && echo "Error: User $1 does not exist" && return 1
return 0 return 0
} }