How-to Compile and Install your own ChessD server

First of all, installing a ChessD server requires a Jabber server up & running: ChessD is in fact a component connected to xmmp, which provides users' authentication and network connection. Next thing to consider is that you also need an Apache Web Server in order to get it working: that is because the chess client you'll use to play is web-based (this is not bad, thinking that users can play without installing a single bit of software, but just using their browser). Finally, Postgre-sql is also needed: the database will contain all the informations about played games, ranking and so on. I do not either want to mention that i'm not going to explain how-to setup an eJabberd and/or a PG-sql / Apache server .. I will only talk about ChessD configurations related to those services. Assuming you've got Apache, eJabberd and PG-sql ready-to-go, let's list what we're going to do:

  • Compile && install ChessD
  • Link ChessD to eJabberd
  • Compile && install bosh
  • Set up the Webclient

1) Setting up the environment

  • Add a new user to the system, login with given username, cd into his home directory, create some path to begin working and download file sources for ChessD, Bosh, Webclient.

    # adduser chess 
    # su chess 
    $ cd 
    $ mkdir sources chess bosh public_html
    $ cd sources
    $ wget http://downloads.sourceforge.net/project/chessd/chessd/alpha-1/chessd-alpha-1.tar.bz2?use_mirror=switch
    $ wget http://downloads.sourceforge.net/project/chessd/bosh/0.1/bosh-0.1.tar.bz2?use_mirror=switch
    $ wget http://downloads.sourceforge.net/project/chessd/webclient/alpha-1/webclient-alpha-1.tar.bz2?use_mirror=mesh
    

Check yourself for newer files on Sourceforge at "http://sourceforge.net/projects/chessd/files/"

Alternatively you may consider using the git sources, available at "http://git.c3sl.ufpr.br/pub/scm/chessd/"

2) Compile ChessD

  • Always take a look to the README/INSTALL files inside sources archive before starting.
  • Extract the source

    $ pwd
    

You should be in /home/chess/sources

$ tar xjvf chessd-alpha-1.tar.bz2
$ cd chessd
$ ./configure --prefix=/home/chess/chess/

Check the INSTALL file for libraries depndencies if this step gives you problems.

$ make && make install
  • The main server should be ok: check into it's directory for installed files; should be something like this ..

    $ cd
    $ cd chess
    $ ls -l
    drwxr-xr-x 2 chess chess 4096 15 mag 11:42 bin
    drwxr-xr-x 2 chess chess 4096 15 mag 11:42 etc
    drwxr-xr-x 2 chess chess 4096 15 mag 11:42 log
    

3) Setup PG-sql DB

  • After creating a database and its user, let's import the database schema provided with chessd source file:

    $ cd 
    $ cd sources/chessd/
    $ psql -U 'user-you-created' 'database-you-created' < database/pgsql.sql
    
  • Done with PostGre: keep your data (user and password) in mind, or write it down somewhere, cause you'll need them soon.

4) eJabberd

  • Let's configure your eJabberd server now; as root user do the following:

      # nano /etc/ejabberd/ejabberd.cfg
    

First of all look at this directive:

{hosts, ["xxx.your.domain.tld"]}.

If you put this setting to 'localhost', be advised that your ChessD installation will only work on your Local Area Network, as the xmpp server will do. The important thing here is that you use the same host value while configuring chessd (if you put 'localhost', keep using 'localhost' afterward). The next part is copy-pasted from the INSTALL file: there's no need to reinvent the wheel ;-)

[cit.]

