суббота, 17 марта 2012 г.

TS3 MySQL Debian Squeeze [EN]

Installing Team Speak 3 with MySQL database server on Debian Squeeze howto

Here we will install TS3 3.0.2 server on Debian Squeeze sever. I'm discribing installation on amd64 architecture.

First, make directory structure for customizing
cd ~
mkdir ./ts3s
mkdir ./ts3s/deb
cd ./ts3s
We need the TS3 package for out architecture (I am using amd64) and library libmysqlclient.15.so (In Squeeze there is no this library, we will use Lenny package). Go to TS3 website add get a link for downloading TS3 server tar.gz for your architecture (I am using amd46).
After that go to http://packages.debian.org/ru/lenny/libmysqlclient15off (From now - http://archive.debian.org/debian/pool/main/m/mysql-dfsg-5.0/ ) and get a link for .deb package for your architecture FOR 'LENNY'. We will use Lenny package is Squeeze
wget http://teamspeak.gameserver.gamed.de/ts3/releases/3.0.2/teamspeak3-server_linux-amd64-3.0.2.tar.gz 
wget http://archive.debian.org/debian/pool/main/m/mysql-dfsg-5.0/libmysqlclient15off_5.0.51a-24+lenny5_amd64.deb
Install MySQL server and tools
sudo apt-get install mysql-server mysql-client 
Then install the libmysqlclient.15 library:

sudo dpkg -i ./libmysqlclient15off_5.0.51a-24+lenny5_amd64.deb
Unpack the TS3 server
tar -xvf ./teamspeak3-server_linux-amd64-3.0.2.tar.gz
Make directory structure for debian-style installation
mkdir ./deb/etc
mkdir ./deb/usr
mkdir ./deb/var
mkdir ./deb/etc/init.d
mkdir ./deb/etc/ts3-server
mkdir ./deb/usr/lib
mkdir ./deb/usr/lib/ts3-server
mkdir ./deb/usr/bin
mkdir ./deb/usr/share
mkdir ./deb/usr/share/ts3-server
mkdir ./deb/var/ts3-server 
Copy files from original TS3 distro to our new debian-style TS3 directory structure.
Note that we do not copy DOC, CopyRight etc files, as we do not really need them.
echo Copying and renaming an executable..
cp ./teamspeak3-server_linux-amd64/ts3server_linux_amd64 ./deb/usr/bin/ts3-server 
echo Copying SQL-TS3 Libraries
cp ./teamspeak3-server_linux-amd64/libts3db_*sql*.so ./deb/usr/lib/ts3-server/
echo Copying SQL-TS3 statement templates
cp --recursive ./teamspeak3-server_linux-amd64/sql ./deb/usr/share/ts3-server/
Now you have to create some files for using TS3.

echo Creating LICENSE file. Replace it if you have one. 
touch ./deb/etc/ts3-server/licensekey.dat 
echo Creating MYSQL-CONF file. You shold edit it 
touch ./deb/etc/ts3-server/ts3-server.mysql 
echo Creating COMMANDLINE-CONF file. You should edit it 
touch ./deb/etc/ts3-server/ts3-server.mysql 
echo Creating INIT.D file. You should edit it 
touch ./deb/etc/init.d/ts3-server
echo filling them with data
echo 'machine_id=MachineId' >  ./deb/etc/ts3-server/ts3-server.cmdlines
echo 'dbplugin=ts3db_mysql' >>  ./deb/etc/ts3-server/ts3-server.cmdlines
echo 'dbsqlcreatepath=create_mysql/' >>  ./deb/etc/ts3-server/ts3-server.cmdlines
echo 'query_ip=' >>  ./deb/etc/ts3-server/ts3-server.cmdlines
echo 'dbpluginparameter=/etc/ts3-server/ts3-server.mysql' >>  ./deb/etc/ts3-server/ts3-server.cmdlines
echo '[config]' >  ./deb/etc/ts3-server/ts3-server.mysql
echo 'host=localhost' >>  ./deb/etc/ts3-server/ts3-server.mysql
echo 'port=3306' >>  ./deb/etc/ts3-server/ts3-server.mysql
echo 'username=ts3s-default' >>  ./deb/etc/ts3-server/ts3-server.mysql
echo 'password=somepassword' >>  ./deb/etc/ts3-server/ts3-server.mysql
echo 'database=ts3db_default' >>  ./deb/etc/ts3-server/ts3-server.mysql
echo 'socket=' >>  ./deb/etc/ts3-server/ts3-server.mysql

