2021-12-25 21:58:02 -06:00
#!/bin/bash
2021-12-25 22:29:46 -06:00
# Exit on any unhandled error
set -e
GIT_DIR = " ${ HOME } /7-Days-To-Die-Temp "
GENERAL_MODULE_PATH = " ${ GIT_DIR } /Scripts/general "
2021-12-25 22:57:47 -06:00
SDTD_USER_NAME = "sdtd"
SDTD_USER_HOME = " /home/ ${ SDTD_USER_NAME } / "
SDTD_BIN_DIR = " ${ SDTD_USER_HOME } /.bin "
2021-12-25 22:29:46 -06:00
# 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
2021-12-25 23:50:50 -06:00
sudo /bin/bash " ${ GENERAL_MODULE_PATH } /install.bash " " ${ GENERAL_MODULE_PATH } " || exit
2021-12-25 22:29:46 -06:00
2021-12-25 22:57:47 -06:00
# Create the user
2021-12-26 00:29:17 -06:00
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
2021-12-25 22:57:47 -06:00
fi
2021-12-25 22:29:46 -06:00
# 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
2021-12-26 00:27:41 -06:00
for script in " ${ GIT_DIR } /Scripts/ " *.bash; do
if [ [ -f " ${ script } " ] ] ; then
script_name = " $( basename " ${ script } " ) "
script_suffixless = " ${ script_name %.bash } "
cat " ${ script } " > " ${ SDTD_BIN_DIR } / ${ script_suffixless } "
chmod 740 " ${ SDTD_BIN_DIR } / ${ script_suffixless } "
fi
2021-12-25 22:29:46 -06:00
done
2021-12-26 00:32:38 -06:00
chown -R " ${ SDTD_USER_NAME } : ${ SDTD_USER_NAME } " " ${ SDTD_BIN_DIR } "
2021-12-25 22:29:46 -06:00
### 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
2021-12-26 00:30:19 -06:00
echo "source ~/.bin/7D2D-Manage-Completion" >> " ${ SDTD_USER_HOME } /.bash_profile "
2021-12-25 22:29:46 -06:00
2021-12-26 00:35:13 -06:00
echo " Cleaning up ${ GIT_DIR } "
rm -rf " ${ GIT_DIR } "
2021-12-25 22:29:46 -06:00
echo "Finished with installation."
2021-12-26 00:38:01 -06:00
echo "You should open the default ports for the server, default starts at 50000. Considering opening 50000 - 50010, that will allow up to 10 7D2D servers without telnet"
2021-12-25 22:29:46 -06:00
echo "To try it out as the user paste the following:"
2021-12-26 01:03:50 -06:00
echo " su ${ SDTD_USER_NAME } && source ~/.bash_profile && 7D2D-Manage -h "
2021-12-25 22:29:46 -06:00