From 2292ff73878ae6c1400f087b7268d9b31844c2e9 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 3 Apr 2023 10:35:01 +0200 Subject: [PATCH] Add script for adding default user --- scripts/Arch/OS/setup.sh | 13 ++++++++++--- scripts/Arch/OS/user.sh | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 scripts/Arch/OS/user.sh diff --git a/scripts/Arch/OS/setup.sh b/scripts/Arch/OS/setup.sh index 97127b9d..1577992a 100755 --- a/scripts/Arch/OS/setup.sh +++ b/scripts/Arch/OS/setup.sh @@ -9,6 +9,10 @@ ARCH_LANG="en_US.UTF-8"; ARCH_KEYMAP="de_CH-latin1"; LOCALE_PATTERN="\(de_CH\|en_US\)"; +USER_NAME="${USER_NAME}"; +USER_DISPLAYNAME="${USER_DISPLAYNAME}"; +USER_GROUPS="${USER_GROUPS}"; + projectRoot="$(realpath ../../..)"; projectName="$(basename "$projectRoot")"; relativeDir="$(realpath --relative-to "$projectRoot" "$(pwd)")"; @@ -33,10 +37,13 @@ echo "KEYMAP=$ARCH_KEYMAP" | arch-chroot "$ARCH_MOUNT_ROOT" tee /etc/vconsole.co arch-chroot "$ARCH_MOUNT_ROOT" echo "$ARCH_HOSTNAME" > /etc/hostname; arch-chroot "$ARCH_MOUNT_ROOT" mkinitcpio -P; -echo "Please choose a password for the user \`root\`"; -arch-chroot "$ARCH_MOUNT_ROOT" passwd; - arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/../Software/GRUB/install.sh"; arch-chroot "$ARCH_MOUNT_ROOT" rm -rf "$tempRoot"; + +USER_NAME="${USER_NAME}" \ +USER_DISPLAYNAME="${USER_DISPLAYNAME}" \ +USER_GROUPS="${USER_GROUPS}" \ + arch-chroot "$ARCH_MOUNT_ROOT" bash "$tempDir/user.sh"; + popd > /dev/null; diff --git a/scripts/Arch/OS/user.sh b/scripts/Arch/OS/user.sh new file mode 100644 index 00000000..22ac664e --- /dev/null +++ b/scripts/Arch/OS/user.sh @@ -0,0 +1,14 @@ +#!/bin/bash +USER_NAME="${USER_NAME}"; +USER_DISPLAYNAME="${USER_DISPLAYNAME}"; +USER_GROUPS="${USER_GROUPS}"; +useradd --create-home --comment "$USER_DISPLAYNAME" --groups wheel "$USER_NAME"; +usermod -aG wheel "$USER_NAME"; + +if [ ! -z "$USER_GROUPS" ] +then + usermod -aG "$USER_GROUPS" "$USER_NAME"; +fi; + +echo "Please Choose a New Password for User \`$USER_NAME\`"; +passwd "$USER_NAME";