[Release] Rust / Oxide automated update script for Linux users

Hey everyone, Skull here.

New to the Rust admin scene but figured I would contribute what I can in the meantime. Made this script to automatically grab the latest version of Oxide from the github repository. I'm sure it could be improved but it should help most people out that are looking for a way to automate Rust / Oxide being updated at the same time.

#!/bin/bash
# Verify that the repository information is correct before running this script.
# Failure to do so can result in a compromised server.
# Only ever download and run software that you know and trust.

# const definitions
LOCAL_VERSION_FILE='oxide_version.txt'
LOCAL_RUST_DIRECTORY="$HOME/.steam/steamapps/common/rust_dedicated"
REPO_URL='https://github.com/OxideMod/Oxide.Rust/' # MUST LINK TO THE REPOSITORY. NOTHING ELSE.
FILENAME='Oxide.Rust-linux.zip'
STEAMAPP_ID='258550' # rust server app ID

# create empty file to store file version (if one doesn't exist)
touch "$LOCAL_VERSION_FILE"

# var initialization
latest_version="$(curl -LIs "${REPO_URL}/releases/latest" | dos2unix | grep -i '^location:' | cut -d' ' -f2 | cut -d'/' -f8)" # Github.com outputs CRLF we run dos2unix to remove them.
local_version="$(<"$LOCAL_VERSION_FILE")"

echo "Download URL is: ${REPO_URL}releases/download/${latest_version}/${FILENAME}"

# check if local version of package matches latest on github
if [ "$latest_version" != "$local_version" ]; then
if curl -Ls "${REPO_URL}releases/download/${latest_version}/${FILENAME}" -o "${FILENAME}"; then
echo "Downloaded ${FILENAME} Successfully."
else
echo "Failed with CURL error: ${?}"
fi
fi

# steam update for whichever steamapp ID you provide. If it says something about SDL ignore it.
steamcmd +login anonymous +app_update "$STEAMAPP_ID" validate +quit && echo "Steam finished updating successfully!" || echo "Failed with steamcmd exit code ${?}"

# overwrite RustDedicated_Data with the latest Oxide files.
unzip -o "${FILENAME}" -d "${LOCAL_RUST_DIRECTORY}" && echo "$latest_version" > "$LOCAL_VERSION_FILE" || echo "Unzip failed with code ${?}. Oxide not installed properly."

echo "Finished updating."

Useful script, thanks!

Great job!  How can we make  it also check and update new  versions  of plugins?

rugovit

Great job!  How can we make  it also check and update new  versions  of plugins?

you can use UpdateChecker from other web site ;) can't post link sorry