From 0ebb2e330ee3ac604e497e8455f44375f7ccdf53 Mon Sep 17 00:00:00 2001 From: Conor Budworth Date: Sun, 9 Nov 2025 22:29:39 +0100 Subject: [PATCH] Update chroot_setup.sh --- chroot_setup.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/chroot_setup.sh b/chroot_setup.sh index daee18f..e5d8107 100644 --- a/chroot_setup.sh +++ b/chroot_setup.sh @@ -20,10 +20,21 @@ cat </etc/hosts EOF echo ">>> Creating users" + +# Root password echo "root:${ROOT_PASSWORD}" | chpasswd -useradd -m -G wheel -s /bin/bash "${USERNAME}" + +# Create user only if missing +if ! id -u "${USERNAME}" &>/dev/null; then + useradd -m -G wheel -s /bin/bash "${USERNAME}" +else + echo "User ${USERNAME} already exists, skipping creation." +fi + +# Always (re)set password echo "${USERNAME}:${USER_PASSWORD}" | chpasswd +# Ensure sudoers configuration exists mkdir -p /etc/sudoers.d echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/10-wheel chmod 440 /etc/sudoers.d/10-wheel