#!/bin/bash # Exit on any unhandled error set -e GIT_DIR="${HOME}/7-Days-To-Die-Temp" GENERAL_MODULE_PATH="${GIT_DIR}/Scripts/general" SDTD_USER_NAME="sdtd" SDTD_USER_HOME="/home/${SDTD_USER_NAME}/" SDTD_BIN_DIR="${SDTD_USER_HOME}/.bin" # 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}" # Run general installation from the general submodule /bin/bash "${GENERAL_MODULE_PATH}/install.bash" # Create the user sudo useradd -m -s /bin/bash "${SDTD_USER_NAME}" # 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 # VERY opinionated this exists. mkdir -p "${SDTD_BIN_DIR}" # Deploy the scipts, removing .bash from the end of them for script in "${GIT_DIR}/Scripts/"*; do script_name="$(basename "${script}")" script_suffixless="${script_name%.bash}" cp "${script_suffixless}" "${SDTD_BIN_DIR}" chmod 740 "${SDTD_BIN_DIR}/${script_suffixless}" done ### bash_profile modification ### # Yes this all could be one brace expansion, but that makes it more difficult # to parse at a cursory glance # Ensure the path for .bin is in the user's bash_profile echo "export PATH=\${PATH}:~/.bin" >> "${SDTD_USER_HOME}/.bash_profile" # Ensure the path for steamcmd is in the user's bash profile, typically installed to /usr/local/bin # for some reason this isn't in the path in certain situations by default... 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" 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"