Last active
May 28, 2018 05:27
-
-
Save lekro/563faad8c3d993134ec67ee65667208a to your computer and use it in GitHub Desktop.
Hacked together a set of scripts to run terraria servers using tmux. I don't recommend this. But it's cool since multiple people can use a console at once.
This file contains hidden or 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
#!/bin/bash | |
# Place to put the server socket. Note that this should be owned by root | |
# but owned by, let's say, a group "terraria" | |
TMUX_ROOT=/var/tmux | |
# Root of terraria servers | |
TERRARIA_ROOT=/var/games/terraria | |
# Name of tmux socket to make | |
TMUX_SOCKET_NAME=terraria | |
# Config file to have tmux source. I wanted people in "terraria" group to be able to use the tmux session, | |
# but not to enter commands and masquerade as me. This is actually my attempt to do that, but I don't think it's good. | |
# Fortunately, I trusted people on this machine, so it wasn't a problem. | |
# Just be careful if you are going to do this and maybe have the terraria server run as a terraria user as well. | |
# Actually don't use any of these files as they are given here. They're bad. | |
# Make your own, maybe these will help you if you are stuck. | |
TMUX_FILE_NAME=tmux.conf | |
# Name of tmux session inside the tmux socket | |
TMUX_SESSION_NAME=terraria | |
# Script to run if starting the server. | |
TERRARIA_SCRIPT=terraria.sh | |
# Get the socket path | |
TMUX_SOCKET_PATH="$TMUX_ROOT/$TMUX_SOCKET_NAME" | |
# Try to attach to the session with that name in that socket. If successful, source the given tmux config. | |
# If attaching was unsuccessful, start a new session with same configuration, run the terraria startup script, | |
# and source the tmux config. | |
tmux -S "$TMUX_SOCKET_PATH" attach-session -t "$TMUX_SESSION_NAME" \; source-file "$TERRARIA_ROOT/$TMUX_FILE_NAME" \ | |
|| tmux -S "$TMUX_SOCKET_PATH" new-session -s "$TMUX_SESSION_NAME" "$TERRARIA_ROOT/$TERRARIA_SCRIPT" \; source-file "$TERRARIA_ROOT/$TMUX_FILE_NAME" |
This file contains hidden or 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
world=/var/games/terraria/server/worlds/FC_Terraria_Server.wld | |
worldname=FC_Terraria_Server | |
autocreate=1 | |
maxplayers=8 | |
worldpath=/var/games/terraria/server/worlds | |
motd=Welcome to FrostCraft's Terraria server ~ frost.kapu.moe | |
password=******* |
This file contains hidden or 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
#!/bin/sh | |
DEFAULT_SERVER_ROOT=/var/games/terraria/server | |
# Check if we have been given a SERVER ROOT | |
# If not, use the default. | |
if [ "0$SERVER_ROOT" = "0" ]; then | |
SERVER_ROOT="$DEFAULT_SERVER_ROOT" | |
fi | |
# This binary can be obtained from Terraria's website. | |
# I had a few problems with the server config. I think it has to be in the same directory, | |
# and only an absolute path is allowed. Also, I think it has to have that name. | |
# I'm not sure now, since these comments are mostly post-mortem. | |
# Only the inane comments were actually written at the time I was using these files. | |
"$SERVER_ROOT/TerrariaServer.bin.x86_64" -config "$SERVER_ROOT/serverconfig.txt" |
This file contains hidden or 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
set -g default-command nologin | |
unbind-key ":" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment