From 9bc4b5c8a8cd53aa59d2de5bf5c90dcb31d7f168 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 4 Dec 2024 18:35:15 +0100 Subject: [PATCH] Use pre-existing setup user if existent --- scripts/lib/action.fish | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/lib/action.fish b/scripts/lib/action.fish index 3d4ea167..607d2c37 100644 --- a/scripts/lib/action.fish +++ b/scripts/lib/action.fish @@ -55,15 +55,19 @@ function runSetupUserAction -V dir set -l sudoConfig "/etc/sudoers.d/PortValhalla" begin - echo "Creating setup user" - - and useradd \ - --comment "PortValhalla Setup User" \ - --system \ - --groups nix-users \ - --create-home \ - --uid (getOSConfig setupUser.id --json) \ - "$name" + if id -u "$name" &>/dev/null + echo "Setup user already exists!" + else + echo "Creating setup user" + + and useradd \ + --comment "PortValhalla Setup User" \ + --system \ + --groups nix-users \ + --create-home \ + --uid (getOSConfig setupUser.id --json) \ + "$name" + end and begin echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"