Skip to content

Rust - Dedicated Linux Server Admin Scripts

Just thought I'd put these out there... a few scripts that might prove useful to you if you run your own Rust dedicated server.

In case it's not obvious from the article title, these scripts are for Linux. They should run fine on RedHat and it's derivatives. All these scripts sit in the directory containing the dedicated server files.

The backup script

This is incredibly simple and lacks any form of error checking, but it shouldn't need to be that clever because unless you have no space or a serious hardware fault, there isn't a lot that can go wrong.

backup.sh
#! /bin/bash

# Create timestamped backup of the key server files
backupstamp=$(date +%Y%m%d%H%M%S)

# Make the directories that will contain our backup files
mkdir backup"$backupstamp"
mkdir backup"$backupstamp"/server
mkdir backup"$backupstamp"/oxide

# Backup all our scripts
cp *.sh backup"$backupstamp"

# Backup the server data
cp -R server/* backup"$backupstamp"/server

# Backup Oxide
cp -R oxide/* backup"$backupstamp"/oxide

# Remove the Oxide logs from the backup
rm -Rf backup"$backupstamp"/oxide/logs

The steamcmd script

This probably shouldn't have a .sh extension, but hey... it means I don't have to include an additional copy in the backup script to ensure this gets backed up.

steamcmdupdate.sh
1
2
3
4
5
6
@ShutdownOnFailedCommand 1
@NoPromptForPassword
force_install_dir /home/rustacian/rusty_cog
login anonymous
app_update 258550 validate
quit

You will notice that this is literally the same set of commands you would run manually to update the server.

The main start script

This is an incredibly simple script that basically runs the actual startup script in a screen session.

start.sh
1
2
3
#! /bin/bash

screen -S <SCREENSESSIONNAME> "./ds.sh"

Note

This is the script you run to start the server (since you will then be able to detach from it using CTRL+A CTRL+D. You can then re-attach using screen -R <SCREENSESSIONNAME>).

The actual start script

ds.sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`dirname $0`/RustDedicated_Data/Plugins:`dirname $0`/RustDedicated_Data/Plugins/x86_64

./RustDedicated -batchmode -logfile 2>&1 \
-server.ip <SERVERIPADDRESS> \
-server.port <SERVERPORT> \
-app.port <RUSTPLUSPORT> \
-rcon.ip <RCONIPADDRESS> \
-rcon.port <RCONPORT> \
-rcon.web 1 \
-rcon.password <RCONPASSWORD> \
-server.maxplayers 20 \
-server.hostname <SERVERNAME> \
-server.identity <SERVERIDENTITY> \
-server.level "Procedural Map" \
-server.seed <MAPSEED> \
-server.worldsize 4500 \
-server.saveinterval 600 \
-server.globalchat false \
-server.description <SERVERDESCRIPTION> \
-decay.tick 0 \
-decay.scale 0 \
-playerhelicopter.insidedecayminutes 0 \
-playerhelicopter.outsidedecayminutes 0 \
-tugboat.tugdecayminutes 0 \
-hackablelockedcrate.requiredhackseconds 300 \

You will no doubt notice that decay is turned off for quite a lot... the server I look after is a private server for a small collection of on-line friends. We don't want to be worrying about decay and having things like tug boats vanishing.

Note

You should only use this script to start the server for testing.

The update script

Since this could break an install, when you call ./update.sh, you must include confirm as the first and only parameter. Without this parameter the script will do nothing except tell you how to have it do it's job. Like the other scripts there is nothing in the way of error checking etc. If it fails you'll need to fix it up, but know that it uses the backup script to take a copy of the config and game data before it does the updates.

update.sh
#! /bin/bash

if [ "$1" = "confirm" ] ; then
  # Backup the current server data
  printf "Backing up current data\n"
  ./backup.sh

  # Use a script for steamcmd to update the server
  printf "Updating server from Steam\n"
  cd /home/<USERNAME>/Steam
  ./steamcmd.sh +runscript /home/<USERNAME>/<SERVERDIRECTORY>/steamcmdupdate.sh
  cd /home/<USERNAME>/<SERVERDIRECTORY>

  # Download the latest Oxide
  printf "Downloading latest Oxide\n"
  wget -O Oxide.Rust-linux.zip https://umod.org/games/rust/download/develop

  # Unzip Oxide (overwriting any existing files without prompting)
  printf "Unzipping Oxide\n"
  unzip -o Oxide.Rust-linux.zip

  printf "Removing Oxide download file\n"
  rm -f Oxide.Rust-linux.zip

  printf "Done"
else
  printf "To use this update script, call it with confirm (i.e. update.sh confirm)\n"
fi

Important

Where there are items of data you need to supply, they are shown in the scripts surrounded by < and >

For example:- <USERNAME>

You will also notice that a certain directory structure is assumed.

/home/<USERNAME>
    Steam
    <SERVERDIRECTORY>
        server
        oxide
        ...

All of these script files reside in <SERVERDIRECTORY>

Disclaimer

These scripts are provided as is for reference/educational purposes only. Before you consider using them, you should make sure you are familiar with the commands they use and the general operation of steamcmd, the Rust dedicated linux server and the host operating system. By using them you acknowledge that you do so at your own risk and you agree that you will not hold me responsible for any losses (financial or otherwise) that may occur as a result of your use of these scripts.

I know they work for me with my setup but I make no guarantees they will work for anyone else and their setup, so if you use them, you do so at your own risk.

Comments