From 260993c261f026ccee358864d296aa6e51e8f6d0 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"