teamspeak
Contents
About
WIP
Installation
Easy mode
#Automation of install and upgrade (script)
No package - only from tar.
Extract the archive
Configure
Filesystem layout
To make the updates manageable we take some precautions on the filesystem level. Here's the global layout
/etc/teamspeak3/ - config
/var/log/teamspeak3 - logs
/var/lib/teamspeak3 - daemon home with variable data (like files)
/opt/teamspeak3-server_linux_amd64-$VERSION - installation directory
/opt/ts3 symbolic link to installation directory
Tweaks every ts3 installation directory
keep libmariadb.so.2 up2data with a symbolic link to the system file in /usr/lib/x86_64-linux-gnu/libmariadb.so.3
create symbolic link of ./files to /var/lib/teamspeak3/files
create a file ./.ts3server_license_accepted to accept the license
Create a user and group
Creating the user
Directories
Create the config directory
Configuration files
/etc/teamspeak3/ts3server.ini
1 machine_id=
2 voice_ip=0.0.0.0
3 default_voice_port=9987
4 licensepath=/etc/teamspeak3/
5 filetransfer_ip=0.0.0.0
6 filetransfer_port=30033
7 #query_port=10011
8 #query_ip=0.0.0.0
9 query_ip_whitelist=/etc/teamspeak3/query_ip_whitelist.txt
10 query_ip_blacklist=/etc/teamspeak3/query_ip_blacklist.txt
11 query_protocols=ssh,raw
12 #query_ssh_ip=0.0.0.0
13 #query_ssh_port=10022
14 query_ssh_rsa_host_key=/etc/teamspeak3/ssh/ssh_host_rsa_key
15 query_timeout=300
16 #dbplugin=ts3db_mysql
17 dbplugin=ts3db_mariadb
18 #dbpluginparameter=/etc/teamspeak3/ts3db_mysql.ini
19 dbpluginparameter=/etc/teamspeak3/ts3db_mariadb.ini
20 dbsqlpath=sql/
21 #dbsqlcreatepath=create_mysql/
22 dbsqlcreatepath=create_mariadb/
23 dblogkeepdays=90
24 dbclientkeepdays=30
25 logpath=/var/log/teamspeak3
26 logquerycommands=0
27 disable_db_logging=0
28 #version=
29 #daemon=0
30 #pidfile=
31 #crashdumps_path=crashdumps/
32 #create_default_virtualserver=1
33
MariaDB connection parameters
/etc/teamspeak3/ts3db_mariadb.ini
/etc/teamspeak3/query_ip_blacklist.txt may be empty.
But you should whitelist the loopback address.
/etc/teamspeak3/query_ip_whitelist.txt
1 127.0.0.1
Probably deprecated but for completeness
/etc/teamspeak3/settings.ini
1 # ***This is the configuration file for the TSDNS server***
2 #
3 # The format is always "ident=value", where:
4 # ident is a host-name, which should at least for the right hand side be a
5 # valid (DNS) host-name.
6 # On a box known via DNS as "myrootserver.com" sensible idents might be
7 # "myrootserver.com" or "any.combination.of.weird.words.myrootserver.com".
8 # Also allowed is "*" as first character of an ident, which matches any
9 # queries that end with what follows the star. For example "*" matches
10 # always, providing a default answer. "*.myserver.eu" matches every query
11 # that ends with ".myserver.eu", like "foo.myserver.eu".
12 #
13 # The value side is always an IP possibly followed by a ':' and then either
14 # a port of the special string "$PORT".
15 #
16 # Also allowed as value is the special string "NORESPONSE", which makes the
17 # TSDNS server answer not answer this query...this can be useful in scenarios
18 # where multiple TSDNS servers exist and you wish to let "the other" TSDNS
19 # server handle this request. Or you wish regular domain resolving to take
20 # place for some cases.
21 #
22 # Example: The TSDNS server runs on on a box reachable as both as
23 # "teamspeak.com" and as "teamspeak-systems.de"
24 # So we might configure:
25 # public.teamspeak.com=12.13.14.15:10000
26 # test.teamspeak.com=12.13.14.15:12000
27 # private.teamspeak.com=12.13.14.15:14000
28 # voice.teamspeak.com=NORESPONSE
29 # *.teamspeak-systems.de=1.2.3.4:15000
30 # *=12.13.14.15:$PORT
31 #
32 # This way, now clients can connect to "test.teamspeak.com" to reach the test
33 # server, but if they still have the old "teamspeak.com:12000" in their
34 # bookmarks, it will also work thanks to the "*=12.13.14.15:$PORT" line, which
35 # acts as a backwards compatibility mechanism in this case, for everybody not
36 # using the new TSDNS names to connect.
37 #
38 # Starting server version 3.0.13 ipv6 values can also be specified. These are
39 # formated along the line of rfc2732 using [ and ] to encapsulate the address.
40 # For example the localhost port 9987 in ipv6 format would be [::1]:9987. Also
41 # starting 3.0.13, it is possible to specify a list of ip's on a line. An
42 # example would be to specify an ipv4 and ipv6 address, but multiple ipv4 and
43 # ipv6 addresses seperated by a space are allowed. Older clients that do not
44 # support ipv6 and multi value replies, will only recieve the first ipv4
45 # address on the line. For example:
46 # public2.teamspeak.com=[2001:0db8::1]:9987 1.2.3.4:9987 5.6.7.8:9987
47 # will only send 1.2.3.4:9987 to the older clients.
48 #
49 # Lines starting with "#" are ignored by the tsdns server, so to make any
50 # actual configuration you must remove the "#" infront.
51 #
52 # Note that if you want to use any non ascii characters you may do so,
53 # but you should make sure to store this configuration file as UTF8 encoded
54 # document.
55 #
56 ts.rockstable.org=176.9.178.19:9987
57 cf.rockstable.org=176.9.178.19:9988
58 *=176.9.178.19:9987
In the configuration directory is also a
/etc/teamspeak3/serverkey.dat probably for unique identification of the ts3-server
/etc/teamspeak3//etc/teamspeak3/ssh/ssh_host_rsa_key ssh-host-key
(optionally) /etc/teamspeak3/licensekey.dat a non-profit license
Make to set the right permissions.
1 UNAME=teamspeak3
2 ### ALL YOUR FILES BELONG TO ROOT
3 chown root:teamspeak3 \
4 /etc/teamspeak3/{licensekey.dat,ts3db_mariadb.ini,ts3db_mysql.ini,ts3server.ini,tsdns_settings.ini}
5 ### DAEMON MAY WRITE THESE FILES
6 chown teamspeak3:teamspeak3 \
7 /etc/teamspeak3/query_ip_{blacklist,whitelist}.txt \
8 /etc/teamspeak3/serverkey.dat \
9 /etc/teamspeak3/ssh/ssh_host_rsa_key
10 ### PROTECT THE HOST-KEY DIRECTORY
11 chmod 0750 /etc/teamspeak3/ssh
12 ### PROTECT THE HOST-KEY
13 chmod 0640 /etc/teamspeak3/ssh/ssh_host_rsa_key
14 ### MAY READ NOT WRITE VIA GROUP, OTHERS MAY NOT READ
15 chmod 0640 /etc/teamspeak3/{licensekey.dat,ts3db_mariadb.ini,ts3db_mysql.ini}
16 ### MAY READ NOT WRITE, OTHERS MAY READ (NO SECRETS)
17 chmod 0644 /etc/teamspeak3/{ts3server.ini,tsdns_settings.ini} \
18 /etc/teamspeak3/query_ip_{blacklist,whitelist}.txt \
19 /etc/teamspeak3/serverkey.dat
Automation of install and upgrade (script)
To automate installation, upgrades, … i wrote a small shell script. Be aware of the HEREDOCs, there should be tabs for indendation, but you'll copy only spaces.
/opt/bin/upgrade_ts3.sh
1 #!/bin/bash
2
3 ### INIT
4 SELF="$(basename "$0")"
5 DELETE_TMP="y"
6 PREFIX="/opt"
7 PATH_TMP="/tmp"
8 PATH_TSDNS="tsdns"
9 PATH_VAR_TS3="/var/lib/teamspeak3"
10 PATH_ETC_TS3="/etc/teamspeak3"
11 PATH_LIB_MARIADB="/usr/lib/x86_64-linux-gnu/libmariadb.so.3"
12 TS3_CONFIG="ts3server.ini"
13 TSDNS_CONFIG="tsdns_settings.ini"
14 QIPBL="query_ip_blacklist.txt"
15 QIPWL="query_ip_whitelist.txt"
16 CHECK="true"
17 FILE_LICENCE_ACCEPTED=".ts3server_license_accepted"
18 LICENSE_ACCEPTANCE="false"
19 VERBOSE=""
20 USER_TS3="teamspeak3"
21 GROUP_TS3="teamspeak3"
22
23 ### SOURCING TS3 CONFIGURATION AS BASH-SCRIPT
24 if [ -r "$PATH_ETC_TS3/$TS3_CONFIG" ]; then
25 source "$PATH_ETC_TS3/$TS3_CONFIG"
26 fi
27
28 declare -a BIN_TS3=("ts3server" "ts3server_linux_amd64")
29 declare -a BIN_TSDNS=("tsdnsserver" "tsdnsserver_linux_amd64")
30
31 usage () {
32 cat <<-EOH
33 $SELF [options]
34
35 options:
36 -a|--archive
37 -c|--check
38 -e|--exchange
39 -f|--force
40 -h|--help
41 -i|--install
42 -l|--license
43 -p|--prefix
44 -s|--ssh
45 -v|--verbose
46 EOH
47 }
48
49
50 TEMP=$(getopt \
51 -o a:cefhil:p:sv \
52 --long archive,check,exchange,force,help,install,license:,prefix:,ssh,verbose \
53 -n "$SELF" -- "$@")
54
55 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
56
57 # Note the quotes around `$TEMP': they are essential!
58 eval set -- "$TEMP"
59
60 while true ; do
61 case "$1" in
62 -a|--archive) ARCHIVE="$2"; shift 2 ;;
63 -c|--check) CHECK="true" shift ;;
64 -e|--exchange) EXCHANGE="true"; shift ;;
65 -f|--force) FORCE="true"; shift ;;
66 -h|--help) usage; exit 0; shift ;;
67 -i|--install) INSTALL="true"; shift ;;
68 -l|--license) LICENSE_ACCEPTANCE="$2"; shift 2 ;;
69 -p|--prefix) PREFIX="$2"; shift 2 ;;
70 -s|--ssh) SSH="true" shift ;;
71 -v|--verbose) VERBOSE="-v" shift ;;
72 #-c|--c-long)
73 # case "$2" in
74 # "") echo "Option c, no argument"; shift 2 ;;
75 # *) echo "Option c, argument \`$2'" ; shift 2 ;;
76 # esac ;;
77 --) shift ; break ;;
78 *) echo "Internal error!" ; exit 1 ;;
79 esac
80 done
81 #echo "Remaining arguments:"
82 #for arg do echo '--> '"\`$arg'" ; done
83
84 ### SANITY CHECKS
85 if [ -z "$ARCHIVE" ]; then
86 echo "Please specify an (optionally compressed) tar-archive with its absolute path as the update source."
87 exit 2
88 fi
89
90 echo "$LICENSE_ACCEPTANCE"
91 if [ "$LICENSE_ACCEPTANCE" != "accepted" ]; then
92 echo "true"
93 cat <<-EOF
94 License has not been accepted.
95 Service will not start.
96 Please accept license by:
97 touch $FILE_LICENCE_ACCEPTED
98 EOF
99 sleep 3
100 fi
101
102 VERSION=$(sed -r 's/\.tar\..*$//;s/^.*[-_](([[:digit:]]+\.?)+).*$/\1/' <<< $ARCHIVE)
103 DIR_DEST=$(basename ${ARCHIVE%%.tar.*})
104
105 if [ -d "$PREFIX/$DIR_DEST" -a "FORCE" = "false" ]; then
106 echo "Destination directory exists and force was not given. Exiting …"
107 exit 3
108 fi
109
110 ARCHIVE_DIR=$(tar tf "$ARCHIVE" | head -n1)
111 DEST="$PREFIX/$DIR_DEST"
112
113 ### PREPARE TMP
114 if [ -n "$ARCHIVE_DIR" -a -d "$PATH_TMP/$ARCHIVE_DIR" -a "$FORCE" = "false" ]; then
115 echo "Temporary directory $PATH_TMP/$ARCHIVE_DIR exists."
116 read -p "Should it be deleted [Yn]: " DELETE_TMP
117 if [ "${DELETE_TMP,,}" = "y" ]; then
118 rm $VERBOSE -r "$PATH_TMP/$ARCHIVE_DIR"
119 fi
120 fi
121
122 ### INSTALL
123 if [ "$INSTALL" = "true" ]; then
124 echo "Installing and new version \"$VERSION\""
125 tar xf "$ARCHIVE" -C "$PATH_TMP"
126
127 if [ "$LICENSE_ACCEPTANCE" = "accepted" ]; then
128 touch "$PATH_TMP/$ARCHIVE_DIR/$FILE_LICENCE_ACCEPTED"
129 fi
130
131 ### SECURITY
132 chown -R 0:0 "$PATH_TMP/$ARCHIVE_DIR"
133 pushd "$PATH_TMP/$ARCHIVE_DIR"
134 find . -type d -exec chmod 755 {} \;
135 find . -type f -exec chmod 644 {} \;
136 chmod 755 ts3server* tsdns/tsdnsserver
137 popd
138
139 mv $VERBOSE "$PATH_TMP/$ARCHIVE_DIR" "$DEST"
140 ln $VERBOSE -s "$PATH_VAR_TS3/files" "$DEST/files"
141 ln $VERBOSE -s "$PATH_ETC_TS3/$TSDNS_CONFIG" "$DEST/$PATH_TSDNS/$TSDNS_CONFIG"
142 ln $VERBOSE -s "$PATH_LIB_MARIADB" "$DEST/libmariadb.so.2"
143 ### XOR CREATE A SYSTEMWIED SYMBOLIC LINK
144 #cd /usr/lib/x86_64-linux-gnu
145 #ln -s libmariadb.so.3 libmariadb.so.2
146 echo "…done"
147 fi
148
149 ### SSH
150 if [ "$SSH" = "true" ]; then
151 install -o "$USER_TS3" -g "$GROUP_TS3" -m 0750 "$PATH_ETC_TS3/ssh"
152 cat <<-EOF
153 Make sure "query_ssh_rsa_host_key=" points to a file in this directory or
154 teamspeak won't be able to generate a ssh_host_rsa_key and
155 crash instantly (even if "query_protocols=raw").
156 EOF
157 ### PRIVATE KEY IS NOT PROTECTED AND CONCATENATED WITH PUBKEY
158 chown "$USER_TS3":"$GROUP_TS3" "$query_ssh_rsa_host_key"
159 chmod 640 "$query_ssh_rsa_host_key"
160 fi
161
162 ### EXCHANGE SERVICE
163 if [ "$EXCHANGE" = "true" ]; then
164 echo "Stopping, exchanging and starting new version of Teamspeak3."
165 service teamspeak3 stop
166 service tsdns stop
167
168 unlink "$PREFIX/ts3"
169 ln $VERBOSE -s "$DEST" "$PREFIX/ts3"
170
171 service teamspeak3 start
172 service tsdns start
173 echo "done"
174 fi
175
176 ### CHECK
177 if [ "$CHECK" == "true" ]; then
178 for TS3 in ${BIN_TS3[*]}; do
179 PID_TS3=$(pidof $TS3)
180 RETURN_TS3=$?
181 [ "$RETURN_TS3" = 0 ] && break
182 done
183
184 for TSDNS in ${BIN_TSDNS[*]}; do
185 PID_TSDNS=$(pidof $TSDNS)
186 RETURN_TSDNS=$?
187 [ "$RETURN_TSDNS" = 0 ] && break
188 done
189
190 if [ "$RETURN_TS3" = 0 ]; then
191 echo "Teamspeak3 is running fine with PID $PID_TS3."
192 else
193 echo "Teamspeak3 is not running, please check logs."
194 fi
195
196 if [ "$RETURN_TSDNS" = 0 ]; then
197 echo "TeamspeakDNS is running fine with PID $PID_TSDNS."
198 else
199 echo "TeamspeakDNS is not running, please check logs."
200 fi
201 fi
Usage example
1 ### INSTALL/UPGRADE
2 cd /opt
3 wget "https://files.teamspeak-services.com/releases/server/3.13.6/teamspeak3-server_linux_amd64-3.13.6.tar.bz2"
4 /opt/bin/upgrade_ts3.sh \
5 --install --verbose --check --exchange --license accepted \
6 --archive /opt/teamspeak3-server_linux_amd64-3.13.6.tar.bz2
7 /opt/bin/upgrade_ts3.sh \
8 -ivce -l accepted \
9 -a /opt/teamspeak3-server_linux_amd64-3.13.6.tar.bz2
SystemV init scripts
- Introduced privilege separation
- Works very reliable.
A init-script for the ts3server
/opt/bin/tsctl
1 #!/bin/bash
2 # Copyright (c) 2010 TeamSpeak Systems GmbH
3 # All rights reserved
4 #
5 ### BEGIN INIT INFO
6 # Provides: teamspeak3
7 # Required-Start: $remote_fs $syslog mysql-ndb mysql
8 # Required-Stop: $remote_fs $syslog mysql-ndb mysql
9 # Should-Start: $network $named $time
10 # Should-Stop: $network $named $time
11 # Default-Start: 2 3 4 5
12 # Default-Stop: 0 1 6
13 # Short-Description: Start and stop the Teamspeak3 Server
14 # Description: Voice over IP Server for Zocking
15 ### END INIT INFO
16
17 #set -vx
18
19 ### INIT
20 BASENAME="$(basename $0)"
21
22 declare -a BINARY_NAMES
23 BINARY_PATH="/opt/ts3"
24 BINARY_NAME="ts3server"
25 #BINARY_NAMES=("ts3server" "ts3server_linux_x86" "ts3server_linux_amd64" "ts3server_freebsd_x86" "ts3server_freebsd_amd64")
26 DISPLAY_NAME="Executable"
27
28 NON_PRIV_USER="teamspeak3"
29 PID_DIR="/var/run/teamspeak3"
30 PID_FILE="$PID_DIR/ts3server.pid"
31
32 if [ -r "/etc/default/$BASENAME" ]; then
33 . "/etc/default/$BASENAME"
34 fi
35
36 ### RESOLV BINARY PATH
37 BINARY_PATH="$([ -x "$(command -v realpath)" ] \
38 && realpath "$BINARY_PATH" \
39 || readlink -f "$BINARY_PATH")"
40
41 if [ ! "$BINARY_PATH" -o ! "$BINARY_NAME" ] || \
42 [ ! "$PID_DIR" -o ! "$PID_FILE" ] || \
43 [ ! "$NON_PRIV_USER" ]; then
44 cat <<-EOF
45 At least one mandatory option is missing.
46 Please check the values of: BINARY_PATH, BINARY_NAME, NON_PRIV_USER, PID_DIR, PID_FILE
47
48 Exiting…
49 EOF
50 exit 2
51 fi
52
53 cd "$BINARY_PATH"
54 LIBRARYPATH="$BINARY_PATH"
55 COMMANDLINE_PARAMETERS="$COMMANDLINE_PARAMETERS ${2}"
56
57 case "$1" in
58 start)
59 if [ -e "$PID_FILE" ]; then
60 if ( kill -0 $(cat "$PID_FILE") 2> /dev/null ); then
61 echo "$DISPLAY_NAME is already running, try restart or stop."
62 exit 1
63 else
64 cat <<-EOF
65 $PID_FILE found, but no server running.
66 Possibly your previously started server crashed.
67 Please view the logfile for details.
68
69 EOF
70 rm "$PID_FILE"
71 fi
72 fi
73
74 if [ -z "$NON_PRIV_USER" -o "$NON_PRIV_USER" = "root" ]; then
75 echo "WARNING ! For security reasons we advise: DO NOT RUN THE SERVER AS ROOT"
76 c=1
77 while [ "$c" -le 10 ]; do
78 echo -n "!"
79 sleep 1
80 c=$(($c+1))
81 done
82 echo "!"
83 exit 1
84 fi
85
86 echo "Starting the $DISPLAY_NAME."
87
88 if [ -e "$BINARY_NAME" ]; then
89 if [ ! -x "$BINARY_NAME" ]; then
90 echo "${BINARY_NAME} is not executable, trying to set it."
91 chmod u+x "${BINARY_NAME}"
92 fi
93 if [ -x "$BINARY_NAME" ]; then
94 export LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}"
95 [ -d "$PID_DIR" ] || install -o "$NON_PRIV_USER" -g root -d "$PID_DIR"
96
97 if [ -z "$NON_PRIV_USER" ] ; then
98 ${BINARY_PATH}/${BINARY_NAME} ${COMMANDLINE_PARAMETERS} > /dev/null &
99 else
100 #echo "su $NON_PRIV_USER -c \"./${BINARY_NAME} ${COMMANDLINE_PARAMETERS}\" > /dev/null"
101 #su $NON_PRIV_USER -c ${BINARY_PATH}/${BINARY_NAME} ${COMMANDLINE_PARAMETERS} > /dev/null &
102 #sudo -u $NON_PRIV_USER -- $BINARY_PATH/${BINARY_NAME} ${COMMANDLINE_PARAMETERS} > /dev/null &
103 #[ -d "$PID_DIR" ] || install -o "$NON_PRIV_USER" -g root -d "$PID_DIR"
104 #start-stop-daemon --start --background \
105 # --chuid $NON_PRIV_USER --chdir "${BINARY_PATH}" --verbose \
106 # --make-pidfile --pidfile "$PID_FILE" \
107 # --exec "${BINARY_PATH}"/"${BINARY_NAME}" ${COMMANDLINE_PARAMETERS}
108 start-stop-daemon --start --background \
109 --chuid $NON_PRIV_USER --chdir "${BINARY_PATH}" --verbose \
110 --make-pidfile --pidfile "$PID_FILE" \
111 --exec "${BINARY_PATH}"/"${BINARY_NAME}" ${COMMANDLINE_PARAMETERS}
112 fi
113
114 ### STATUS CHECK AND PID HANDLING
115 sync
116 ps -p "$(cat $PID_FILE)" > /dev/null 2>&1
117 if [ "$?" -ne "0" ]; then
118 echo "$DISPLAY_NAME could not start, for details please view the log file."
119 else
120 echo "$DISPLAY_NAME started."
121 fi
122 else
123 echo "${BINARNAME} is not exectuable, cannot start $DISPLAY_NAME."
124 fi
125 else
126 echo "Could not find binary, aborting."
127 exit 5
128 fi
129 ;;
130 stop)
131 if [ -e "$PID_FILE" ]; then
132 echo "Stopping the $DISPLAY_NAME."
133 if ( kill -TERM $(cat "$PID_FILE") 2> /dev/null ); then
134 c=1
135 while [ "$c" -le 300 ]; do
136 if ( kill -0 $(cat "$PID_FILE") 2> /dev/null ); then
137 echo -n "."
138 sleep 1
139 else
140 break
141 fi
142 c=$(($c+1))
143 done
144 fi
145 if ( kill -0 $(cat "$PID_FILE") 2> /dev/null ); then
146 echo "$DISPLAY_NAME is not shutting down cleanly - killing."
147 kill -KILL $(cat "$PID_FILE")
148 else
149 echo "done"
150 fi
151 rm "$PID_FILE"
152 else
153 echo "No $DISPLAY_NAME running ($PID_FILE is missing)."
154 exit 7
155 fi
156 ;;
157 restart)
158 $0 stop && $0 start "${COMMANDLINE_PARAMETERS}" || exit 1
159 ;;
160 status)
161 if [ -e "$PID_FILE" ]; then
162 if ( kill -0 $(cat "$PID_FILE") 2> /dev/null ); then
163 echo "$DISPLAY_NAME is running."
164 else
165 echo "$DISPLAY_NAME seems to have died."
166 fi
167 else
168 echo "No $DISPLAY_NAME running ($PID_FILE is missing)."
169 fi
170 ;;
171 *)
172 echo "Usage: ${0} {start|stop|restart|status}"
173 exit 2
174 esac
175 exit 0
Create some symbolic link to the
If you are on SystemD
Unit-scripts will be introduced in a future release.
Here is a start-script for the Teamspeak3 DNS Server. The script is obsolete, because tsctl unifies the cli
/opt/bin/tsdns_startscript.sh
1 #!/bin/sh
2 # Copyright (c) 2010 TeamSpeak Systems GmbH
3 # All rights reserved
4 #
5 ### BEGIN INIT INFO
6 # Provides: tsdns
7 # Required-Start: $remote_fs $syslog mysql-ndb mysql
8 # Required-Stop: $remote_fs $syslog mysql-ndb mysql
9 # Should-Start: $network $named $time
10 # Should-Stop: $network $named $time
11 # Default-Start: 2 3 4 5
12 # Default-Stop: 0 1 6
13 # Short-Description: Start and stop the Teamspeak3 DNS Server
14 # Description: Voice over IP Server for Zocking
15 ### END INIT INFO
16
17 #set -vx
18
19 [ -r /etc/default/tsdns ] && . /etc/default/tsdns
20
21 D1=$(readlink -f "$0")
22 [ BINARYPATH ] || BINARYPATH="$(dirname "${D1}")"
23 cd "${BINARYPATH}/tsdns"
24 LIBRARYPATH="$(pwd)"
25
26
27 if [ -e "$TSDNS_BIN" ]; then
28 if [ -z "`uname | grep Linux`" -o -z "`uname -m | grep 64`" ]; then
29 echo "Do you have the right TS3 Server package for your system? You have: `uname` `uname -m`, not Linux x86_64."
30 fi
31 BINARYNAME="$TSDNS_BIN"
32 else
33 echo "Could not locate binary file, aborting"
34 exit 5
35 fi
36
37 case "$1" in
38 start)
39 if [ -e "$TSDNS_PID" ]; then
40 if ( kill -0 $(cat "$TSDNS_PID") 2> /dev/null ); then
41 echo "The server is already running, try restart or stop"
42 exit 1
43 else
44 echo "$TSDNS_PID found, but no server running. Possibly your previously started server crashed"
45 echo "Please view the logfile for details."
46 rm "$TSDNS_PID"
47 fi
48 fi
49 if [ "${UID}" = "0" ] && [ -z "$NON_PRIV_USER" ]; then
50 echo WARNING ! For security reasons we advise: DO NOT RUN THE SERVER AS ROOT
51 c=1
52 while [ "$c" -le 10 ]; do
53 echo -n "!"
54 sleep 1
55 c=$((++c))
56 done
57 echo "!"
58 fi
59 echo "Starting the TeamSpeak 3 server"
60 if [ -e "$BINARYNAME" ]; then
61 if [ ! -x "$BINARYNAME" ]; then
62 echo "${BINARYNAME} is not executable, trying to set it"
63 chmod u+x "${BINARYNAME}"
64 fi
65 if [ -x "$BINARYNAME" ] && [ -r "${BINARYPATH}/tsdns/tsdns_settings.ini" ]; then
66 export LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}"
67 if [ -z "$NON_PRIV_USER" ] ; then
68 "${BINARYPATH}"/tsdns/"${BINARYNAME}" > /dev/null &
69 else
70 start-stop-daemon --start --background \
71 --chuid "$NON_PRIV_USER" --chdir "${BINARYPATH}/tsdns" --verbose \
72 --make-pidfile --pidfile "${BINARYPATH}/tsdns/$TSDNS_PID" \
73 --exec "${BINARYPATH}/tsdns/${BINARYNAME}"
74 fi
75 echo $! > "$TSDNS_PID"
76 echo "TeamSpeak 3 DNS server started, for details please view the log file"
77 else
78 echo "${BINARNAME} is not exectuable, cannot start TeamSpeak 3 server"
79 fi
80 else
81 echo "Could not find binary, aborting"
82 exit 5
83 fi
84 ;;
85 stop)
86 if [ -e "$TSDNS_PID" ]; then
87 echo -n "Stopping the TeamSpeak 3 DNS server"
88 if ( kill -TERM $(cat "$TSDNS_PID") 2> /dev/null ); then
89 c=1
90 while [ "$c" -le 300 ]; do
91 if ( kill -0 $(cat "$TSDNS_PID") 2> /dev/null ); then
92 echo -n "."
93 sleep 1
94 else
95 break
96 fi
97 c=$((++c))
98 done
99 fi
100 if ( kill -0 $(cat "$TSDNS_PID") 2> /dev/null ); then
101 echo "Server is not shutting down cleanly - killing"
102 kill -KILL $(cat "$TSDNS_PID")
103 else
104 echo "done"
105 fi
106 rm $TSDNS_PID
107 else
108 echo "No server running ($TSDNS_PID is missing)"
109 exit 7
110 fi
111 ;;
112 restart)
113 "$0" stop && "$0" start || exit 1
114 ;;
115 status)
116 if [ -e "$TSDNS_PID" ]; then
117 if ( kill -0 $(cat "$TSDNS_PID") 2> /dev/null ); then
118 echo "Server is running"
119 else
120 echo "Server seems to have died"
121 fi
122 else
123 echo "No server running ($TSDNS_PID is missing)"
124 fi
125 ;;
126 *)
127 echo "Usage: ${0} {start|stop|restart|status}"
128 exit 2
129 esac
130 exit 0
Ports
ss -tulpen |grep ts
1 Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
2 udp UNCONN 0 0 0.0.0.0:9987 0.0.0.0:* users:(("ts3server",pid=26580,fd=40)) uid:105 ino:28586087 sk:14 <->
3 udp UNCONN 0 0 0.0.0.0:9988 0.0.0.0:* users:(("ts3server",pid=26580,fd=42)) uid:105 ino:28586088 sk:15 <->
4 tcp LISTEN 0 128 0.0.0.0:30033 0.0.0.0:* users:(("ts3server",pid=26580,fd=24)) uid:105 ino:28586077 sk:16 <->
5 tcp LISTEN 0 128 0.0.0.0:10011 0.0.0.0:* users:(("ts3server",pid=26580,fd=44)) uid:105 ino:28586090 sk:18 <->
6 tcp LISTEN 0 128 0.0.0.0:10022 0.0.0.0:* users:(("ts3server",pid=26580,fd=46)) uid:105 ino:28586094 sk:19 <->
7 tcp LISTEN 0 128 *:41144 *:* users:(("tsdnsserver",pid=584,fd=10)) uid:105 ino:19741 sk:f v6only:0 <->
8 tcp LISTEN 0 128 [::]:10011 [::]:* users:(("ts3server",pid=26580,fd=45)) uid:105 ino:28586091 sk:1b v6only:1 <->
9 tcp LISTEN 0 128 [::]:10022 [::]:* users:(("ts3server",pid=26580,fd=47)) uid:105 ino:28586095 sk:1c v6only:1 <->
Log rotation
/etc/cron.daily/ts3
Set script executable
chmod a+x /etc/cron.daily/ts3