From 7caf8d371d19af8000b23c7202154df9d2f861b9 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 26 Dec 2021 00:29:17 -0600 Subject: [PATCH] Create user home if they exist, silently ignore --- install.bash | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/install.bash b/install.bash index 46804ca..d28621e 100755 --- a/install.bash +++ b/install.bash @@ -16,14 +16,11 @@ git clone --recurse-submodules https://gitlab.orion-technologies.io/game-servers sudo /bin/bash "${GENERAL_MODULE_PATH}/install.bash" "${GENERAL_MODULE_PATH}" || exit # Create the user -if [[ ! -d "${SDTD_USER_HOME}" ]]; then - if id -u "${SDTD_USER_NAME}" > /dev/null 2>&1; then - echo "Creating home directory for ${SDTD_USER_NAME}" - mkdir -p "${SDTD_USER_HOME}" - else - echo "Creating user ${SDTD_USER_NAME}" - sudo useradd -m -s /bin/bash "${SDTD_USER_NAME}" 2>/dev/null - fi +if id -u "${SDTD_USER_NAME}" > /dev/null 2>&1; then + mkdir -p "${SDTD_USER_HOME}" +else + echo "Creating user ${SDTD_USER_NAME}" + sudo useradd -m -s /bin/bash "${SDTD_USER_NAME}" 2>/dev/null fi # Create the user .bin directory, I prefer .bin in scenarios in which I need