From 7f1243213b7c462368e7dddbe77a754d22bb2a74 Mon Sep 17 00:00:00 2001 From: langfingaz Date: Sun, 2 May 2021 21:43:50 +0200 Subject: [PATCH] installer script: work in progress (12): user and group --- pkg/de-p1st-installer/de-p1st-installer.sh | 14 ++++++++++++++ pkg/de-p1st-installer/installer.cfg | 3 +++ 2 files changed, 17 insertions(+) diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index fd85f09..709d628 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -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 "$@" diff --git a/pkg/de-p1st-installer/installer.cfg b/pkg/de-p1st-installer/installer.cfg index 311cd98..1ed1665 100644 --- a/pkg/de-p1st-installer/installer.cfg +++ b/pkg/de-p1st-installer/installer.cfg @@ -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