installer script: work in progress (12): user and group

This commit is contained in:
Daniel Langbein 2021-05-02 21:43:50 +02:00
parent 809ffddb50
commit 7f1243213b
2 changed files with 17 additions and 0 deletions

View File

@ -276,6 +276,19 @@ ff02::2 ip6-allrouters" >> /mnt/etc/hosts || return $?
fi
}
function user_and_pwd() {
# -m: create home
# -U: Create a group with the same name as the user, and add the user to this group.
arch-chroot /mnt useradd -m -s /usr/bin/zsh -g wheel "${USERNAME}" || return $?
arch-chroot /mnt chsh -s /usr/bin/zsh || return $?
# If ROOT_PWD is not given, the use USER_PWD for root user
ROOT_PWD="${ROOT_PWD:="${USER_PWD}"}"
printf "%s:%s" "${USERNAME}" "${USER_PWD}" | chpasswd --root /mnt || return $?
printf "%s:%s" "root" "${ROOT_PWD}" | chpasswd --root /mnt || return $?
}
function main() {
# @pre
# bash libraries imported
@ -322,6 +335,7 @@ function main() {
# in: HOSTNAME, FQDN (optional), STATIC_IP (optional), IPV6_CAPABLE (optional)
config_hostname_and_hosts || return $?
user_and_pwd || return $?
}
main "$@"

View File

@ -11,6 +11,9 @@ USERNAME=arch
USER_PWD=test
LUKS_PWD=test
# if unset, then USER_PWD will be used for ROOT_PWD
# ROOT_PWD=test
KERNEL=linux
TARGET_BLOCK_DEVICE=/dev/sda