Commit 48641fb9 authored by David's avatar David
Browse files

Update server install scripts

parent 2efdb0cf
......@@ -11,9 +11,10 @@ export STEAMUSERNAME='PUT-STEAM-USERNAME-HERE'
export DEFAULTMAP='pl_upward'
export PLAYERS='24'
# Check if root
# Check if running with sudo/root privilages
if [ "$EUID" -ne 0 ]
then echo "Run as root or use sudo."
then
echo "Run as root or use sudo."
exit 1
fi
......@@ -30,10 +31,6 @@ sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo apt-get autoclean
# Turn off ubuntu auto updates
sed 's/"1"/"0"/' /etc/apt/apt.conf.d/10periodic > tmp-file && mv tmp-file /etc/apt/apt.conf.d/10periodic
sed 's/"1"/"0"/' /etc/apt/apt.conf.d/20auto-upgrades > tmp-file && mv tmp-file /etc/apt/apt.conf.d/20auto-upgrades
# Install dependices for the tf2server instance
sudo dpkg --add-architecture i386; sudo apt-get update; sudo apt-get install mailutils postfix curl wget file bzip2 gzip unzip bsdmainutils python util-linux ca-certificates binutils bc tmux lib32gcc1 libstdc++6 libstdc++6:i386 libcurl4-gnutls-dev:i386 libtcmalloc-minimal4:i386 vim -y
......
#!/bin/bash
#Purpose - This is a script to automate the process of installing a tf2server stack on a clean Debian or Ubuntu server instance. The script needs to be ran as root to function properly. Please auit the code below before running in your environment.
# Purpose - This is a script to automate the process of installing a tf2server stack on a clean Debian or Ubuntu server instance. The script needs to be ran as root to function properly. Please auit the code below before running in your environment.
# Variables used in script. Only edit the STEAMID and STEAMUSERNAME variable.
# Variables used in script.
export METAMODURL='https://mms.alliedmods.net/mmsdrop/1.10/mmsource-1.10.7-git961-linux.tar.gz'
export METAMODFILENAME='mmsource-1.10.7-git961-linux.tar.gz'
export SOURCEMODURL='https://sm.alliedmods.net/smdrop/1.8/sourcemod-1.8.0-git6041-linux.tar.gz'
......@@ -11,26 +11,22 @@ export STEAMUSERNAME='PUT-STEAM-USERNAME-HERE'
export DEFAULTMAP='pl_upward'
export PLAYERS='24'
# Check if root
# Check if running as root user, and exit if not.
if [ "$EUID" -ne 0 ]
then echo "Run as root or use sudo."
then
echo "Run as root or use sudo."
exit 1
fi
# Install sudo incase its not installed.
# Install sudo incase its not already installed.
apt-get -y install sudo
# Update the server
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo apt-get autoclean
# Turn off ubuntu auto updates
sed 's/"1"/"0"/' /etc/apt/apt.conf.d/10periodic > tmp-file && mv tmp-file /etc/apt/apt.conf.d/10periodic
sed 's/"1"/"0"/' /etc/apt/apt.conf.d/20auto-upgrades > tmp-file && mv tmp-file /etc/apt/apt.conf.d/20auto-upgrades
# Install required packages and utilities used later in the script
sudo dpkg --add-architecture i386
sudo apt-get update
......@@ -42,58 +38,58 @@ passwd tf2server
# Install tf2 server function
install-tf2-server() {
cd ~
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
tar -zxf steamcmd_linux.tar.gz
rm steamcmd_linux.tar.gz
cd ~
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
tar -zxf steamcmd_linux.tar.gz
rm steamcmd_linux.tar.gz
cat << EOT >> ~/tf2_ds.txt
cat << EOT >> ~/tf2_ds.txt
login anonymous
force_install_dir ./tf2
app_update 232250 validate
quit
EOT
cat << EOT >> ~/update.sh
cat << EOT >> ~/update.sh
#!/bin/sh
./steamcmd.sh +runscript tf2_ds.txt
EOT
chmod +x ~/update.sh
~/update.sh
chmod +x ~/update.sh
~/update.sh
# Fix for srcds looking in wrong directory for binaries. (Such as steamclient.so)
ln -s ~/tf2/bin ~/.steam/sdk32
# Fix for srcds looking in wrong directory for binaries. (Such as steamclient.so)
ln -s ~/tf2/bin ~/.steam/sdk32
cat << EOT >> ~/tf2/tf/cfg/server.cfg
cat << EOT >> ~/tf2/tf/cfg/server.cfg
hostname "Your_Server's_Name"
rcon_password "Your_Rcon_Password"
sv_contact "admin@yourdomain.com"
mp_timelimit "30"
EOT
cat << EOT >> ~/tf.sh
cat << EOT >> ~/tf.sh
#!/bin/sh
tmux new-session -d -s tf2server "~/tf2/srcds_run -autoupdate -ip 0.0.0.0 -steam_dir ~/ -steamcmd_script ~/tf2_ds.txt -console -game tf +sv_pure 1 +map $DEFAULTMAP +maxplayers $PLAYERS"
EOT
# Install MetaMod and SourceMod
cd ~/tf2/tf
wget $METAMODURL
tar -xf $METAMODFILENAME
rm $METAMODFILENAME
# Install MetaMod and SourceMod
cd ~/tf2/tf
wget $METAMODURL
tar -xf $METAMODFILENAME
rm $METAMODFILENAME
wget $SOURCEMODURL
tar -xf $SOURCEMODFILENAME
rm $SOURCEMODFILENAME
wget $SOURCEMODURL
tar -xf $SOURCEMODFILENAME
rm $SOURCEMODFILENAME
# Setup Steam id's for admin
cat << EOT >> /home/tf2server/tf2/tf/addons/sourcemod/configs/admins_simple.ini
# Setup Steam id's for admin
cat << EOT >> /home/tf2server/tf2/tf/addons/sourcemod/configs/admins_simple.ini
"$STEAMID" "99:z" //$STEAMUSERNAME
EOT
chmod +x ~/tf.sh
~/tf.sh
chmod +x ~/tf.sh
~/tf.sh
}
# Export the function
......@@ -102,7 +98,11 @@ export -f install-tf2-server
# Install the tf2server
su tf2server -c "bash -c install-tf2-server"
# Configure firewall
#################
#### Configure firewall
#################
# Install packages
sudo apt-get -y install iptables iptables-persistent
# Wipe the v4 rules
......@@ -123,7 +123,7 @@ sudo ip6tables -t mangle -F
sudo ip6tables -F
sudo ip6tables -X
# Set up rules
# Confiure the new firewall rules.
sudo iptables -I INPUT 1 -i lo -j ACCEPT
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp -m state --state NEW,ESTABLISHED --dport 22 -j ACCEPT
......@@ -139,14 +139,21 @@ sudo iptables -P INPUT DROP
iptables-save > /etc/iptables/rules.v4
ip6tables-save > /etc/iptables/rules.v6
# Setup web server
##########
### Configure web server for fastdl
##########
# install Apache
sudo apt-get -y install apache2
# Create a fastdl directory and create a symlink
mkdir -p /var/www/html/fastdl/tf2/
cd /var/www/html/fastdl/tf2/
ln -s /home/tf2server/tf2/tf/maps maps
# Start the service and enable on startup.
sudo systemctl start apache2.service
sudo systemctl enable apache2.service
mv /var/www/html/index.html /var/www/html/index.html.bak
# Add cronjobs
echo "@reboot tf2server /home/tf2server/tf.sh" >> /etc/crontab
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment