summaryrefslogtreecommitdiff
path: root/media-sound/teamspeak-server/files/teamspeak.initd
blob: cc8393b58db7f2133e6b343f370fb4e4466d1595 (plain)
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
#!/sbin/openrc-run
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

command="/opt/bin/ts3server"
command_background="true"
group="teamspeak"
inifile="/etc/teamspeak3-server/ts3server.ini"
name="TeamSpeak Server"
pidfile="/run/teamspeak3-server/server.pid"
user="teamspeak"

depend() {
	need net
	use mysql
}

start_pre() {
	# ensure, that the TS3-server finds all custom supplied shared objects on startup.
	LD_LIBRARY_PATH="/opt/teamspeak3-server:$LD_LIBRARY_PATH"
	export LD_LIBRARY_PATH

	# temporay fix for EPERM bug (we still leave it here to make sure it is *really* not there)
	rm -f /dev/shm/7gbhujb54g8z9hu43jre8

	checkpath -d --owner ${user}:${group} --mode 0700 /run/teamspeak3-server
}

start() {
	ebegin "Starting ${name}"

	start-stop-daemon --start --quiet --background --env "TS3SERVER_LICENSE=accept" \
		--pidfile "${pidfile}" --make-pidfile \
		--user "${user}" --group "${group}" --chdir "/opt/teamspeak3-server" \
		--exec "${command}" -- \
		inifile="${inifile}"

	eend $?
}

restart() {
	stop
	sleep 3
	start
}