Skip to content

Commit

Permalink
Added three different startup modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dids committed Jul 1, 2016
1 parent eec72ab commit 273891e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ ENV RUST_RESPAWN_ON_RESTART "0"
ENV RUST_DISABLE_AUTO_UPDATE "0"
ENV RUST_UPDATE_CHECKING "0"
ENV RUST_UPDATE_BRANCH "public"
ENV RUST_START_MODE "0"

# Start the server
ENTRYPOINT ["./start.sh"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUST_RCON_PASSWORD (DEFAULT: "docker" - RCON server password, please change this
RUST_RESPAWN_ON_RESTART (DEFAULT: "0" - Controls whether to respawn resources on startup)
RUST_DISABLE_AUTO_UPDATE (DEFAULT: "0" - Disables automatic updating on startup)
RUST_BRANCH (DEFAULT: Not set - Sets the branch to use, eg. set to "-beta prerelease" for the prerelease branch)
RUST_START_MODE (DEFAULT: 0 - Determines if the server should update and then start (0), only update (1) or only start (2))
```

If you need help, have questions or bug submissions, feel free to contact me **@Dids** on Twitter, and on the *Rust Server Owners* Slack community.
28 changes: 19 additions & 9 deletions start_rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,22 @@ else
sed -i "s/app_update 258550.*validate/app_update 258550 validate/g" /install.txt
fi

# Disable auto-update if start mode is 2
if [ "$RUST_START_MODE" = "2" ]; then
RUST_DISABLE_AUTO_UPDATE=1
fi

# Check if we are auto-updating or not
if [ "$RUST_DISABLE_AUTO_UPDATE" = "1" ]; then
if [ ! -f "/steamcmd/rust/RustDedicated" ]; then
# Install/update Rust from install.txt
echo "Installing/updating Rust.."
bash /steamcmd/steamcmd.sh +runscript /install.txt
# Disable auto-update if start mode is 2
if [ "$RUST_START_MODE" = "2" ]; then
echo "Skipping Rust update due to mode 2.."
else
# Install/update Rust from install.txt
echo "Installing/updating Rust.."
bash /steamcmd/steamcmd.sh +runscript /install.txt
fi
else
echo "Rust seems to be installed, skipping automatic update.."
fi
Expand Down Expand Up @@ -72,6 +82,12 @@ if [ -d "/oxide" ]; then
cp -fr /oxide/* /steamcmd/rust/
fi

# Start mode 1 means we only want to update
if [ "$RUST_START_MODE" = "1" ]; then
echo "Exiting, start mode is 1.."
exit
fi

# Add RCON support if necessary
RUST_STARTUP_COMMAND=$RUST_SERVER_STARTUP_ARGUMENTS
if [ ! -z ${RUST_RCON_PORT+x} ]; then
Expand Down Expand Up @@ -119,12 +135,6 @@ if [ -f "/steamcmd/rust/seed_override" ]; then
fi
fi

# Use an intermediary file to pass env vars to cron
if [ -f "/root/.profile" ]; then
rm -fr /root/.profile
fi
env |sed 's/^\(.*\)$/export \1/g' >/root/.profile

# Start cron
echo "Starting scheduled task manager.."
node /scheduler_app/app.js &
Expand Down

0 comments on commit 273891e

Please sign in to comment.