forked from Didstopia/rust-server
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added experimental fully automatic updates
- Loading branch information
Showing
15 changed files
with
203 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
#!/bin/bash | ||
|
||
# Set Docker to use the machine | ||
eval "$(docker-machine env default)" | ||
|
||
docker build -t didstopia/rust-server:latest . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
#!/bin/bash | ||
|
||
# Set Docker to use the machine | ||
eval "$(docker-machine env default)" | ||
|
||
docker build --no-cache -t didstopia/rust-server:latest . |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Set Docker to use the machine | ||
eval "$(docker-machine env default)" | ||
|
||
docker tag -f didstopia/rust-server:latest didstopia/rust-server:latest | ||
docker tag didstopia/rust-server:latest didstopia/rust-server:latest | ||
docker push didstopia/rust-server:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# Set Docker to use the machine | ||
eval "$(docker-machine env default)" | ||
./docker_build.sh | ||
|
||
# Run the server | ||
docker run -p 28015:28015 -p 28016:28016 -p 8080:8080 -m 4g -v $(pwd)/rust_data:/steamcmd/rust -e RUST_RESPAWN_ON_RESTART=1 --name rust-server -d didstopia/rust-server:latest | ||
docker run -p 28015:28015 -p 28016:28016 -p 8080:8080 -m 4g -v $(pwd)/rust_data:/steamcmd/rust -e RUST_RESPAWN_ON_RESTART=1 -e RUST_UPDATE_CHECKING=1 -e RUST_UPDATE_BRANCH="prerelease" --name rust-server -d didstopia/rust-server:latest | ||
docker logs -f rust-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env node | ||
|
||
var serverHostname = 'localhost'; | ||
var serverPort = process.env.RUST_RCON_PORT; | ||
var serverPassword = process.env.RUST_RCON_PASSWORD; | ||
|
||
var WebSocket = require('ws'); | ||
var ws = new WebSocket("ws://" + serverHostname + ":" + serverPort + "/" + serverPassword); | ||
ws.on('open', function open() | ||
{ | ||
setTimeout(function() | ||
{ | ||
ws.send(createPacket("say NOTICE: We're updating the server, get to a safe spot!")); | ||
setTimeout(function() | ||
{ | ||
ws.send(createPacket("restart 60")); | ||
setTimeout(function() | ||
{ | ||
ws.close(1000); | ||
}, 1000); | ||
}, 1000 * 60); | ||
}, 1000); | ||
}); | ||
ws.on('close', function close() | ||
{ | ||
process.exit(0); | ||
}); | ||
|
||
function createPacket(command) | ||
{ | ||
var packet = | ||
{ | ||
Identifier: -1, | ||
Message: command, | ||
Name: "WebRcon" | ||
}; | ||
return JSON.stringify(packet); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "restart_app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "app.js", | ||
"scripts": { | ||
"start": "nodejs app.js" | ||
}, | ||
"author": "", | ||
"private": "true", | ||
"dependencies": { | ||
"ws": "^1.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env node | ||
|
||
var debug = false; | ||
|
||
var child_process = require('child_process'); | ||
|
||
var startupDelayInSeconds = 60 * 5; // TODO: Set to 5 minutes | ||
var runIntervalInSeconds = 60 * 15; // TODO: Set to 15 minutes | ||
|
||
if (debug) | ||
{ | ||
startupDelayInSeconds = 1; | ||
runIntervalInSeconds = 60; | ||
} | ||
|
||
// Start the endless loop after a delay (allow the server to start) | ||
setTimeout(function() | ||
{ | ||
checkForUpdates(); | ||
}, 1000 * startupDelayInSeconds); | ||
|
||
function checkForUpdates() | ||
{ | ||
setTimeout(function() | ||
{ | ||
if (debug) console.log("Scheduled update triggered"); | ||
child_process.exec('bash /update_check.sh', { timeout: 60 * 1000, env: process.env }, function (err, stdout, stderr) | ||
{ | ||
if (debug) console.log(stdout); | ||
checkForUpdates(); | ||
}); | ||
}, 1000 * runIntervalInSeconds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "scheduler_app", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "app.js", | ||
"scripts": { | ||
"start": "nodejs app.js" | ||
}, | ||
"author": "", | ||
"private": "true", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -m | ||
|
||
# Check if we are auto-updating or not | ||
if [ "$RUST_UPDATE_CHECKING" = "1" ]; then | ||
echo "Checking Steam for updates.." | ||
else | ||
## REMOVE THIS | ||
echo "Updates disabled" | ||
exit | ||
fi | ||
|
||
# Get the old build id (default to 0) | ||
OLD_BUILDID=0 | ||
if [ -f "/steamcmd/rust/build.id" ]; then | ||
OLD_BUILDID="$(cat /steamcmd/rust/build.id)" | ||
fi | ||
|
||
# Minimal validation for the update branch | ||
STRING_SIZE=${#RUST_UPDATE_BRANCH} | ||
if [ "$STRING_SIZE" -lt "1" ]; then | ||
RUST_UPDATE_BRANCH=public | ||
fi | ||
|
||
# Get the new build id directly from Steam | ||
NEW_BUILDID="$(./steamcmd/steamcmd.sh +login anonymous +app_info_update 1 +app_info_print "258550" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"$RUST_UPDATE_BRANCH\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | sed "s/ buildid //g" | xargs)" | ||
|
||
# Check that we actually got a new build id | ||
STRING_SIZE=${#NEW_BUILDID} | ||
if [ "$STRING_SIZE" -lt "6" ]; then | ||
echo "Error getting latest build id from Steam, automatic updates disabled.." | ||
exit | ||
fi | ||
|
||
# Skip update checking if this is the first time | ||
if [ ! -f "/steamcmd/rust/build.id" ]; then | ||
echo "First time running update check (build id not found), skipping update.." | ||
echo $NEW_BUILDID > /steamcmd/rust/build.id | ||
exit | ||
else | ||
STRING_SIZE=${#OLD_BUILDID} | ||
if [ "$STRING_SIZE" -lt "6" ]; then | ||
echo "First time running update check (build id empty), skipping update.." | ||
echo $NEW_BUILDID > /steamcmd/rust/build.id | ||
exit | ||
fi | ||
fi | ||
|
||
# Check if the builds match and quit if so | ||
if [ "$OLD_BUILDID" = "$NEW_BUILDID" ]; then | ||
echo "Build id $OLD_BUILDID is already the latest, skipping update.." | ||
exit | ||
else | ||
echo "Latest build id ($NEW_BUILDID) is newer than the current one ($OLD_BUILDID), restarting the server and forcing an update.." | ||
echo $NEW_BUILDID > /steamcmd/rust/build.id | ||
node /restart_app/app.js & | ||
exit | ||
fi |