Then you have to add an entry in the config to allow chessd to connect to the
jabber server as a component. To do this look for something that look like
this:

  {listen,
    [

Then add the following lines after it:

  {<port>, ejabberd_service, [{ip, {127, 0, 0, 1}},
          {access, all},
          {host, "chessd.localhost", [{password, "<secret>"}]}]},

Here port <port> is the port that the ejabberd will listen to connect with the
chessd server, pick any unused port, <secret> is password required to connect.

The web interface use the in-band mechanism for registration, then you must
allow it. Look up for a line that looks like this:

{access, register, [{deny, all}]}.

And replace it with:

{access, register, [{allow, all}]}.

In order to enable some of the admin features, you have to give admin
privilegies to the server component. To do so you just have to add the following
line to the ejabberd config file:

{acl, admin, {user, "", "chessd.localhost"}}.

Here, the "chessd.localhost" string must be the same one you chose for the
component configuration.

Then just restart ejabberd if it was already running.

5) Chessd configuration:

  • Let's continue with our 'chess' user:

    $ cd
    $ cd chess/etc
    $ nano config.xml
    

You have to set some parameters for the component and for the database server.

<server>
        <xmpp-component
        server_name="localhost" ### same host used in ejabberd.cfg
                server_address="localhost" ### server address is set to localhost, assuming ejabberd and chessd are running into the same box
                component_port="5333"
                component_password="secret" ### password that chessd will use to authenticate against ejabberd (same as set before)
        component_name="chessd.localhost" ### what you chose in ejabberd.cfg for your chessd component name
        />
    <database
        host="localhost" ### pgsql DB host: always assuming it runs locally, keep it to localhost
        port="5432" ### pgsql listening port
        db_name="chessd" ### name of the database (the one you created in step 3)
        user="chessd" ### username that will access the pgsql DB (the one you created in step 3)
        password="chessd" ### password for the given username (the one you created in step 3)
        max_connections="50"
    />
    <log
        filename="/home/chess/chessd/log/chessd.log" ### relative or absolute path to logfile (relative in this example)
    />
</server>

Let's assume all is good and continue with our things: you cannot yet start the server, 'cause it misses the bosh server (that's the next step).

6) Compile && configure the bosh server

$ cd
$ cd sources/
$ tar xjvf bosh-0.1.tar.bz2
$ mv bosh-0.1/* ../bosh
$ cd ../bosh/
$ make
  • Now you've got the executable (bosh). Next step is configure it.

    $ nano config.xml
    
    
    <jbind>
        <bind
            jabber_port='5222' ### port where ejabberd listen at (should be default)
            session_timeout='60000'
            default_request_timeout='20000'
        />
        <http_server
            port='8082' ### chose a random port > 1024 to have your bosh server listen at
        />
        <log filename='log/bosh.log' ### set a path for logs (same as chessd, relative or absolute one)
             verbose='ERROR'/>
    </jbind>
    
  • Now i'm going to copy/paste again (Apache configuration)

[cit.]

All you need to do is to tell apache to forward a given address to
a port that the bosh will listen.

Say you want to redirect http://localhost/jabber to localhost:8082
you have to add the following lines to apache.conf:

ProxyPass /jabber http://localhost:8082 ### This is the port bosh is listening to
ProxyPassReverse /jabber http://localhost:8082 ### Same thing here

You must enable the proxy module too, if it isn't already.

Restart Apache

7) Run the bosh && chessd servers

$ cd
$ cd bosh/
$ ./bosh &
$ cd ../chess/bin/
$ ./chessd ../etc/config.xml &

8) Set up the Webclient

  • Extract the files and move them on your public_html directory

    $ cd
    $ cd sources
    $ tar xjvf webclient-alpha-1.tar.bz2
    $ mv webclient/* ../public_html/
    

ALL DONE! Great Job !!!You can now test it by pointing your browser to http://xxx.your.domain.tld/~chess

At the time of this (re)writing i discovered a bug in the webclient which makes impossible for a user to set his profile (nickname, avatar, some other informations). If you use the Portoguese version of the client you won't notice any problem, but using the english version there it is (you are not able to click on the 'Change Profile' link, id est, window will not pop-up).

Using firebug i was able to spot the problem in a missing line in the 'scripts/lang/en_US.xml' file:

        <window>
                <window_yes>Yes</window_yes>
                <window_no>No</window_no>
                <window_ok>Ok</window_ok>
                <window_close>Close</window_close>
                <window_save>Save</window_save>
                <window_accept>Accept</window_accept>
                <window_cancel>Cancel</window_cancel>
                <window_decline>Decline</window_decline>
                <window_search>Search</window_search>
                <window_character>Character(s): %s</window_character>  ### This line is missing, add it
        </window>