Update chroot_setup.sh

This commit is contained in:
Conor Budworth 2025-11-09 22:29:39 +01:00
parent 934d9f8061
commit 0ebb2e330e

View File

@ -20,10 +20,21 @@ cat <<EOF >/etc/hosts
EOF EOF
echo ">>> Creating users" echo ">>> Creating users"
# Root password
echo "root:${ROOT_PASSWORD}" | chpasswd echo "root:${ROOT_PASSWORD}" | chpasswd
# Create user only if missing
if ! id -u "${USERNAME}" &>/dev/null; then
useradd -m -G wheel -s /bin/bash "${USERNAME}" 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 echo "${USERNAME}:${USER_PASSWORD}" | chpasswd
# Ensure sudoers configuration exists
mkdir -p /etc/sudoers.d mkdir -p /etc/sudoers.d
echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/10-wheel echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/10-wheel
chmod 440 /etc/sudoers.d/10-wheel chmod 440 /etc/sudoers.d/10-wheel