-
Notifications
You must be signed in to change notification settings - Fork 2
/
teamspeak3-server.spec
1613 lines (1309 loc) · 50.4 KB
/
teamspeak3-server.spec
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# How to create a Teamspeak3 server *.rpm with the help of this .spec file
# on Fedora, CentOS 5, 6 or 7:
# 1. install packages for rpm build environment:
# $ sudo yum install rpm-build rpmdevtools redhat-rpm-config
# 2. login as non-root user and call:
# $ rpmdev-setuptree
# 3. save this *.spec file to ~/rpmbuild/SPECS
# 4. This *.spec file was created for version 3.0.13.8. If you want to package
# a different version, change the "version: " number below.
# 5. download the original teamspeak3-server_linux-*.tar.gz from
# http://www.teamspeak.com/?page=downloads and save it to ~/rpmbuild/SOURCES
# You can also use spectool to download the correct file directly:
# $ spectool -g -R teamspeak3-server.spec
# 6. build the rpm:
# $ rpmbuild -bb teamspeak3-server.spec
# 7. On x86_64 architecture, the *.rpm is created as:
# ~/rpmbuild/RPMS/x86_64/teamspeak3-server-3.0.13.8-1.el7.centos.x86_64.rpm
# Two additional packages are created:
# teamspeak3-server-mariadb-3.0.13.8-1.el7.centos.x86_64.rpm (mariadb support)
# teamspeak3-server-backup-3.0.13.8-1.el7.centos.noarch.rpm (daily backup)
# How to perform the server installation with this *.rpm:
# On Fedora 18+ or CentOS 7:
# 1. Install:
# $ sudo yum install teamspeak3-server-3.0.13.8-1.el7.centos.x86_64.rpm
# 2. open firewall (assuming you are using firewalld):
# $ sudo firewall-cmd --permanent --add-service=teamspeak3-server
# $ sudo firewall-cmd --reload
# 3. set the server to autostart:
# $ sudo systemctl enable teamspeak3-server
# 4. start the server:
# $ sudo systemctl start teamspeak3-server
# On CentOS 5 or 6:
# 1. Install:
# $ sudo yum install teamspeak3-server-3.0.13.8-1.el6.x86_64.rpm
# 2. add firewall rules to /etc/sysconfig/iptables (see README.install)
# 3. set the server to autostart:
# $ sudo chkconfig teamspeak3 on
# 4. start the server:
# $ sudo service start teamspeak3
# Please consult the documentation in /usr/share/doc/teamspeak3-server-3.0.13.8.
# See README.install with general information about configuring and running the
# server.
Name: teamspeak3-server
Version: 3.3.1
Release: 1%{?dist}
Summary: TeamSpeak 3 Server
Group: Applications/Internet
License: Teamspeak, see http://sales.teamspeakusa.com/licensing.php
URL: http://www.teamspeak.com/
%ifarch x86_64
%define __tgzarch amd64
%else
%define __tgzarch x86
%endif
# define variables that must exist
%{?!fedora:%define fedora 0}
%define use_systemd 0
%if 0%{?rhel} == 7
%define fedora 19
%endif
# sysv init or systemd
%if 0%{?fedora} >= 18
%define use_systemd 1
%endif
%define __data %{_datadir}/%{name}
%define __dbdir %{_localstatedir}/lib/teamspeak3
%define __etc %{_sysconfdir}/teamspeak3
%define __libdir %{_libdir}/%{name}
%define __tsdnsbin tsdnsserver
%define __ts3serverbin ts3server
%define __user teamspeak3
%define _firewallddir %{_usr}/lib/firewalld/services
Source: http://ftp.4players.de/pub/hosted/ts3/releases/%{version}/%{name}_%{_target_os}_%{__tgzarch}-%{version}.tar.bz2
Requires: logrotate
%if %{use_systemd}
%systemd_requires
BuildRequires: systemd
%else
Requires(post): /sbin/service /sbin/chkconfig
Requires(preun): /sbin/service /sbin/chkconfig
Requires(postun): /sbin/service
%endif
Requires(pre): shadow-utils
%description
TeamSpeak enables people to speak with one another over the Internet.
TeamSpeak is flexible, powerful, scalable client-server software which
results in an Internet based conferencing solution which facilitates
communication between users. This package contains the server.
%package mariadb
Summary: MariaDB support for the Teamspeak 3 server
Group: Applications/Internet
Requires: teamspeak3-server
%description mariadb
MariaDB support for the Teamspeak 3 server.
%package backup
Summary: Scripts for backing up the Teamspeak 3 server
Group: Applications/Internet
License: Public Domain
BuildArch: noarch
Requires: teamspeak3-server, nc
Requires: sqlite >= 3.0
%description backup
Contributed scripts and a cron job to backup the Teamspeak server database and
create snapshots of all virtual server instances on a daily basis.
# no debug package for precompiled binaries
%global debug_package %{nil}
%prep
# extract *.tar.gz
%setup -n %{name}_%{_target_os}_%{__tgzarch} -q
# change documentation encoding to UTF8 and preserve timestamp
#for i in doc/*.txt LICENSE CHANGELOG; do
# iconv -f CP1250 -t UTF8 "$i" -o "$i.new"
# touch -r "$i" "$i.new"
# mv -f "$i.new" "$i"
#done
%install
# create directories
%if %{use_systemd}
%{__install} -d -m 0755 %{buildroot}%{_unitdir}
%{__install} -d -m 0755 %{buildroot}%{_firewallddir}
%else
%{__install} -d -m 0755 %{buildroot}%{_initrddir}
%{__install} -d -m 0755 %{buildroot}%{_localstatedir}/run/teamspeak3
%endif
%{__install} -d -m 0755 %{buildroot}%{_bindir}
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}/cron.d
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}/ld.so.conf.d
%{__install} -d -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d
%{__install} -d -m 0755 %{buildroot}%{_localstatedir}/log/teamspeak3
%{__install} -d -m 0755 %{buildroot}%{__libdir}
%{__install} -d -m 0755 %{buildroot}%{__etc}
%{__install} -d -m 0755 %{buildroot}%{__data}
%{__install} -d -m 0750 %{buildroot}%{__dbdir}
%{__install} -d -m 0750 %{buildroot}%{__dbdir}/backups
%{__install} -d -m 0750 %{buildroot}%{__dbdir}/snapshots
# install files
%{__cp} -a serverquerydocs/ sql/ %{buildroot}%{__data}
%{__cp} -a tsdns/tsdns_settings.ini.sample %{buildroot}%{__etc}/tsdns_settings.ini
%{__install} -m 0755 -p tsdns/%{__tsdnsbin} %{buildroot}%{_bindir}
%{__install} -m 0755 -p %{__ts3serverbin} %{buildroot}%{_bindir}
%{__install} -m 0755 -p libts3db_mariadb.so %{buildroot}%{__libdir}
%{__install} -m 0755 -p libts3db_sqlite3.so %{buildroot}%{__libdir}
%{__install} -m 0755 -p libts3_ssh.so %{buildroot}%{__libdir}
%{__install} -m 0755 -p redist/libmariadb.so* %{buildroot}%{__libdir}
%{__ln_s} %{__data}/serverquerydocs %{buildroot}%{__dbdir}/serverquerydocs
%{__rm} -f tsdns/%{__tsdnsbin}
# create ldconfig configuration for the TS3 libraries
cat <<"EOF" > %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf
%{__libdir}
EOF
# create default ts3server.ini
cat <<"EOF" > %{buildroot}%{__etc}/ts3server.ini
default_voice_port=9987
filetransfer_port=30033
query_port=10011
dbplugin=ts3db_sqlite3
dbpluginparameter=
dbsqlpath=%{__data}/sql/
dbsqlcreatepath=create_sqlite/
query_ip_whitelist=%{__etc}/query_ip_whitelist.txt
query_ip_blacklist=%{__etc}/query_ip_blacklist.txt
logpath=%{_localstatedir}/log/teamspeak3
logquerycommands=1
logappend=1
dbclientkeepdays=365
dblogkeepdays=365
EOF
# create default ts3server.ini.mariadb, in case you want to use mariadb
cat <<"EOF" > %{buildroot}%{__etc}/ts3server.ini.mariadb
default_voice_port=9987
filetransfer_port=30033
query_port=10011
dbplugin=ts3db_mariadb
dbpluginparameter=%{__etc}/ts3db_mariadb.ini
dbsqlpath=%{__data}/sql/
dbsqlcreatepath=create_mariadb/
query_ip_whitelist=%{__etc}/query_ip_whitelist.txt
query_ip_blacklist=%{__etc}/query_ip_blacklist.txt
logpath=%{_localstatedir}/log/teamspeak3
logquerycommands=1
logappend=1
dbclientkeepdays=365
dblogkeepdays=365
EOF
# create default ts3db_mariadb.ini, in case you want to use mariadb
cat <<"EOF" > %{buildroot}%{__etc}/ts3db_mariadb.ini
[config]
host=localhost
port=3306
username=teamspeak
password=__PASSWORD__
database=ts3db
socket=
EOF
# create default whitelist with local addresses
cat <<"EOF" > %{buildroot}%{__etc}/query_ip_whitelist.txt
127.0.0.1
EOF
# create default blacklist (empty)
cat <<"EOF" > %{buildroot}%{__etc}/query_ip_blacklist.txt
EOF
# create default snapshot logon data
cat <<"EOF" > %{buildroot}%{__etc}/snapshot
#user="__QUERYADMIN__"
#pass="__PASSWORD__"
file="%{__dbdir}/snapshots/%%i/ts3-snapshot-%%i-`date +%%Y%%m%%d-%%H%%M%%S`.txt"
EOF
# create logrotate configuration
cat <<"EOF" > %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%{_localstatedir}/log/teamspeak3/ts3server_*.log {
monthly
rotate 6
copytruncate
compress
notifempty
missingok
}
EOF
# create README.install
cat <<"EOF" > README.install
===============================================================================
Teamspeak 3 server rpm installation
Written by Alex Woick <[email protected]> 2012-02-22
Last updated: 2016-03-15
Contents:
1. OVERVIEW
2. OPEN FIREWALL PORTS
3. INSTALL TEAMSPEAK LICENSE
4. DIRECTORIES AND FILES
5. BACKUP YOUR SERVER
6. TSDNSSERVER
7. SRV DNS RECORDS
8. QUERY ADMIN PASSWORD RESET
===============================================================================
1. OVERVIEW
This rpm install of the Teamspeak server distributes the files from the
original *.tar.gz distribution into fhs-conformant destination directories.
It also comes with an enhanced startup file for SYSV init systems or systemd
unit files for Fedora 18+/RHEL 7+/CentOS 7+. It creates directories for the
database, for logfiles and for the ts3server.ini including blacklist and
whitelist files. It contains a working ts3server.ini, which can be customized
according to your needs.
The user %{__user} is created, which is used to run the Teamspeak server.
After installation, the server is ready to be started right away. It will run
out of the box with the default sqlite database.
To activate autostart and start the Teamspeak server, call:
%if %{use_systemd}
$ sudo systemctl --now enable teamspeak3-server
%else
$ sudo chkconfig teamspeak3 on
$ sudo service teamspeak3 start
%endif
If you want that your server is reachable from remote, it is required to open
some ports in the firewall of the Teamspeak server machine. See Chapter 2 on
how to do this.
If you want that your server uses MariaDB as database, install the package
teamspeak3-server-mariadb and use the supplied ts3server.ini.mariadb instead
of ts3server.ini. Note that the default Sqlite database is sufficient for
standalone machines of any size. Only ATHPs will benefit from MariaDB.
IMPORTANT:
%if %{use_systemd}
After starting the Teamspeak server for the first time, call this command to
extract the query admin password and the server admin token from the journal:
$ journalctl -u teamspeak3-server.service
Store the information in a safe place for later use. If you also installed the
package teamspeak3-server-backup, call get-query-admin.sh to extract the query
admin password and add it to the snapshot configuration in %{__etc}/snapshot.
%else
Check the file %{__dbdir}/query-admin-password.txt after server start.
It contains the query admin password and the server admin token after the
server has been started successfully for the first time. Get the file and store
it in a safe place for later use. Don't leave it openly on the server!
%endif
To get administrator access to the new server, use the token with your
Teamspeak client when you connect to the server for the first time. The
Teamspeak client will ask for it when you connect to a new server for the first
time.
===============================================================================
2. OPEN FIREWALL PORTS
2.1. Allow incoming connections
2.1.1. iptables
The iptables firewall configuration is in the file /etc/sysconfig/iptables.
Find the appropriate location for adding new port openings, for example where
port 22 for ssh or port 80 for http traffic is opened. Right after those
existing rules, but before any global REJECT rule or the closing COMMIT rule,
add the following rules for the Teamspeak server:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10011 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 30033 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp -m multiport --dports 9987:9988 -j ACCEPT
In case you add more virtual servers, for example you create 10 virtual servers
which use the ports 9987..9997, modify the last rule accordingly:
-A INPUT -m state --state NEW -m udp -p udp -m multiport --dports 9987:9997 -j ACCEPT
This is an example for a complete firewall configuration that only allows ssh
and Teamspeak access:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10011 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 30033 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp -m multiport --dports 9987:9988 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
%if %{use_systemd}
2.1.2. firewalld
This package comes with service definitions for the Teamspeak and tsdns server.
Enable Teamspeak service:
$ sudo firewall-cmd --permanent --add-service=teamspeak3-server
$ sudo firewall-cmd --reload
%endif
2.2. Outgoing connections
If you run a restrictive firewall that also filters outgoing traffic, it is
required to allow outgoing TCP connections to accounting.teamspeak.com:2008.
If you want weblist support, additionally allow outgoing UDP traffic on port
2010.
2.3. Port forwarding
If you run your server at home behind a router and want access from the
internet, it is required that you forward the Teamspeak ports on your router to
the Teamspeak server in your local network. Forward these ports on your router
to the local IP address of your Teamspeak server machine:
TCP 10011 # query port [only required for query admin access]
TCP 30033 # file transfer port
UDP 9987 # voice port (in case of more virtual servers: add every voice port)
===============================================================================
3. INSTALL TEAMSPEAK LICENSE
Please note that Teamspeak kindly allows operating a server without a license
for noncommercial use. Simply use the server without licence file, if you fit
Teamspeak's definition for noncommercial use and if you don't need more than 32
slots.
But if you require a license and have one, copy your Teamspeak license file
licensekey.dat into %{__dbdir} and adjust ownership and permissions:
$ sudo -i
$ cd %{__dbdir}
$ cp -p /original-path-to-your-licensekey/licensekey.dat .
$ chown %{__user}:%{__user} licensekey.dat
$ chmod 640 licensekey.dat
%if %{use_systemd}
$ systemctl restart teamspeak3-server
%else
$ service teamspeak3 restart
%endif
$ exit
It is very important to chown the license file to the Teamspeak user, so the
server is able to update the file to renew the license before it expires. If
the server is not able to update the license file, the license will expire and
you will have to contact Teamspeak to get a new one.
===============================================================================
4. DIRECTORIES AND FILES
Documentation:
%{_docdir}/%{name}-%{version}
Server Configuration:
%{__etc}/ts3server.ini
%{__etc}/query_ip_blacklist.txt
%{__etc}/query_ip_whitelist.txt
# stored query admin username and password for snapshot backup operations
%{__etc}/snapshot
Startup options, optionally to be created manually:
%{_sysconfdir}/sysconfig/teamspeak3
%if %{use_systemd}
Unit files:
%{_unitdir}/teamspeak3-server.service
%{_unitdir}/tsdns-server.service
%else
Startup script:
%{_initrddir}/teamspeak3
%{_initrddir}/tsdnsserver
%endif
Teamspeak database directory:
%{__dbdir}
Log file directory:
%{_localstatedir}/log/teamspeak3
%if %{use_systemd} == 0
Pid file (used by the startup script):
%{_localstatedir}/run/teamspeak3/ts3server.pid
%endif
SQL scripts and query admin help files:
%{__data}
Server and tools binary:
%{_bindir}/%{__ts3serverbin}
%{_bindir}/%{__tsdnsbin}
%{_bindir}/ts3snapshot (create and deploy virtual server snapshots)
%{_bindir}/ts3backup_cron (cron job for snapshots and database backup)
Database plugins and libraries:
%{__libdir}/libts3db_mariadb.so
%{__libdir}/libts3db_sqlite3.so
===============================================================================
5. BACKUP YOUR SERVER
The optional package teamspeak3-server-backup installs a cron job that creates
snaphots for every virtual server instance once a day. It's highly recommended,
if you don't do your own instance backup.
Snapshot and backup files older than 60 days are removed automatically.
The snapshot creation script uses the query admin login credentials from
%{__etc}/snapshot.
%if %{use_systemd}
After the first start of the Teamspeak server, call:
$ get-query-admin.sh
This will extract the query admin password from the journal and store it in
%{__etc}/snapshot.
%endif
If the credentials have not been entered automatically, edit the file manually.
Snapshots are stored here with a subdirectory for each server instance:
%{__dbdir}/snapshots
If you want to restore or deploy a virtual server with one of the snaphot
files, call:
$ ts3snapshot deploy -i <instance> -f %{__dbdir}/snapshots/<instance>/ts3-snapshot-<instance>-<date>.txt
The backup files are stored in this location:
%{__dbdir}/backups
Additionally, you should backup the following files regularly to be able to
restore your server:
%{__dbdir}/files/*
%{__dbdir}/licensekey.dat (in case you have a license installed)
%{__dbdir}/serverkey.dat
%{__dbdir}/ts3server.sqlitedb
%{__etc}/snapshot
%{__etc}/ts3server.ini
%{__etc}/query_ip_blacklist.txt
%{__etc}/query_ip_whitelist.txt
%{_sysconfdir}/sysconfig/teamspeak3
If you need to restore the Teamspeak server database, stop the Teamspeak server
and copy one of the datase backup files over the existing database:
%if %{use_systemd}
$ systemctl stop teamspeak3-server
$ cd %{__dbdir}
$ cp backups/ts3server.sqlitedb.YYYYMMDD-HHMMDD ts3server.sqlitedb
$ systemctl start teamspeak3-server
%else
$ service teamspeak3 stop
$ cd %{__dbdir}
$ cp backups/ts3server.sqlitedb.YYYYMMDD-HHMMDD ts3server.sqlitedb
$ service teamspeak3 start
%endif
There is an important difference between database backups and snapshots:
A snapshot always contains one single virtual server instance. If you need to
move one virtual server instance from one host to another, or if you need to
copy one virtual server to another instance or host, create and deploy a
snapshot.
There is one caveat with using snapshots: the connection between uploaded
channel files and the actual channel is lost. It is lost even if you restore
a virtual server on the same host, since all server objects (channels, groups
and users) get new id numbers.
A database backup always contains the whole server with every virtual server
instance. Restoring a database backup always restores every virtual server. It
is not possible to restore a single server instance by using a database backup.
In contrast to snapshots, the connection between uploaded channel files and the
channels is not lost. If you restore a server, uploaded files remain
accessible.
===============================================================================
6. TSDNSSERVER
A start script for tsdnsserver is installed as well. To activate autostart and
start tsdnsserver, call:
%if %{use_systemd}
$ sudo systemctl --now enable tsdns-server
%else
$ sudo chkconfig tsdnsserver on
$ sudo service tsdnsserver start
%endif
The configuration is in %{__etc}/tsdns_settings.ini. After you change the
configuration, restart the server:
%if %{use_systemd}
$ sudo systemctl reload tsdns-server
%else
$ sudo service tsdnsserver restart
%endif
It you use tsdnsserver, you need to open port 41144 in your firewall:
%if %{use_systemd}
$ sudo firewall-cmd --permanent --add-service=tsdns-server
$ sudo firewall-cmd --reload
else
-A INPUT -m state --state NEW -m tcp -p tcp --dport 41144 -j ACCEPT
%endif
Usually, you will not want to use tsdnsserver but use SRV dns records instead.
===============================================================================
7. SRV DNS RECORDS
If you want that your users connect to your server by using a simple hostname,
you may want to create SRV records for your virtual Teamspeak instances if
you have control over your domains' DNS. No more cryptic IP address or port
number for your users.
In this example, you want to support 4 clans called clanalpha, clanbeta,
clangamma and clandelta and give them individual Teamspeak hostnames like
clanalpha.example.org.
You collect these prerequisites:
- your server machine has an IP address of 1.2.3.4
- your server machine has the hostname www.example.org
- Teamspeak server is installed on this server machine
- you configured 4 Teamspeak server instances on ports 9987, 9988, 9989, 9990
- you can already connect successfully to the instances by using 1.2.3.4:9987
or www.example.org:9987 as connection data.
- you are able to configure SRV records in your domain example.org
You plan these assignments:
IP-address=hostname port Teamspeak-hostname
1.2.3.4=www.example.org 9987 clanalpha.example.org
1.2.3.4=www.example.org 9988 clanbeta.example.org
1.2.3.4=www.example.org 9989 clangamma.example.org
1.2.3.4=www.example.org 9990 clandelta.example.org
Now you create the following SRV records into your dns zone for example.org:
$ORIGIN example.org.
_ts3._udp.clanalpha 3600 SRV 10 5 9987 www.example.org.
_ts3._udp.clanbeta 3600 SRV 10 5 9988 www.example.org.
_ts3._udp.clangamma 3600 SRV 10 5 9989 www.example.org.
_ts3._udp.clandelta 3600 SRV 10 5 9990 www.example.org.
To verify that these entries are active in the dns, enter these commands:
For clanalpha:
$ dig srv _ts3._udp.clanalpha.example.org +short
Expected output:
10 5 9987 www.example.org.
For clanbeta:
$ dig srv _ts3._udp.clanbeta.example.org +short
Expected output:
10 5 9988 www.example.org.
etc.
If there is no output, the entries are not active.
From now on, your clanalpha users can connect to your Teamspeak servers by
simply connecting to clanalpha.example.org without port number. Your clanbeta
users use clanbeta.example.org, and so on.
If you move your Teamspeak server away from your web server, for example to
ts.example.org on 1.2.3.5, you only need to change your SRV records:
$ORIGIN example.org.
_ts3._udp.clanalpha 3600 SRV 10 5 9987 ts.example.org.
_ts3._udp.clanbeta 3600 SRV 10 5 9988 ts.example.org.
_ts3._udp.clangamma 3600 SRV 10 5 9989 ts.example.org.
_ts3._udp.clandelta 3600 SRV 10 5 9990 ts.example.org.
Your users don't need to change anything.
Even if you run your Teamspeak server at home and use a dynamic hostname for
it, for example "mytsathome.dyndns.org", it is possible to hide the dynamic
hostname for your Teamspeak users. The only thing you need is control over your
domain example.org. This scenario applies if you only have rented webspace
with your own domain, but without the possibility of installing the Teamspeak
server on the webspace.
$ORIGIN example.org.
_ts3._udp.clanalpha 3600 SRV 10 5 9987 mytsathome.dyndns.org.
_ts3._udp.clanbeta 3600 SRV 10 5 9988 mytsathome.dyndns.org.
_ts3._udp.clangamma 3600 SRV 10 5 9989 mytsathome.dyndns.org.
_ts3._udp.clandelta 3600 SRV 10 5 9990 mytsathome.dyndns.org.
Your users still use clanalpha.example.org, clanbeta.example.org, etc. to
connect to your Teamspeak server.
===============================================================================
8. QUERY ADMIN PASSWORD RESET
To reset the query admin password without restarting the Teamspeak server,
simply call the contributed script /usr/bin/ts3-reset-query-admin.sh.
It creates a new random serveradmin password, sets this password in the
Teamspeak database, and prints it to stdout.
If you want to do this manually to have control over the process, use these
commands:
$ echo -n 'the!New1Password2' | openssl dgst -binary -sha1 | openssl base64
kUOY5N1LFgSOVsKq689XHdYtJnQ=
$ sqlite3 ts3server.sqlitedb
sqlite> UPDATE clients SET client_login_password='kUOY5N1LFgSOVsKq689XHdYtJnQ=' WHERE
client_login_name='serveradmin';
This is not an officially supported way to reset the password, but it works
nonetheless.
EOF
%if %{use_systemd}
# create teamspeak3-server unit file for systemd
cat <<"EOF" > %{buildroot}%{_unitdir}/teamspeak3-server.service
[Unit]
Description=TeamSpeak 3 Server
Documentation=file:/%{_docdir}/%{name}-%{version}/README.install
After=nss-lookup.target network.target
[Service]
User=%{__user}
UMask=0027
WorkingDirectory=%{__dbdir}
ExecStart=%{_bindir}/%{__ts3serverbin} inifile=%{__etc}/ts3server.ini
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# create tsdns-server unit file for systemd
cat <<"EOF" > %{buildroot}%{_unitdir}/tsdns-server.service
[Unit]
Description=TeamSpeak 3 TSDNS Server
Documentation=file:/%{_docdir}/%{name}-%{version}/README.install
After=network.target
[Service]
User=%{__user}
WorkingDirectory=%{__etc}
ExecStart=%{_bindir}/%{__tsdnsbin}
ExecReload=%{_bindir}/%{__tsdnsbin} --update
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# create teamspeak server service file for firewalld
cat <<"EOF" > %{buildroot}%{_firewallddir}/teamspeak3-server.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Teamspeak 3 Server</short>
<description>TeamSpeak enables people to speak with one another over the Internet.</description>
<port protocol="udp" port="9987-9999"/>
<port protocol="tcp" port="10011"/>
<port protocol="tcp" port="30033"/>
</service>
EOF
# create tsdns server service file for firewalld
cat <<"EOF" > %{buildroot}%{_firewallddir}/tsdns-server.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Teamspeak 3 TSDNS Server</short>
<description>TSDNS for Teamspeak enables Teamspeak-specific name resolution services.</description>
<port protocol="tcp" port="41144"/>
</service>
EOF
cat <<"EOF" > %{buildroot}%{_bindir}/get-query-admin.sh
#!/bin/sh
# Read the Teamspeak 3 query admin password from the journal and write it to
# %{__etc}/snapshot, which is used by the database backup
# utility script.
test -f %{__etc}/snapshot || exit 0
grep -q "#user=\"__QUERYADMIN__\"" %{__etc}/snapshot || exit 0
journalctl -u teamspeak3-server.service | grep -o "loginname= .*" |
while read -r kwuser queryadmin kwpass password; do
sed -i "s/#\?user=\".*\"/user=${queryadmin%,}/g" %{__etc}/snapshot
sed -i "s/#\?pass=\".*\"/pass=$password/g" %{__etc}/snapshot
done
EOF
%else
# create server startup script
cat <<"EOF" > %{buildroot}%{_initrddir}/teamspeak3
#!/bin/sh
# teamspeak3 Startup script written by Alex Woick <[email protected]> 2012-02-22
# chkconfig: - 95 5
# description: TeamSpeak 3 Server
# processname: %{__ts3serverbin}
# config: %{_sysconfdir}/sysconfig/teamspeak3
# pidfile: %{_localstatedir}/run/teamspeak3/ts3server.pid
# TeamSpeak 3
# Copyright TeamSpeak Systems GmbH
# http://www.teamspeak.com
# Source function library.
. /etc/rc.d/init.d/functions
exec=%{_bindir}/%{__ts3serverbin}
prog=$(basename $exec)
config=%{__etc}/ts3server.ini
snapconf=%{__etc}/snapshot
dbdir=%{__dbdir}
pidfile=%{_localstatedir}/run/teamspeak3/ts3server.pid
ts3user=%{__user}
[ -e %{_sysconfdir}/sysconfig/teamspeak3 ] && . %{_sysconfdir}/sysconfig/teamspeak3
lockfile=%{_localstatedir}/lock/subsys/teamspeak3
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
[ -f "$pidfile" ] && checkpid `cat $pidfile` && return 0
# check if tmpfs is mounted, add entry to fstab if necessary
if ! mount|grep -q "/dev/shm"; then
mount -t tmpfs tmpfs /dev/shm
grep -q "/dev/shm" /etc/fstab || echo "tmpfs /dev/shm tmpfs rw 0 0" >> /etc/fstab
fi
echo -n $"Starting Teamspeak 3 server $prog: "
errout=$dbdir/query-admin-password.txt
if grep -q "^dbplugin=ts3db_sqlite3" $config; then
if [ -s $dbdir/ts3server.sqlitedb ]; then
errout="/dev/null"
else
echo
echo 1>&2 "This is the first start of a new Teamspeak 3 server."
echo 1>&2 "Check $errout for the query admin password"
echo 1>&2 "and the server admin token if the database was created successfully."
echo -n $"Starting"
fi
fi
if [ "$errout" != "/dev/null" ]; then
echo "Teamspeak server started on `date`" >> $errout
chown $ts3user:root $errout
chmod 0640 $errout
fi
cd $dbdir
runuser -s /bin/bash $ts3user -c "
umask 0027
$exec inifile=$config 1>/dev/null 2>>$errout &
umask 0022
echo -n \$! > $pidfile
"
sleep 3
[ -f "$pidfile" ] && checkpid `cat $pidfile`
retval=$?
if [ "$retval" -eq 0 ]; then
success
touch $lockfile
if [ "$errout" != "/dev/null" -a -f $snapconf ]; then
# copy query admin name and password to snapshot login data
if grep -q "#user=\"__QUERYADMIN__\"" $snapconf; then
grep "loginname= " $errout |
while read -r kwuser queryadmin kwpass password; do
sed -i "s/#\?user=\".*\"/user=${queryadmin%,}/g" $snapconf
sed -i "s/#\?pass=\".*\"/pass=$password/g" $snapconf
done
fi
fi
else
failure
rm -f $pidfile $lockfile
fi
echo
return $retval
}
stop() {
echo -n $"Stopping Teamspeak 3 server $prog: "
killproc -p $pidfile $exec
retval=$?
echo
[ $retval -eq 0 ] && rm -f $pidfile $lockfile
return $retval
}
restart() {
stop
start
}
case "$1" in
start|stop|restart)
$1
;;
reload|force-reload)
restart
;;
try-restart|condrestart)
[ -f $lockfile ] && restart || :
;;
status)
status -p $pidfile $exec
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
EOF
# create tsdns startup script
cat <<"EOF" > %{buildroot}%{_initrddir}/tsdnsserver
#!/bin/sh
# tsdnsserver Startup script written by Alex Woick <[email protected]> 2012-02-22
# chkconfig: - 95 5
# description: tsdnsserver for TeamSpeak 3 Server
# processname: %{__tsdnsbin}
# config: %{_sysconfdir}/sysconfig/teamspeak3
# pidfile: %{_localstatedir}/run/teamspeak3/tsdnsserver.pid
# TeamSpeak 3
# Copyright TeamSpeak Systems GmbH
# http://www.teamspeak.com
# Source function library.
. /etc/init.d/functions
exec=%{_bindir}/%{__tsdnsbin}
prog=$(basename $exec)
configdir=%{__etc}
pidfile=%{_localstatedir}/run/teamspeak3/tsdnsserver.pid
ts3user=%{__user}
[ -e %{_sysconfdir}/sysconfig/teamspeak3 ] && . %{_sysconfdir}/sysconfig/teamspeak3
lockfile=%{_localstatedir}/lock/subsys/tsdnsserver
start() {
[ -f "$pidfile" ] && checkpid `cat $pidfile` && return 0
# check if tmpfs is mounted, add entry to fstab if necessary
if ! mount|grep -q "/dev/shm"; then
mount -t tmpfs tmpfs /dev/shm
grep -q "/dev/shm" /etc/fstab || echo "tmpfs /dev/shm tmpfs rw 0 0" >> /etc/fstab
fi
echo -n $"Starting tsdnsserver $prog: "
cd $configdir
runuser -s /bin/bash $ts3user -c \
"$exec 1>/dev/null 2>/dev/null & echo -n \$! > $pidfile"
sleep 3
[ -f "$pidfile" ] && checkpid `cat $pidfile`
retval=$?
[ "$retval" -eq 0 ] && success || failure
[ "$retval" -eq 0 ] && touch $lockfile || rm -f $pidfile
echo
return $retval
}
stop() {
echo -n $"Stopping tsdnsserver $prog: "
killproc -p $pidfile $exec -TERM
retval=$?
echo
[ $retval -eq 0 ] && rm -f $pidfile $lockfile
return $retval
}
restart() {
stop
start
}
case "$1" in
start|stop|restart)
$1
;;
force-reload)
restart
;;
try-restart|condrestart)
[ -f $lockfile ] && restart || :
;;
reload)
echo -n $"Reloading tsdnsserver $prog: "
cd $configdir
runuser -m -s /bin/bash - $ts3user -c "$exec --update"
success
echo
exit 0
;;
status)
status -p $pidfile $exec
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
EOF
%endif
# create script for creating virtual server snapshots
cat <<"EOF" > %{buildroot}%{_bindir}/ts3snapshot
#!/bin/sh