Setup a Team-Speak Server with Systemd on QuickBox

The original question was asked here and I figured it’d be good to give this it’s own home spot in the WIki category. All credits to @liara for the thorough explanation.


Systemd is actually a breeze to work with, which is one of the reasons why we have transferred over to this system. However, it is worth noting that init.d scripts will definitely still work using systemd and can be called using the legacy:

service myservice {start,stop,restart,status}

However, that said there are often scripts that can be found by a quick google search. Here is what I was able to come up with. I’ve edited it a bit to ensure that the bug that the original user was experiencing doesn’t get called:

[Unit]
Description=Teamspeak Service
Wants=network.target

[Service]
WorkingDirectory=/srv/ts3
User=admin
ExecStart=/srv/ts3/ts3server_minimal_runscript.sh
ExecStop=/srv/ts3/ts3server_startscript.sh stop
ExecReload=/srv/ts3/ts3server_startscript.sh restart
Restart=always
RestartSec=15

[Install]
WantedBy=multi-user.target

In order for this to work properly, you’ll need to replace a few variables. Ensure WorkingDirectory points to the correct location where TS3 is currently installed and make sure the Start, Stop and Reload commands also point to the same folder. Also change User to the user who is going to be running the daemon

Restart determines if systemd will restart the service in the event it stops. It can also be changed to on-failure. I don’t normally see RestartSec in a service, however I’m assuming that’s the delay before the service restarts. You can also run commands before starting a service or after starting a service with items like ExecStartPre or ExecStartPost.

Really, the best place for information is the systemd.service man page. It has all the information you could want in regards to how to properly write a service.

Once you have the service, place it in /etc/systemd/system – call it something like teamspeak.service. Once the service is installed, call it like every other service, with systemctl.

systemctl enable teamspeak
systemctl start teamspeak

Enable is used to start the process during boot.

2 Likes

Thanks! This is awesome. I’ve been using TS for a long time but never thought of hosting it on my server.

I’ve started with some basic script writing and want to run them at boot or at specific intervals (hourly, etc) Is there a way to test that the .service or script works, do a dry-run or something?

I’m not so sure about a dry run. The ultimate test is usually whether or not your app starts and stays running.

You can verify the current status of the service with

systemctl status myservice

If you’re looking interval based methods of calling a script, cron would likely be the easiest method to implement. systemd tends to focus on running a service and keeping it running. Cron “keeps services running” by nudging them every so often and saying, “Hey you awake?”. If the service dies right after cron checks, the service won’t be restarted until the next cron check. Conversely, if a systemd service dies and restart is specified, the service will be restarted with no delay.