Skip to content

Need help with custom .service

Hey there,

I just installed arch linux to run a teamspeak server. I've already installed Teamspeak and everything runs when I run it as root. I've created a user by doing:

useradd teamspeak3 -m -s /usr/bin/nologin

Now I created a teamspeak3.service so that teamspeak will run on boot and will be run by the user teamspeak3:

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

[Service]
WorkingDirectory=/home/teamspeak3/teamspeak3server
User=teamspeak3
ExecStart=/home/teamspeak3/teamspeak3server/ts3server_startscript.sh start
ExecStop=/home/teamspeak3/teamspeak3server/ts3server_startscript.sh stop
ExecReload=/home/teamspeak3/teamspeak3server/ts3server_startscript.sh restart

For some reason whenever I start the service and show the status it says it failed with (code=exited, status=200/CHDIR) behind the ExecStart and ExecStop.

Could you guys help me out?:)

4 points17 comments
Open on Reddit
About this post
Posted
Archived
Score
4 · 100% up
Kind
Text
ID
2lavs8

Author

4
posts
25
comments
1
media
View profile

18 comments

I suspect you need Type=<something> in the [Service] section, because by default systemd expects the program you run in ExecStart to keep running as long as the service is running. Read man systemd.service for the details of the different options.

Ultimately, it's probably better to figure out what ts3server_startscript.sh start actually does and make the service do that directly.

3 points

Can you try adding Type=forking in the [Service] section. Is there any output in the journal from the script?

Also, for consitency, you might want to add After=network.target so that the server is started after networking and not in parallel.

2 points
R3gnoOP6 hidden

I tried adding the type=forking and it still crashes, the output is changed though:

teamspeak.service - Teamspeak Server Service
Loaded: loaded (/etc/systemd/system/teamspeak.service; static)
Active: failed (Result: exit-code) since Wed 2014-11-05 19:24:52 CET; 16s ago
Process: 2723 ExecStart=/home/teamspeak3/teamspeak3server/ts3server_startscript.sh start (code=exited, status=200/CHDIR)

Nov 05 19:24:52 R3gnoServer systemd[2723]: Failed at step CHDIR spawning /home/teamspeak3/teamspeak3server/ts3server_startscript.sh: No such file or directory

When I cd to /home/teamspeak3/teamspeak3server/ nothing goes wrong and I can see the startscript there...

1 points

Hmmm... Silly question, but does /bin/sh exist on your system?

Either way, can you try prepending /bin/bash (or where ever bash is) to all the Exec directive so they look like this: ExecStart=/bin/bash /home/teamspeak3/teamspeak3server/ts3server_startscript.sh start

1 points

Why not simply use the AUR package that comes with a service and stuff?

2 points
R3gnoOP4 hidden

I'm kind of a newbie and I couldn't get it fixed with the AUR package. So I just downloaded the .tar.gz from teamspeak and started figuring things out myself...

edit: And why not learn how to write a .service by yourself?:)

1 points
unknown author

Deleted before we saved it.

1 points

So instead of using a pre-configured and very well set up package that you only need to install and use (because the package maintainer already did all the necessary work for you) you thought you better do it by yourself because you are a newbie? Makes total sense … :D

-4 points

Not sure on writing services but 'status=200/CHDIR' was the same error I got when starting btsync with the btsync.conf only readable by root. 'ls -l' to make sure user teamspeak3 owns or at least can read that script.

Outside of that I got nothing.

0 points
R3gnoOP1 hidden

the /ts3server_startscript.sh has the following ls -l:

-rwxrwxr-x, so that should be ok right?

1 points

Yeah as long as it's owned by that user that's fine. Sorry can't be any more help.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.