### Quick Start Guide:

This is step-by-step guide to setting up a TrackMania² Canyon (TM2) dedicated server with XASECO2 for those lost in or confused by the available readme's and tutorials, and those just too lazy to read them. ;-)

It's initially written for Linux but should largely apply to Windows too, and your system needs to have a working MySQL 4.x or 5.x and PHP 5.x setup. To manage the database, enter the MySQL commands in the mysql command prompt, PhpMyAdmin or another tool of your choice. You need to run the TM2 server and XASECO2 on the same machine, running them on separate machines is beyond the scope of this guide.

First, the dedicated server:

1. On Linux:
   1. The TM2 server and XASECO2 should run under a user account rather than root, so create a user e.g. "tm2" with home directory "/home/tm2".
   2. Login as (or switch to) user "tm2" so that all files created down the road receive the correct ownership and permissions.
   3. The TM2 server zip doesn't have a top-level directory, so create one first to keep all the server files together, e.g.:
      `mkdir TM2`
      `cd TM2`
2. On Windows:
   1. The TM2 server and XASECO2 can run under a user account rather than administrator, so create a user e.g. "TM2".
   2. Switch to that user.
   3. Change to your (My) Documents directory.
3. Download and unzip the latest TM2 server (ManiaPlanetDedicated_2011-10-12.zip) into the TM2/ directory.
4. Log into the MP Player Page using your player login and password, and create a dedicated server login and password (different from your player password).
5. Edit TM2/UserData/Config/dedicated_cfg.txt:
   1. In the <authorization_levels> section, change all three passwords, but do not change the names (SuperAdmin, Admin, User).
   2. In the <masterserver_account> section, enter the server <login> obtained above with its own <password>, and your account's validation key (usually five characters) in <validation_key> so that your server is able to use planets.
   3. This validation key is given in the mail you should have received after creating your player account with the game, but a new one can be generated via the player page. Additionally, you must make an initial donation from your player login to your server login via the in-game message system, so that there are sufficient planets in the account to pay Nadeo tax on the first transaction.
   4. In the <server_options> section, give your server a <name> and configure the other options to your liking.
   5. In the <system_config> section, set <connection_uploadrate> and <connection_downloadrate> to values closest to your connection's speed (in Kbps), and remember the three port numbers (default: 2350 for the server, 3450 for P2P and 5000 for XMLRPC; these can be changed to other free port numbers, but it's recommended to keep the defaults at least until your server comes online successfully).
6. Choose and edit a match settings file, e.g. TM2/UserData/Maps/MatchSettings/CanyonA.txt, to your liking (see the server readme for details).
7. On your firewall/router, open the server port 2350 and the P2P port 3450 for both UDP and TCP traffic, but not the XMLRPC port 5000. For the Dedimania system in XASECO2 port 8002 needs to be open as well. For more information on this, PortForward.com may be useful.
8. A standard startup script called RunSrv.sh is included in the zip, so review/edit it if needed:
   `#!/bin/sh`
   `./ManiaPlanetServer /game_settings=MatchSettings/CanyonA.txt /dedicated_cfg=dedicated_cfg.txt /title=TMCanyon`
   or use a corresponding RunSrv.bat:
   `ManiaplanetServer.exe /game_settings=MatchSettings/CanyonA.txt /dedicated_cfg=dedicated_cfg.txt /title=TMCanyon`
9. Start the server:
   `cd ~/TM2/`
   `./RunSrv.sh` (or `RunSrv.bat`)
   You should see output like the following:

       Starting ManiaPlanet Date=2011-10-12-xx_xx Svn=41570 GameVersion=3.0.0...
       Initializing...
       Configuration file : dedicated_cfg.txt
       Loading system configuration...
       ...system configuration loaded
       Loading cache...
       ...OK
       Listening for xml-rpc commands on port 5000.
       Trackmania server daemon started with pid=14180 (parent=14176).

   If you get a Segmentation Fault here, your kernel/distro may be too old, or the server cannot create files/directories due to ownership/permission problems (perhaps you forgot step 1b?).
