Rust CA

by agracie
11 deployments · 1 still active · last rev. 4 months ago

Compatible with: Debian 9
						#!/bin/bash
#
#<UDF name="pubkey" Label="SSH public key" example="ssh-rsa..." default="" />
#<UDF name="rusthostname" label="hostname" default="Linode Rust Server" />
#<UDF name="description" label="motd" default="Powered by Linode!" />
#<UDF name="rconpassword" Label="RCON password" />
#<UDF name="maxplayers" label="maxplayers" oneOf="10,25,50,75,100" default="50" />
#<UDF name="level" label="map" oneOf="Procedural Map,Barren,HapisIsland,SavasIsland_koth" default="Procedural Map" />
#<UDF name="worldsize" label="worldsize" oneOf="1000,3000,6000" default="3000" />
#<UDF name="seed" label="seed" default="50000" />
#<UDF name="globalchat" label="global chat" oneOf="true,false" default="true" />
#<UDF name="pve" label="pve" oneOf="true,false" default="false" />


source <ssinclude StackScriptID="401711">
source <ssinclude StackScriptID="401712">

exec 1> >(tee -a "/var/log/stackscript.log") 2>&1

GAMESERVER="rustserver"

set_hostname
apt_setup_update

if [[ "$PUBKEY" != "" ]]; then
  add_pubkey
fi

if [[ "$RUSTHOSTNAME" = "" ]]; then
  RUSTHOSTNAME="Linode Rust Server"
fi

if [[ "$LEVEL" = "Procedural Map" ]]; then
  LEVEL=""
fi

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 lib32z1

# Install linuxGSM
linuxgsm_install

# Install Rust
game_install

# Setup crons and create systemd service file
service_config

#Game Config Options

cp /home/rustserver/lgsm/config-lgsm/rustserver/_default.cfg /home/rustserver/lgsm/config-lgsm/rustserver/common.cfg
chown -R rustserver:rustserver /home/rustserver/

echo "server.globalchat $GLOBALCHAT/" > /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
echo "server.pve $PVE" >> /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
echo "server.description \"$DESCRIPTION\"" >> /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
echo "server.maxplayers $MAXPLAYERS" >> /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
echo "server.seed \"$SEED\"" >> /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
echo "server.level $LEVEL" >> /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
echo "server.hostname \"RUSTHOSTNAME\"" >> /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
echo "server.ip $IP" >> /home/rustserver/serverfiles/server/rustserver/cfg/server.cfg
sed -i "s/rconpassword=\"CHANGE_ME\"/rconpassword=\"$RCONPASSWORD\"/"  /home/rustserver/lgsm/config-lgsm/rustserver/common.cfg
sed -i "s/worldsize=\"3000\"/worldsize=\"$WORLDSIZE\"/"  /home/rustserver/lgsm/config-lgsm/rustserver/common.cfg
sed -i "s/maxplayers=\"50\"/maxplayers=\"$MAXPLAYERS\"/" /home/rustserver/lgsm/config-lgsm/rustserver/common.cfg


# Start the service and setup firewall
ufw_install
ufw allow 28015
ufw allow 28016
ufw enable
fail2ban_install
systemctl start "$GAMESERVER".service
systemctl enable "$GAMESERVER".service
stackscript_cleanup