diff --git a/README.md b/README.md index bb90c45..26682cb 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A set of opinionated scripts used to manage 7 days to die. - Used to show progress for backup operations # Automatic Installation -Run as the user you wish to install the scripts for, e.g. `sdtd`. +Must be ran as `root` or a user with access to `sudo su` ```bash bash -c "$(curl https://gitlab.orion-technologies.io/game-servers/7-days-to-die/-/raw/Development/install.bash)" diff --git a/install.bash b/install.bash index 3de8495..83ba38f 100755 --- a/install.bash +++ b/install.bash @@ -5,8 +5,12 @@ set -e GIT_DIR="${HOME}/7-Days-To-Die-Temp" GENERAL_MODULE_PATH="${GIT_DIR}/Scripts/general" -SDTD_USER_HOME="${HOME}" -SDTD_BIN_DIR="${HOME}/.bin" +SDTD_USER_NAME="sdtd" +SDTD_USER_HOME="/home/${SDTD_USER_NAME}/" +SDTD_BIN_DIR="${SDTD_USER_HOME}/.bin" + +# Change to the root user +sudo su # Get the repo as this script SHOULD be a copy paste into a terminal, so we have to pull this down git clone --recurse-submodules https://gitlab.orion-technologies.io/game-servers/7-days-to-die.git "${GIT_DIR}" @@ -14,6 +18,17 @@ git clone --recurse-submodules https://gitlab.orion-technologies.io/game-servers # Run general installation from the general submodule /bin/bash "${GENERAL_MODULE_PATH}/install.bash" +# 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 +fi + # Create the user .bin directory, I prefer .bin in scenarios in which I need # significant user segmentation, e.g. I have some users running a different game # and only this user managing 7 Days to Die; considering that these scripts are @@ -43,8 +58,6 @@ echo "export PATH=\${PATH}:/usr/local/bin" >> "${SDTD_USER_HOME}/.bash_profile" # Ensure the completions are being sourced echo "source ~/.bin/7D2D-Manage-Completions" >> "${SDTD_USER_HOME}/.bash_profile" -rm -rf "${GIT_DIR}" - echo "Finished with installation." echo "To try it out as the user paste the following:" echo "su ${SDTD_USER_NAME} && cd ${HOME} && source .bash_profile && 7D2D-Manage -h"