10. The first time the server starts, it creates several files in UserData/Config/ (including blacklist.txt and guestlist.txt), as well as the Logs/ directory and an extensive directory hierarchy under UserData/. The files in the Logs/ directory are useful to monitor your server's activity.
11. Start your TM2 client and check in the Internet server browser that the server is running in your zone with your chosen server name and some official tracks.
12. Join your server, and have a friend join from elsewhere on the Internet, to verify that the server is accessible.
13. To start & stop your TM2 server on Linux more easily, you can use this start-up script.
14. Collect your own tracks in UserData/Maps/My Challenges/, copy and edit a new match settings file in UserData/Maps/MatchSettings/ that lists those tracks, use that file in RunSrv.sh (or RunSrv.bat), and restart your server. It should now be running your track selection. Congratulations. :-)

Secondly, the XASECO2 system:

1. Create the XASECO2 database in MySQL (default "xaseco2" but any other name is okay too):
   `CREATE DATABASE xaseco2;`
   Also create a separate user (e.g. "tm2") in MySQL with a password, and grant this user all rights to the "xaseco2" database. The basic MySQL commands are:
   `CREATE USER 'tm2'@'localhost';`
   `SET PASSWORD FOR 'tm2'@'localhost' = password('password');`
   `GRANT all ON xaseco2.* TO 'tm2'@'localhost';`
2. Login as (or switch to) user "tm2" so that all files created down the road receive the correct ownership and permissions.
3. Download and unzip XASECO2 (latest version) into the "/home/tm2/" directory too, the default path will be xaseco2/ so that future releases can be unpacked into the same directory tree.
   In the zip file, all *.XML and config files are located inside the newinstall/ directory. Go into the newinstall/ directory and move all *.XML files into the main directory, next to xaseco2.php, and move all *.PHP files into the includes/ directory.
4. Setting up the database tables in MySQL is done automatically the first time XASECO2 runs, but if you prefer you can do it manually in advance:
   `USE xaseco2;`
   `SOURCE /home/tm2/xaseco2/DOCS/xaseco2.sql;`
5. Edit xaseco2/localdatabase.xml:
   1. Replace YOUR_MYSQL_LOGIN with the MySQL user you created above, e.g. tm2.
   2. Replace YOUR_MYSQL_PASSWORD with the MySQL password you set above.
   3. Use the same database name as you created above, e.g. xaseco2.
   4. localhost is your own machine, so the server option is okay.
6. Edit xaseco2/config.xml:
   1. In the <masteradmins> section, uncomment and replace YOUR_MASTERADMIN_LOGIN with your player login, and add further logins for other players you want to grant all XASECO2 admin rights.
   2. In the <tmserver> section, replace YOUR_SUPERADMIN_PASSWORD with the password you chose for SuperAdmin in dedicated_cfg.txt (TM2 step 5a above) but do not change the SuperAdmin login itself.
   3. The <port> field should contain the same XMLRPC port number you chose in dedicated_cfg.txt (TM2 step 5e above), default 5000.
   4. IP 127.0.0.1 is your own machine again, so that option is okay too.
7. Edit xaseco2/adminops.xml:
   1. In the <admins> section, uncomment and replace YOUR_ADMIN_LOGIN with an admin's login, and add further logins for other players you want to grant partial XASECO2 admin rights. Or leave the <tmlogin> entry commented out if there are none.
   2. In the <operators> section, uncomment and replace YOUR_OPERATOR_LOGIN with an operator's login, and add further logins for other players you want to grant XASECO2 operator rights. Or leave the <tmlogin> entry commented out if there are none.
8. Edit xaseco2/dedimania.xml if you want to use the Dedimania world records system:
   1. In the <masterserver_account> section, replace YOUR_SERVER_LOGIN with the <login> value from your dedicated_cfg.txt file.
   2. Also, replace YOUR_DEDIMANIA_CODE with the DedimaniaCode that you can generate after registering your server with the Dedimania system.
   3. To disable Dedimania support, remove or comment out the chat.dedimania.php and plugin.dedimania.php entries in plugins.xml.
