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.