aboutsummaryrefslogtreecommitdiff
blob: 89aec3b2b90f002d44d40eb6121852d11a5dd097 (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
46
47
48
49
50
#!/sbin/openrc-run
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: 12592412748fe9e413480f1884a361542f460a36 $

DIR="/opt/teamspeak3"
name="TeamSpeak Server"
command="${DIR}/bin/ts3server"
command_background="true"
pidfile="/var/run/teamspeak3/server.pid"

depend() {
	need net
	use mysql
}

start_pre() {
	# Ensure that ts3-server finds all custom shared objects on startup
	export LD_LIBRARY_PATH="${DIR}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"

	# ts3-server complains if LANG ic 'C' or unset...
	if [ -n "${TS3_LANG:-}" ]; then
		export LANG="${TS3_LANG}"
	else
		[ -z "${LANG:-}" -o "${LANG}" = 'C' ] && export LANG="en_US.UTF-8"
	fi

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

	checkpath -qd --owner teamspeak3:teamspeak3 --mode 0700 "$( dirname "${pidfile}" )" || return 1
	checkpath -qd --owner teamspeak3:teamspeak3 --mode 0700 "/var/run/teamspeak3" || return 1
	checkpath -qd --owner teamspeak3:teamspeak3 --mode 0755 "${DIR}" || return 1
}

start() {
	ebegin "Starting ${name}"
	start-stop-daemon --start --quiet --background \
		--pidfile "${pidfile}" --make-pidfile \
		--user "teamspeak3" --chdir "${DIR}" \
		--exec "${command}" -- \
		inifile="/etc/teamspeak3/server.conf" ${TS3_ARGS:-}
	eend $?
}

restart() {
	stop
	sleep 3
	start
}