9. Start the XASECO2 system:
   `cd ~/xaseco2/`
   `./XAseco2.sh` (or `XAseco2.bat`)
   You won't see output, but logfile.txt should contain something like the following:

       [XAseco2] PHP Version is 5.3.x on Linux
       [XAseco2] Load settings [config.xml]
       [XAseco2] Load default style [styles/NavBlueBlur.xml]
       [XAseco2] Load default panel background [panels/PanelBGNavBlueBlur.xml]
       [XAseco2] Load admin/ops lists [adminops.xml]
       [XAseco2] Load banned IPs list [bannedips.xml]
       [XAseco2] Load plugins list [plugins.xml]
       [XAseco2] Load plugin [plugin.localdatabase.php]
       [...snip plugins...]
       [XAseco2] Load plugin [jfreu.plugin.php]
       [XAseco2] Load plugin [mistral.idlekick.php]
       [09/xx,xx:33:22] Try to connect to MP dedicated server on 127.0.0.1:5006 timeout 180s
       [09/xx,xx:33:22] Try to authenticate with login 'SuperAdmin' and password 'PASSWORD'
       [09/xx,xx:33:22] Connection established successfully !
       [09/xx,xx:33:22] [LocalDB] Load config file [localdatabase.xml]
       [09/xx,xx:33:22] [LocalDB] Try to connect to MySQL server on 'localhost' with database 'xaseco2'
       [09/xx,xx:33:22] [LocalDB] MySQL Server Version is 5.1.56-log
       [09/xx,xx:33:22] [LocalDB] Checking database structure...
       [09/xx,xx:33:22] [LocalDB] ...Structure OK!
       [09/xx,xx:33:22] [RASP] Loading config file [rasp.xml]
       [09/xx,xx:33:22] [RASP] Checking database structure...
       [09/xx,xx:33:22] [RASP] ...Structure OK!
       [09/xx,xx:33:22] [RASP] Cleaning up unused data
       [09/xx,xx:33:22] Load default admin panel [panels/AdminRightCorner.xml]
       [09/xx,xx:33:22] Load default donate panel [panels/DonateBelowCPList.xml]
       [09/xx,xx:33:22] Load default records panel [panels/RecordsRightCorner.xml]
       [09/xx,xx:33:22] Load default vote panel [panels/VoteBottomCenter.xml]
       [09/xx,xx:33:22] ************* (Dedimania) *************
       [09/xx,xx:33:22] * Dataserver connection on Dedimania ...
       [09/xx,xx:33:22] * Try connection on http://dedimania.net:8082/Dedimania ...
       [09/xx,xx:33:22] Webaccess (dedimania.net:8082/Dedimania.8083): send: deflate, receive: deflate
       [09/xx,xx:33:22] * Connection and status ok! (Dedimania.8083)
       [09/xx,xx:33:22] ------------- (Dedimania) -------------
       [09/xx,xx:33:22] Load stats panel [panels/StatsCanyon.xml]
       [09/xx,xx:33:22] Load music server config [musicserver.xml]
       [09/xx,xx:33:22] Load auto timelimit config [autotime.xml]
       ###############################################################################
         XASECO2 v1.00 running on 127.0.0.1:5000
         Name   : YOUR SERVER NAME - YOUR_SERVER_LOGIN
         Game   : ManiaPlanet - Canyon - TimeAttack
         Version: 3.0.0 / 2011-10-12-xx_xx
         Author : Xymph
       ###############################################################################
       Begin Race
       [09/xx,xx:33:23] track changed [none] >> [Spirit of Canyon]
       [09/xx,xx:33:23] currently no record on Spirit of Canyon

   If you get an RPC Permission Error here, there is an XMLRPC port mismatch or the dedicated server isn't running (anymore).
10. To start & stop your XASECO2 on Linux more easily, you can use this start-up script.
11. Edit the configuration options to your liking, and restart XASECO2. It should now be ready to manage tracks, receive players, and record... er... records. Congratulations. :-)

Finally, to run another server on the same machine:

1. Basically follow the same steps above, but use a second user account (e.g. "tm2b"), another new server login/password in dedicated_cfg.txt, a separate server name, a second set of ports (e.g. 2351, 3451 and 5001), a new database (e.g. "xaseco2b"), optionally a second MySQL account (e.g. "tm2b"), and the corresponding updates in localdatabase.xml and config.xml.
2. Don't use symbolic links in the UserData/ directory tree (e.g. to symlink the tracks from the first server to the second one), as the TM2 server will crash without an error message.

And for the last time, read the readme's and tutorials completely for a more thorough understanding of the entire setup.