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 Core Keeper template #276

Open
wants to merge 6 commits into
base: v2.6
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
5 changes: 5 additions & 0 deletions corekeeper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Notes
This only supports Linux.

## Important
**Make sure to stop the server. If you kill it, the server will still run in the background.**
115 changes: 115 additions & 0 deletions corekeeper/corekeeper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"name": "core-keeper",
"display": "Core Keeper",
"type": "srcds",
"data": {
"world": {
"type": "integer",
"desc": "Which world index to use.",
"display": "World",
"required": true,
"value": "0"
},
"worldname": {
"type": "string",
"desc": "The name to use for the server.",
"display": "World name",
"required": true,
"value": "Core Keeper Server"
},
"worldseed": {
"type": "integer",
"desc": "The seed to use for a new world. Set to 0 to generate random seed.",
"display": "World seed",
"required": true,
"value": "0"
},
"gameid": {
"type": "string",
"desc": "Game ID to use for the server. Needs to be at least 28 characters and alphanumeric, excluding Y,y,x,0,O. Empty or not valid means a new ID will be generated at start.",
"display": "GameID",
"required": false,
"value": ""
},
"datapath": {
"type": "string",
"desc": "Save file location. If not set it defaults to a subfolder named \"DedicatedServer\" at the default Core Keeper save location.",
"display": "Data path",
"required": true,
"value": ""
},
"maxplayers": {
"type": "integer",
"desc": "Maximum number of players that will be allowed to connect to server.",
"display": "Max players",
"required": true,
"value": "100"
},
"worldmode": {
"type": "integer",
"desc": "Sets the world mode for the world. Can be Normal (0), Hard (1), Creative (2), Casual (4). NOTE: Changing between Creative and non-Creative worlds not currently supported.",
"display": "World mode",
"required": true,
"value": "0"
},
"port": {
"type": "integer",
"desc": "What port to bind to. If not set, then the server will use the Steam relay network. If set, the clients will connect to the server directly and the port needs to be open.",
"display": "Port",
"required": false,
"value": ""
},
"ip": {
"type": "string",
"desc": "What IP to bind the server to",
"display": "IP",
"required": true,
"value": "0.0.0.0"
},
"season": {
"type": "integer",
"desc": "Overrides current season by setting to any of None (0), Easter (1), Halloween (2), Christmas (3), Valentine (4), Anniversary (5), CherryBlossom (6), LunarNewYear (7). -1 is default setting where it is set depending on system date. You can use either the season name or the corresponding number.",
"display": "Season",
"required": true,
"value": "-1"
}
},
"install": [
{
"appId": "1963720",
"type": "steamgamedl"
},
{
"type": "writefile",
"target": "CoreKeeperServerLog.txt",
"text": ""
},
{
"type": "writefile",
"target": "_launch.sh",
"text": "#!/bin/bash\n\nxvfbpid=\"\"\nckpid=\"\"\ntailpid=\"\"\ngreppid=\"\"\ninstalldir=\"$(dirname -- \"$0\";)\"\nexepath=\"$installdir/CoreKeeperServer\"\nrequirements=( \"libxi6\" \"xvfb\" )\nshutdown_command=\"shutdown\"\n\nsudo=\"sudo\" && [[ $(id -u) == 0 ]] && sudo=\"\"\nfunction kill_corekeeperserver {\n\tif [[ ! -z \"$ckpid\" ]]; then\n\t\tkill $ckpid\n\t\twait $ckpid\n\tfi\n\tif [[ ! -z \"$xvfbpid\" ]]; then\n\t\tkill $xvfbpid\n\t\twait $xvfbpid\n\tfi\n\tif [[ ! -z \"$tailpid\" ]]; then\n\t\tkill $tailpid\n\t\twait $tailpid\n\tfi\n\tif [[ ! -z \"$greppid\" ]]; then\n\t\tkill $greppid\n\t\twait $greppid\n\tfi\n\texit\n}\n\nfunction shutdown_server {\n\techo \"Shutting down server...\"\n\tkill_corekeeperserver\n}\n\ntrap kill_corekeeperserver EXIT\n\nfor r in \"${requirements[@]}\"\n\ndo\n\techo \"Checking for required package: $r\"\n\tif ! (dpkg -l $r >/dev/null); then\n\t\techo \"Installing missing package: $r\"\n\t\tsleep 1\n\t\t$sudo apt-get update -yy && $sudo apt-get install -yy \"$r\"\n\tfi\ndone\n\nset -m\n\nrm -f /tmp/.X99-lock\n\nXvfb :99 -screen 0 1x1x24 -nolisten tcp &\nxvfbpid=$!\n\nrm -f GameID.txt\n\nchmod +x \"$exepath\"\n\nDISPLAY=:99 LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:$installdir/../Steamworks SDK Redist/linux64/\" \\\n\"$exepath\" -batchmode -logfile CoreKeeperServerLog.txt -world ${world} -worldname \"${worldname}\" -worldseed ${worldseed} -gameid \"${gameid}\" -datapath \"${datapath}\" -maxplayers ${maxplayers} -worldmode ${worldmode} -port ${port} -ip ${ip} -season ${season} \"$@\" &\n\nckpid=$!\n\necho \"Started server process with pid $ckpid\"\n\nwhile [ ! -f GameID.txt ]; do\n\tsleep 0.1\ndone\n\necho \"Game ID: $(cat GameID.txt)\"\n\ntail -f $installdir/CoreKeeperServerLog.txt | grep \"^[userid:[0-9]*] player\" &\ntail_and_grep_pid=$(ps -ho pgid $!)\npids=$(pgrep -ag $tail_and_grep_pid)\ntailpid=$(echo \"$pids\" | awk 'NR==1{print $1}')\ngreppid=$(echo \"$pids\" | awk 'NR==2{print $1}')\n\nwhile true; do\n\tread -p \"\" command\n\tif [ \"$command\" == \"$shutdown_command\" ]; then\n\t\tshutdown_server\n\tfi\ndone"
},
{
"commands": [
"chmod +x _launch.sh"
],
"type": "command"
}
],
"run": {
"stop": "shutdown",
"command": "./_launch.sh"
},
"environment": {
"type": "tty"
},
"supportedEnvironments": [
{
"type": "tty"
}
],
"requirements": {
"os": "linux",
"arch": "amd64"
}
}