#!/bin/bash # #<UDF name="steamuser" Label="Steam username." example="username" /> #<UDF name="steampassword" Label="Steam user password, must have Steam Guard turned off." example="YourSteamPassword" /> #<UDF name="pubkey" Label="SSH pubkey (installed for root and sudo user)?" example="ssh-rsa ..." /> #<UDF name="worldsize" label="Size of your world: 1(small) 2(medium) 3(large)" default="1"/> #<UDF name="worldname" label="Name of your Terraria world." default="world1" /> #<UDF name="gspassword" label="Game server password" default="" /> #<UDF name="players" label="Number of players: 1-255" default="20"/> source <ssinclude StackScriptID="349139"> source <ssinclude StackScriptID="370022"> exec 1> >(tee -a "/var/log/stackscript.log") 2>&1 GAMESERVER="terrariaserver" set_hostname apt_setup_update if [[ "$PUBKEY" != "" ]]; then add_pubkey fi # Terraria specific dependencies debconf-set-selections <<< "postfix postfix/main_mailer_type string 'No Configuration'" debconf-set-selections <<< "postfix postfix/mailname string `hostname`" dpkg --add-architecture i386 apt update sudo apt -q -y install mailutils postfix \ curl wget file bzip2 gzip unzip bsdmainutils \ python util-linux ca-certificates binutils bc \ jq tmux lib32gcc1 libstdc++6 libstdc++6:i386 # Install linuxGSM linuxgsm_install echo Requires Steam username and password to install su - $GAMESERVER -c "mkdir -p /home/$GAMESERVER/lgsm/config-lgsm/$GAMESERVER" su - $GAMESERVER -c "touch /home/$GAMESERVER/lgsm/config-lgsm/$GAMESERVER/common.cfg" su - $GAMESERVER -c "echo steamuser=\"$STEAMUSER\" >> /home/$GAMESERVER/lgsm/config-lgsm/$GAMESERVER/common.cfg" su - $GAMESERVER -c "echo steampass=\''$STEAMPASSWORD'\' >> /home/$GAMESERVER/lgsm/config-lgsm/$GAMESERVER/common.cfg" # Install Terraria game_install # Update the server IP and name echo Updating the server IP and name #sed -i \"s/server-ip=/server-ip=$IPADDR/\" /home/$GAMESERVER/serverfiles/server.properties" sed -i s/autocreate=1/autocreate="$WORLDSIZE"/ home/"$GAMESERVER"/serverfiles/"$GAMESERVER".txt sed -i s/worldname=world1/worldname="$WORLDNAME"/ home/"$GAMESERVER"/serverfiles/"$GAMESERVER".txt sed -i s/password=/password="$GSPASSWORD"/ home/"$GAMESERVER"/serverfiles/"$GAMESERVER".txt sed -i s/maxplayers=8/maxplayers="$PLAYERS"/ home/"$GAMESERVER"/serverfiles/"$GAMESERVER".txt # Setup crons and create systemd service file service_config # Start the service and setup firewall ufw_install ufw allow 7777/tcp ufw allow 7777/udp ufw enable fail2ban_install systemctl start "$GAMESERVER".service systemctl enable "$GAMESERVER".service stackscript_cleanup