在Debian 8上运行TeamSpeak3作为服务

时间:2017-06-07 21:11:19

标签: linux service debian vps

我花了几个小时试图找到解决方案并已经访问过。

我已经陷入了启动服务的状态(其他一切都做得很好,我成功地可以手动启动teampeak服务器)

我发现我的问题与我的Debian版本有关。

我的uname -rv返回:

 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30)

我的上一个服务文件如下:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          ts3
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: TeamSpeak3 Server Daemon
# Description:       Starts/Stops/Restarts the TeamSpeak Server 

Daemon
### END INIT INFO 
set -e

# PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="TeamSpeak3 Server"
NAME=teamspeak3-server
USER=ts3user
DIR=/home/ts3user/teamspeak3-server


DAEMON=$DIR/ts3server_startscript.sh
PIDFILE=/home/ts3user/teamspeak3-server/ts3server.pid
SCRIPTNAME=/etc/init.d/ts3

# Gracefully exit if the package has been removed.
# test -x $DAEMON || exit 0
# sleep 2
su $USER -c $DAEMON $1

我用过

sudo service ts3 start

sudo systemctl start ts3.service

都返回错误:

Job for ts3.service failed. See 'systemctl status ts3.service' and 'journalctl -xn' for details.

sudo service ts3 status return:

 ● ts3.service - LSB: TeamSpeak3 Server Daemon
Loaded: loaded (/etc/init.d/ts3)
Active: failed (Result: exit-code) since Wed 2017-06-07 21:08:45 CEST; 49s ago
Process: 8941 ExecStart=/etc/init.d/ts3 start (code=exited, status=2)

Jun 07 21:08:45 vps419654.ovh.net su[8942]: Successful su for ts3user by root
Jun 07 21:08:45 vps419654.ovh.net su[8942]: + ??? root:ts3user
Jun 07 21:08:45 vps419654.ovh.net su[8942]: pam_unix(su:session): session opened for user ts3us...=0)
Jun 07 21:08:45 vps419654.ovh.net ts3[8941]: Usage: /home/ts3user/teamspeak3-server/ts3server_s...us}
Jun 07 21:08:45 vps419654.ovh.net systemd[1]: ts3.service: control process exited, code=exited ...s=2
Jun 07 21:08:45 vps419654.ovh.net systemd[1]: Failed to start LSB: TeamSpeak3 Server Daemon.
Jun 07 21:08:45 vps419654.ovh.net systemd[1]: Unit ts3.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.

我跟随了很多导游,但都没有成功

my user for this puropse is **ts3user**
TS3 server is located in **/home/ts3user/teamspeak3-server/**
file that start TS3 server is **ts3server_startscript.sh**
file ts3 (service) is located in **/etc/init.d**

我在这个ts3文件中做错了什么?

1 个答案:

答案 0 :(得分:0)

首先使脚本可执行(在ts3的情况下不需要)

sudo chmod +x /home/ts3user/teamspeak3-server/ts3server_startscript.sh

接下来尝试更改文件的所有者

cd /home/ts3user/
chown ts3user:ts3user teamspeak3-server/ -R

然后尝试以ts3user

运行服务器
su - ts3user
cd /home/ts3user/teamspeak3-server/
./ts3server_startscript.sh

如果一切正常,请尝试以此用户身份运行服务

service ts3 start