Difference between revisions of "Development:DIRTSAND"

m (Set up the dirtsand database: whitespace fix)
(for test shards, a dedicated dirtsand user is overkill)
Line 19: Line 19:
 
=Building the code=
 
=Building the code=
  
Run the following commands in an appropriate folder:
+
If you are installing DirtSand on your personal machine for testing, just continue with the next paragraph and run all commands as normal user (''NEVER USE ROOT!''). If however you are working on a dedicated server for production use, you should create a user which runs dirtsand, so that it is properly isolated from the rest of the system:
<source lang="bash">git clone git://github.com/H-uru/dirtsand.git
+
<source lang="bash">sudo adduser dirtsand
cd dirtsand
+
su dirtsand</source>
mkdir build
+
Some commands further down start with "sudo", they need to be run as a user with the necessary privileges (you should know how to do that if you plan to set up a public server).
cd build
+
 
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/dirtsand
+
Run the following commands to download, compile and install dirtsand:
 +
<source lang="bash">cd # change to home directory (you can use any other folder as base directory, of course)
 +
mkdir dirtsand && cd dirtsand
 +
git clone git://github.com/H-uru/dirtsand.git src
 +
cd src
 +
mkdir build && cd build
 +
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dirtsand
 
make
 
make
sudo make install</source>
+
make install # copies the files to $HOME/dirtsand/bin etc.</source>
  
 
If you run into any errors about finding libraries or headers, make sure you have the *development* versions of all of the required libraries, and that they are in your path.  You can also use the cmake-gui to help cmake locate the missing paths and files.
 
If you run into any errors about finding libraries or headers, make sure you have the *development* versions of all of the required libraries, and that they are in your path.  You can also use the cmake-gui to help cmake locate the missing paths and files.
Line 38: Line 44:
 
== Set up the postgres user ==
 
== Set up the postgres user ==
  
The command
 
 
<source lang="bash">sudo -u postgres psql</source>
 
<source lang="bash">sudo -u postgres psql</source>
 
will open a postgres shell that you can type commands into. The following commands will create a user to be used by DirtSand (replace "<password>" by some random series of characters):
 
will open a postgres shell that you can type commands into. The following commands will create a user to be used by DirtSand (replace "<password>" by some random series of characters):
Line 59: Line 64:
 
== Set up the dirtsand database ==
 
== Set up the dirtsand database ==
  
Make sure that your working directory is the "dirtsand" folder you cloned above.
+
<source lang="bash">cd ~/dirtsand/src
<source lang="bash">sudo -u postgres psql -d dirtsand < db/dbinit.sql
+
sudo -u postgres psql -d dirtsand < db/dbinit.sql
 
sudo -u postgres psql -d dirtsand < db/functions.sql</source>
 
sudo -u postgres psql -d dirtsand < db/functions.sql</source>
  
Line 69: Line 74:
 
A sample dirtsand.ini has been provided in the root of the dirtsand sources.  We can copy this to our install directory and then edit the fields we need. If you have dirtsand installed to somewhere other than /opt/dirtsand, you will also need to point the configuration to the right paths too.
 
A sample dirtsand.ini has been provided in the root of the dirtsand sources.  We can copy this to our install directory and then edit the fields we need. If you have dirtsand installed to somewhere other than /opt/dirtsand, you will also need to point the configuration to the right paths too.
  
<source lang="bash">sudo cp dirtsand.sample.ini /opt/dirtsand/dirtsand.ini
+
<source lang="bash">cd ~/dirtsand
sudo adduser dirtsand
+
sudo cp src/dirtsand.sample.ini dirtsand.ini
sudo chown dirtsand /opt/dirtsand/dirtsand.ini
+
<your-favorite-editor> dirtsand.ini</source>
sudo -u dirtsand <your-favorite-editor> dirtsand.ini</source>
+
  
 
For now, only change the database settings - usually, the line containing "Db.Password" should be the only one you need to change. It must be set to the same random series of characters that you used when creating the user in postgres.
 
For now, only change the database settings - usually, the line containing "Db.Password" should be the only one you need to change. It must be set to the same random series of characters that you used when creating the user in postgres.

Revision as of 17:20, 31 July 2011

