Create user home if they exist, silently ignore

This commit is contained in:
Price Hiller 2021-12-26 00:29:17 -06:00
parent 9f064da562
commit 7caf8d371d

View File

@ -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