[ JagoPG Site ]

Setting up a CoreKeeper server

A friend asked me to set up a Core Keeper server to play on different hours together with some more people 👻. We set up a tiny shared machine in Hetzner and seemed to work well on the smallest tier of Cloud service.

Installation Process

I followed this guide to set up the server with steamcmd bash application.

Automatic Update

I wrote this script so I could just forget about updating the server. Finally, I set up a cron job so each 15 minutes the server version is verified:

#!/usr/bin/env bash

# This script updates the Corekeeper server if a new version is available

function get_version() {
    # Get the latest version of the game
    STEAM_GAME_VERSION=$(/usr/games/steamcmd +login anonymous +app_info_update 0 +app_info_print "1963720" +quit | \
        grep -EA 50 "\"branches\"" | grep -EA 5 "\"public\"" | \
        grep -E "\"buildid\"" | awk -F '"' '{print $4}')


    echo $STEAM_GAME_VERSION
}

function update_game() {
    # Updates the game and stores the new version
    sudo -u corekeeper-server -s /bin/bash -c "steamcmd +login anonymous +app_update 1007 validate +app_update 1963720 validate +quit"
    echo $STEAM_GAME_VERSION > $CURRENT_VERSION_FILE
    echo "game updated to version $STEAM_GAME_VERSION"
}

# Set up this variables with your own values 👇👇
SERVER_PROCESS_NAME="corekeeper-server"
CURRENT_VERSION_FILE="$HOME/corekeeper-version.txt"
CURRENT_VERSION=0

# Main process starts here 👇👇
# Get stored version
if [ -f $CURRENT_VERSION_FILE ]; then
    CURRENT_VERSION=$(cat $CURRENT_VERSION_FILE)
    echo "current version is $CURRENT_VERSION"
else
    echo "game version file not found" >&2
    exit 1
fi

STEAM_GAME_VERSION=$(get_version)

# Check if the game version has changed
if [ "$CURRENT_VERSION" != "$STEAM_GAME_VERSION" ]; then
    echo "game version has changed from $CURRENT_VERSION to $STEAM_GAME_VERSION"
else
    echo "game is up to date"
    exit 0
fi

# Update the game and the version file
echo "stopping corekeeper server"
systemctl stop "$SERVER_PROCESS_NAME"

echo "updating game"
update_game

echo "starting corekeeper server"
if systemctl start "$SERVER_PROCESS_NAME"; then
    echo "game updated and server started"
else
    echo "failed to start the server" >&2
    exit 1
fi

Happy gaming! 👾