Then we have to make a init.d script for starting our TS3 server. It is based on original ts3server_startscript.sh but adds debian-style structure, separate low-priveledged user and so on.
You can view on pastebin  http://pastebin.com/H7wPSsNM  . You have to download it too
sudo wget http://pastebin.com/download.php?i=H7wPSsNM
 -O ./deb/etc/init.d/ts3-server
chmod +x ./deb/etc/init.d/ts3-server
After that we should start mysql and create database for TS3 server and mysql user
sudo /etc/init.d/mysql start
Log in to MySQL shell (with password you entered at install time)
mysql -u root -p
And execute commands:
Replace ts3db with database name you prefer. It is not good idea to share database with any else service.
Create a TS3Server MYSQL user `ts3server` with password `somepassword` (remember it) and grant him access to any tables in database `ts3db`)
GRANT ALL PRIVILEGES on ts3db.* TO ts3server@localhost IDENTIFIED BY 'somepassword';
Exit MySQL console
Now you should install the directory structure we made to root (/) of our fs.
sudo cp --recursive ./deb/* /
And edit some parameters.
First, edit machine_id. It is almot useless unless you run multiple servers.
sudo nano /etc/ts3-server/ts3-server.cmdlines
Edit the machine_id= field, then press CTRL+X and say Y
Not that this file does not accept any comments in it. All strings are added as command-line parameters to executable when starting.

Second, edit the MySQL parameters.
sudo nano /etc/ts3-server/ts3-server.mysql
Edit parameters you need, press CTRL+X and say Y

Third, add a new user for TS3. By default, it uses ts3-server user in ts3-server group, so add this. If there is no such user, startup script will create it.
sudo /usr/sbin/adduser --system --no-create-home --shell /bin/true --group --disabled-password --disabled-login ts3-server
(!) Initial run differs from others.
sudo /etc/init.d/ts3-server nodaemon clear_database=1
Then you will see something like this:
                      I M P O R T A N T
              Server Query Admin Acccount created
         loginname= "serveradmin", password= "IGKPLW2s"
                      I M P O R T A N T
      ServerAdmin privilege key created, please use it to gain
      serveradmin rights for your virtualserver. please
      also check the doc/privilegekey_guide.txt for details.
Copy all marked red into safe place. The first one is server admin password. It can be used when accessing TS3 Server by QueryConsole (TS3WebInterface uses it). The second one is PRIVELEGE KEY.  

Press CTRL+C and you will see 
INFO    |ServerMain    |   | Received signal SIGINT, shutting down.
INFO    |VirtualServer |  1| stopped
Then, try to start your TS3-server in normal mode
sudo /etc/init.d/ts3-server start
Check if it is running
sudo netstat --numeric --listening --programs | grep ts3-server

You will see
tcp        0      0 *               LISTEN      18551/ts3-server 
tcp        0      0 *               LISTEN      18551/ts3-server 
udp        0      0  *                           18551/ts3-server
Now let the server start automatically
sudo update-rc.d ts3-server defaults

Check it is added
ls /etc/rc2.d/ | grep ts3-server
Server setting completed.

Now connect to your TS3 Server with a client (no passwords used by default)
It will ask you about privilege key. Copy and paste it from your notebook.
If not, go to Permissions->Use Privelege key

You can use TS3-WebInterface  (the serveradmin password is used here)

You can get NPL license key at http://npl.teamspeakusa.com/ts3npl.php (Gives 10 virtual servers and 512 clients for all virtual servers)

Комментариев нет:

Отправка комментария