Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Carbon Mod to Rust #115

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ ENV RUST_UPDATE_BRANCH "public"
ENV RUST_START_MODE "0"
ENV RUST_OXIDE_ENABLED "0"
ENV RUST_OXIDE_UPDATE_ON_BOOT "1"
ENV RUST_CARBON_ENABLED "0"
ENV RUST_CARBON_UPDATE_ON_BOOT "1"
ENV RUST_CARBON_BRANCH ""
ENV RUST_RCON_SECURE_WEBSOCKET "0"
ENV RUST_SERVER_WORLDSIZE "3500"
ENV RUST_SERVER_MAXPLAYERS "500"
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,21 @@ RUST_UPDATE_BRANCH (DEFAULT: "public" - Set to match the branch that you want to
RUST_START_MODE (DEFAULT: "0" - Determines if the server should update and then start (0), only update (1) or only start (2))
RUST_OXIDE_ENABLED (DEFAULT: "0" - Set to 1 to automatically install the latest version of Oxide)
RUST_OXIDE_UPDATE_ON_BOOT (DEFAULT: "1" - Set to 0 to disable automatic update of Oxide on boot)
RUST_CARBON_ENABLED (DEFAULT: "0" - Set to 1 to automatically install the latest version of Carbon)
RUST_CARBON_UPDATE_ON_BOOT (DEFAULT: "0" - Set to 1 to automatically update Carbon on boot)
RUST_CARBON_BRANCH (DEFAULT: "" - Set's the Branch of Carbon to install, Values: preview, edge, stable)
RUST_RCON_SECURE_WEBSOCKET (DEFAULT: "0" - Set to 1 to enable secure websocket connections to the RCON web interface)
RUST_HEARTBEAT (DEFAULT: "0" - Set to 1 to enable the heartbeat service which will forcibly quit the server if it becomes unresponsive to queries)
```

# Oxide vs Carbon

There are currently 3 systems for Modding Rust. Oxide, is the oldest, and most stable release of the Modding System, and most plugins are written for Oxide. However, Oxide is not updated as rapidly, or frequently, and can sometimes have a lag before a release matches with Rust server.

Carbon on the other hand, is the new kid on the block, it's more newer, more frequently updated, and utilizes a Hook on Demand setup, where only the hooks that plugins subscribe to / override in their code, will actually be connected, instead of all of them. Most plugins written for Oxide will work with Carbon, but it is not currently 100 percent backwards compatible. And Extensions (Pre-compiled Assemblies) that specifically target Oxide, need to be re-compiled to work with Carbon, and may have issues if certain API functionality that is available in Oxide, is not available in Carbon.

It is recommended that you only choose 1 of these systems for your server, and the docker will fail to run, if you enable both.

# Logging and rotating logs

The image now supports log rotation, and all you need to do to enable it is to remove any `-logfile` arguments from your startup arguments.
Expand Down
64 changes: 64 additions & 0 deletions start_rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ else
fi
fi

# Ensure only Oxide or Carbon is selected, not both.
if [ "$RUST_OXIDE_ENABLED" = "1" ] && [ "$RUST_CARBON_ENABLED" = "1" ]; then
echo "You need to select either Carbon or Oxide for your Plugins, can't enable both."
exit 1
fi

# Check if Oxide is enabled
if [ "$RUST_OXIDE_ENABLED" = "1" ]; then
# Next check if Oxide doesn't' exist, or if we want to always update it
Expand All @@ -117,6 +123,60 @@ if [ "$RUST_OXIDE_ENABLED" = "1" ]; then
fi
fi

if [ "$RUST_CARBON_ENABLED" = "1" ]; then
CARBON_BASE_URL="https://github.com/CarbonCommunity/Carbon.Core/releases/download/"
INSTALL_CARBON="0"
if [ ! -f "/steamcmd/rust/carbon/managed/Carbon.dll" ]; then
INSTALL_CARBON="1"
fi

if [ "$RUST_CARBON_UPDATE_ON_BOOT" = "1" ]; then
INSTALL_CARBON="1"
fi

if [ "$INSTALL_CARBON" = "1" ]; then
echo "Downloading and installing latest Carbon.."

case $RUST_BRANCH in
"staging")
echo "Downloading Rust Staging Release.."
CARBON_URL="${CARBON_BASE_URL}rustbeta_staging_build/Carbon.Linux.Debug.tar.gz"
;;
"aux01")
echo "Downloading Rust AUX01 Release.."
CARBON_URL="${CARBON_BASE_URL}rustbeta_aux01_build/Carbon.Linux.Debug.tar.gz"
;;
"aux02")
echo "Downloading Rust AUX02 Release.."
CARBON_URL="${CARBON_BASE_URL}rustbeta_aux02_build/Carbon.Linux.Debug.tar.gz"
;;
*)
if [ ! -z ${RUST_CARBON_BRANCH+x} ]; then
case $RUST_CARBON_BRANCH in
"preview")
echo "Downloading preview release.."
CARBON_URL="${CARBON_BASE_URL}preview_build/Carbon.Linux.Debug.tar.gz"
;;
"edge")
echo "Downlaoding edge release.."
CARBON_URL="${CARBON_BASE_URL}edge_build/Carbon.Linux.Debug.tar.gz"
;;
*)
echo "Downloading Rust Production Release.."
CARBON_URL="${CARBON_BASE_URL}production_build/Carbon.Linux.Release.tar.gz"
;;
esac
else
echo "Downloading Rust Production Release.."
CARBON_URL="${CARBON_BASE_URL}production_build/Carbon.Linux.Release.tar.gz"
fi
;;
esac
curl -sL $CARBON_URL | bsdtar -xvf- -C /steamcmd/rust/
chmod 755 /steamcmd/rust/carbon/tools/environment.sh
fi
fi

# Start mode 1 means we only want to update
if [ "$RUST_START_MODE" = "1" ]; then
echo "Exiting, start mode is 1.."
Expand Down Expand Up @@ -229,6 +289,10 @@ add_argument_pair ARGUMENTS "+server.maxplayers" "RUST_SERVER_MAXPLAYERS"
add_argument_pair ARGUMENTS "+server.saveinterval" "RUST_SERVER_SAVE_INTERVAL"
add_argument_pair ARGUMENTS "+app.port" "RUST_APP_PORT"

if [ "$RUST_CARBON_ENABLED" = "1" ]; then
source "/steamcmd/rust/carbon/tools/environment.sh"
fi

if [ "$LOGROTATE_ENABLED" = "1" ]; then
unbuffer /steamcmd/rust/RustDedicated $RUST_STARTUP_COMMAND "${ARGUMENTS[@]}" 2>&1 | grep --line-buffered -Ev '^\s*$|Filename' | tee $RUST_SERVER_LOG_FILE &
elif [ "$STDLOG_ENABLED" = "1" ]; then
Expand Down