This page contains information about how to set up DirtSand, the "D'ni in Real-Time Server and Network Dæmon" by Zrax. It is a server compatible with the CyanWorlds.com Engine. CWE needs a server to run at all, which makes setting up DirtSand (or a compatible server) a necessary part of any CWE setup. DirtSand currently works only on Linux operating systems.

This tutorial assumes that you run the DirtSand server and the database it uses on the same machine, which will usually be the case. If you plan to use a dedicated database server, you probably know enough about Postgres and Linux do change the setup accordingly.

Git

DirtSand uses git for its source control needs. If you're already familiar with git, some of these instructions may seem obvious to you. If you're not familiar with git, it is recommended that you read through some of the excellent articles in the GitHub help area.

Dependencies

You will need to install some applications and libraries before you can build DirtSand. The package names in brackets are tested on Debian, they should be called similar on other distributions.

  • GCC 4.4+ (might work with other C++0x compliant compilers, but untested) [g++]
  • Postgres, server and development libraries [postgresql, libpq-dev]
  • OpenSSL [libssl-dev]
  • libreadline [libreadline6-dev]
  • zlib [zlib1g-dev]
  • git (to get the sources) [git]

Building the code

If you are installing DirtSand on your personal machine for testing, just continue with the next paragraph and run all commands as normal user (NEVER USE ROOT!). If however you are working on a dedicated server for production use, you should create a user which runs dirtsand, so that it is properly isolated from the rest of the system:

sudo adduser dirtsand
su dirtsand

Some commands further down start with "sudo", they need to be run as a user with the necessary privileges (you should know how to do that if you plan to set up a public server).

Run the following commands to download, compile and install dirtsand:

cd # change to home directory (you can use any other folder as base directory, of course)
mkdir dirtsand && cd dirtsand
git clone git://github.com/H-uru/dirtsand.git src
cd src
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dirtsand
make
make install # copies the files to $HOME/dirtsand/bin etc.

If you run into any errors about finding libraries or headers, make sure you have the *development* versions of all of the required libraries, and that they are in your path. You can also use the cmake-gui to help cmake locate the missing paths and files.

You should not continue beyond this step before completing above commands without error messages!

Setting up the server

Now the database server needs to be set up and DirtSand needs to be configure to work with it.

Set up the postgres user

sudo -u postgres psql

will open a postgres shell that you can type commands into. The following commands will create a user to be used by DirtSand (replace "<password>" by some random series of characters):

CREATE USER dirtsand WITH PASSWORD '<password>';
CREATE DATABASE dirtsand WITH TEMPLATE = template0 ENCODING = 'UTF8';
ALTER DATABASE dirtsand OWNER TO dirtsand;
\q

Install the UUID functionality

This may be provided by your OS distribution. In Ubuntu, simply install the postgresql-contrib package to provide the necessary libraries and installation scripts. If your distribution does not provide a contrib or uuid-ossp bundle, you can get it and build it yourself from the sources provided at: http://www.ossp.org/pkg/lib/uuid/

Once you have the ossp, you can add it to the dirtsand database by running the import script:

sudo -u postgres psql -d dirtsand < /path/to/uuid-ossp.sql

Example for Ubuntu 10.10:

sudo -u postgres psql -d dirtsand < /usr/share/postgresql/8.4/contrib/uuid-ossp.sql

Set up the dirtsand database

cd ~/dirtsand/src
sudo -u postgres psql -d dirtsand < db/dbinit.sql
sudo -u postgres psql -d dirtsand < db/functions.sql

If there were no other errors, your database should be ready for DIRTSAND

Configure dirtsand

A sample dirtsand.ini has been provided in the root of the dirtsand sources. We can copy this to our install directory and then edit the fields we need. If you have dirtsand installed to somewhere other than /opt/dirtsand, you will also need to point the configuration to the right paths too.

cd ~/dirtsand
sudo cp src/dirtsand.sample.ini dirtsand.ini
<your-favorite-editor> dirtsand.ini

For now, only change the database settings - usually, the line containing "Db.Password" should be the only one you need to change. It must be set to the same random series of characters that you used when creating the user in postgres.

Done!

That's it for the actual server setup. To complete this installation to a working Shard, more work is required - have a look at the Sandbox Shard tutorial.