The following is how I installed TShock Terraria Server on a clean Debian Wheezy machine. The same method has been tested working on Ubuntu 12.04 LTS (Precise).
One important difference to other howtos is it does not install mono-complete and the plethora of dependencies that requires (including x11-common). This only installs the required libraries to run, nothing more.
Run these commands individually, this is not to be copy pasted into your shell in full.
Update: A few users are complaining of missing packages, however I have re-run the instructions in a fresh Wheezy guest and found no issues (see transcript of installation here).
Update2: I have successfully tested the following instructions using Ubuntu 12.04 LTS Precise (transcript here)
Update3: Tested working with TShock 4.2
Make sure you are using Debian 7 Wheezy or Ubuntu 12.04 LTS Precise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# Need root sudo su - # Install dependancies apt-get update && apt-get install unzip screen \ mono-runtime libmono-system-core4.0-cil libmono-sqlite4.0-cil libmysql-cil-dev \ libmono-system-runtime-serialization4.0-cil libmono-web4.0-cil libmono-system-xml-linq4.0-cil # Add terraria group and user sudo groupadd --gid 70001 terraria sudo useradd --gid 70001 -d /home/terraria -m --uid 70001 -s /bin/bash terraria # Change user to terraria su terraria # Make and change to bin folder mkdir ~/bin cd ~/bin # Download and extract TShock Terraria Server wget http://cloud.github.com/downloads/TShock/TShock/TShock-4.0.zip unzip TShock-4.0.zip # Fix case-insensitive folder ln -s serverplugins ServerPlugins # Run Terraria for first time, create world # (note down auth code for admin access, and exit-nosave) mono TerrariaServer.exe -ip 0.0.0.0 -port 7777 -maxplayers 8 # Change server password TERRARIAPASSWORD="password"; sed -i "s/("ServerPassword": ")[^"]*(",)$/1${TERRARIAPASSWORD}2/" tshock/config.json # Terraria is now installed, keep reading to setup startup init script # Go back to root exit # Download init script to /etc/init.d/ wget -O /etc/init.d/terraria-server http://www.nooblet.org/blog/download/terraria-init.sh # Fix permissions chmod +x /etc/init.d/terraria-server # Insert to startup insserv -v /etc/init.d/terraria-server # At this point you may want to edit the init script if you are using a # different world-file or server-port # Also by default, the script does not save on exit, see variable: EXIT_COMMAND # Start the server invoke-rc.d terraria-server start # Check its running in screen (press Ctrl-a then d to exit) invoke-rc.d terraria-server connect |
Debian init-script
The following init-script can:
- Connect to the screen console with ./terraria-server connect
- Exits the server cleanly by issuing the “exit” or “exit-nosave” command to the server console
- Fits perfectly if installation was made by the above howto
Download
terraria-init.sh (2.6 KiB, 4,974 hits)
This didn’t work for me. apt-get didnt find some of the packages mentioned in the first step.
libmono-system-runtime-serialization4.0-cil
mono-runtime
@Jeff, make sure you are using Debian Wheezy, this guide is only tested with that.
I just installed a blank Wheezy guest to test this, and is working as it should, both packages are available in the main repository. If you can’t find them something else is wrong.
http://packages.debian.org/wheezy/mono-runtime
http://packages.debian.org/wheezy/libmono-system-runtime-serialization4.0-cil
This also had issues for me. A lot of packages weren’t found. However mono was. But when I run the server for the first time I get an error:
@Jordan, I already tested this couple of days ago on a fresh Wheezy machine. You are obviously not using Wheezy.
Edit: Here is a transcript of the install process up to the first running of Terreria. https://www.nooblet.org/files/terraria-wheezy-install.txt
Hello, my problem is that when I rebooted linux and I want to turn on, turn off or restart the TShock server it writes: Starting TShock Terraria Server terraria_server [fail]. Do you know what can be?
Thanks for the reply
(Sorry for Google translate ;))
I have this issue too
Worked flawlessly, thanks :3
I run wheezy..
Worked great with version 4.2 of Tshock. I am running Debian Wheezy.
Seems to work ok on ubuntu 12.0.4 LTS but line 27 of the transcript says to “# (note down auth code for admin access, and exit-nosave)”.
I did not see Auth code
And…nevermind! I found it. π
On Ubuntu Server 13.10 use insserv commant say’s “not Found”.
Can be fixed with
“sudo ln -s /usr/lib/insserv/insserv /sbin/insserv”
PS: Tested OK with Tshock v4.21103
The init-script doesn’t seem to work. If I start terraria manually with mono, the server works fine and I can connect. If I use your script though, I can’t get into the game. “invoke-rc.d terraria-server connect” just shows:
Terraria Server v1.2.1.2
Saving world. Momentary lag might result from this.
Saving world data: 1%
The status is stuck at 1%. Am I doing something wrong?
How are you running it manually?
Try running the following:
su terraria -c "cd ~terraria/bin/; screen -mS terraria_server $(which mono) /home/terraria/bin/TerrariaServer.exe -port 7777 -world /home/terraria/bin/Terraria/Worlds/test.wld;"
This will run the almost identical command as the init-script but will keep you inside the screen.
If you get an error such as “Unable to read from /dev/pts/0”, then give that file o+rw permissions, ie. chmod o+rw /dev/pts/0
PS. I came accross a possibly unrelated bug where it would create ServerLog.txt in the wrong directory, so adjusted the init-script to change directory prior to launch. I also added more variables to make it a little easier to setup. Re-download the init-script to find the changes, do a diff to see what I changed.
Just set up a TShock server on Ubuntu 12.04 and started thinking of writing some startup-scripts. The init.d script I found here saved a lot of works. Big thanks to the author!
@Cr4zY: Same thing happened to me when I started the server with the startup-script pointing to a non-existant world. Check the “WORLDFILE” variable in the script and make sure it points to an existing world.
On Ubuntu 12.04 I had some problems with the server not shutting down properly. Tracked it down to screen not recognizing the newline character when sending the EXIT_COMMAND to the detached screen in terraria-init.sh line 79.
Changing line 79 from:
su “${USERID}” -c ‘screen -dr ‘${NAME}’ -X stuff “‘${EXIT_COMMAND}’15″‘
to
su “${USERID}” -c ‘screen -dr ‘${NAME}’ -X stuff “‘${EXIT_COMMAND}’$(printf \\r)”
solved this problem for me.
BR, Johan
I tested your change on my Debian machine and it works so I have updated the init script here to use that.
Thanks π
Well, I am using Ubuntu 12.04 and updated your script recently.
I receive the error when I attempt to shut down the server:
Warning: unknown mime-type for “\r” — using “application/octet-stream”
Error: no such file “\r”
It is associated to line 79, with the previous fix that Johan made.
If you could let me know what I can do to solve it, please reply. I’ll keep this on refresh tab. π
Thanks in advance
Doh! It was meant to be “printf” not “print”.
I have adjusted it, sorry.
I was testing the changes to my own server and then editing the online file separately and made a typo π
Hello,
really nice Guide! Got it working really fast,
Im Using an Raspberry Pi (700mhz, 500mb ram, ARM) with “A Debian wheezy port, optimised for the Raspberry Pi” from http://www.raspberrypi.org/downloads
at first everything runs smoothly but after random intervals the Server just goes offline without any information inside the log. (no errors)
Im Using Putty to observe the “screen”.
Just at the momment when the Server Crashes Putty shows:
“[screen is terminating]
root@raspberrypi:~#”
if i use invoke-rc.d terraria-server connect it says “screen not running)
if i use invoke-rc.d terraria-server start
it shows: [FAIL] Starting TShock Terraria Server: terraria_server failed!
invoke-rc.d: initscript terraria-server, action “start” failed.-
if i use “invoke-rc.d terraria-server connect” now it connects and it is allready Loading world data.
I can play again but after some time random crashes ocur.
I have not worked much with linux yet. But i can imagine that the ram is overflowing? or do you have any other idea what is causing the crash.
Greetings Shibi
When linux runs out of RAM it runs the OOM-KILLER, which will begin to destroy processes in order to free up RAM. The easiest way to find out if Terraria will killed due to OOM-KILLER, is to run the command “dmesg”. The kernel writes messages to a wall regularly, errors, driver info etc, all go on this wall, and running dmesg allows you to see the messages since boot.
Also, Terraria is written in .NET and so uses the equivalient mono library on Linux. Unfortunately mono is well known for requiring a disproportionate amount of RAM compared to .NET. π Since writing this guide I have retired the Linux VM used to run Terraria and instead run a Windows VM just for this purpose. Memory requirements for Terraria went from 1.5GB to 750MB and I have an always-on Remote Desktop as well π
Hello,
Thank you so much for the post.
Could I maybe use your init script in my Blog? I would give full credit and add also a Link to your Blog. Love the way it is handling the screen session and you can use it for every gameserver.
Yeah, go for it.
Hi There i have a problem my server runs there is no problem with that but if someone connectΒ΄s they cant load the map file completely ! it stucks on 26% what can i do ?
What does this mean??
Settling liquids: 99%
Starting server…
System.Net.Sockets.SocketException: Address already in use
at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in :0
at System.Net.Sockets.TcpListener.Start (Int32 backlog) [0x00000] in :0
at System.Net.Sockets.TcpListener.Start () [0x00000] in :0
at Terraria.Netplay.ServerLoop (System.Object threadContext) [0x00000] in :0
thx a LOT! great manual. It working with my debian 7.0 x64 on digital ocean with tshock π
Been ages since I used linux, I’m getting this:
/etc/init.d/terraria-server: line 46: [: too many arguments
guessing a space or new line is getting in there somehow, but I’m using the default with no changes. I modified everything to adhere to the default script.
if [ -e /var/run/screen/S-${USERID}/*.${NAME} ]; then return 0; fi
NAME=terraria_server
USERID=terraria
if [[ -e /var/run/screen/S-${USERID}/*.${NAME} ]]; then return 0; fi
Double [[ works.
When I try to connect to the service I get (screen not running).
if [[ -e /var/run/screen/S-${USERID}/*.${NAME} ]]; then return 0; fi
Double [[ doesn’t fail, but when I try to connect to the service I get:
(screen not running)
So it’s probably causing another issue.
this fails when i try to run the server because it is “already running” but when i try to stop it it fails also.
root@raspberrypi:~# invoke-rc.d terraria-server start
[FAIL] Starting TShock Terraria Server: terraria_server (already running) failed!
root@raspberrypi:~# invoke-rc.d terraria-server stop
[FAIL] Stopping TShock Terraria Server: terraria_server failed!
invoke-rc.d: initscript terraria-server, action “stop” failed.
also how can i edit the init file from ssh?
This is brilliant, thank you!