StendhalLocalhostServerOnLinux

From Arianne
Revision as of 10:53, 10 September 2007 by imported>Kymara (Setting up a localhost server: mar doesn't need building.)
Jump to navigation Jump to search

Setting up a localhost server

This guide will teach you how to set up a server on your Ubuntu machine. The server will be a local one, so people from around the world cannot get to your server. Only those who are directly connected to you via a LAN can connect to this server. The required packages are:

  • A compiled version of Marauroa The marauroa jar is included in the stendhal server package now.
  • A compiled version of the Stendhal Server
  • MySQL
  • GNU/Linux (This may be others, the directions should apply almost exactly to any *nix system)
  • A text editor (doesn't matter)
  • Command-line access

Getting the materials

Download a current version of Stendhal. I won't go in-depth about this, it is worth an entire tutorial, see How to build Stendhal for more info. If you run a Linux System, then you have the necessary tools to get everything else. I recommend ViM for those command-line lovers, and GEdit/Kate for those GUI people. Command line access shouldn't be a problem, ask your system administrator if you do and how to get to it.

Setting up MySQL

After you've installed MySQL, make sure you have a database ready for it:

mysql -u NAME -p -e "create database DB_NAME;"

Where "NAME" is the name of the user to create the database (usaully root is fine), and "DB_NAME" is the name of the database. Remember this name!

mysql -u NAME -p -e "grant all on DB_NAME.* to 'FOO'@'localhost' identified by 'BAR';"

This will create (or just add to) a user called 'FOO', with a password of 'BAR'. Replace those with whatever you want. If the user doesn't exist, it'll be created. Again, remember these values (FOO and BAR)!

Makin' the cake

Well, now that we have the materials ready, we need to mix them together to create a great product, no? Here are the steps to take:

  1. Create a server directory, to hold everything in a nice, organized way
  2. Get Marauroa and Stendhal Server over to the server directory
  3. Run the Marauroa generateini script, to get a configuration file
  4. Create a marauroa loading script (in BASH)
  5. Have fun

Now, the first and last shouldn't be to hard. Let's create that directory!

Creating the server directory

I'm an organized person when it comes to my computer. Now, sometimes that means I have to go about 3-4 levels deeper into the folder hireachroy to get where I want, but at least I know where my files are for whatever project directory I'm in. Now, you don't have to do this, but I like to keep my computer not so cluttered up with files that I don't know where they belong. Let's create it in your home directory. NOTE: The commands given are for use in the command-line, but you can take the GUI route as well. For some commands, you must run them from the command-line, and I will tell you

cd $HOME
mkdir stendhal_server

This will create a directory called "stendhal_server" in your home directory. See how easy that was? And how easy to tell what will be in that directory? That's the beauty of organization.

Marauroa and Stendhal: Moving time!

Copy-paste the following files into the server directory:

  • marauroa.jar
  • log4j.properties
  • stendhal-server-#.##.jar
  • stendhal-xmlconf-#.##.jar
  • stendhal-maps-#.##.jar
  • log4j.jar
  • groovy.jar
  • simple.jar
  • jython.jar
  • mysql-connector.jar

Done!

MySQL & Marauroa: Let the 2 be one

Time to configure Marauroa to point to the database you made earlier. In the command-line (not in GUI!), run:

java -cp marauroa.jar marauroa.server.generateini

When it asks you for...

  • database name, enter the name you used when making it (DB_NAME)
  • host, using 'localhost' is fine
  • user, use the username you used in giving permissions (FOO)
  • password, use the password you used giving permissions (BAR)
  • port, anything above 1024. 32160 is the deafult for stendhal, but it can be anything above 1024
  • game, type "stendhal" (or a number for that, if a muliple-choice menu appears)
  • turn time, or how long the server takes to process each event, choose anything above 200, but below 1000. This is in milliseconds
  • log and stats generation logs, use the default ("./") - it's in the same directory as everything else
  • RSA key size, choose anything smaller than 1024 bits, but greater than 512 (or equal to). This is to make sure that the login information is vaild and secure. Like the prompt says, anything greater than 1024 can take a LONG time. But, if you have ~30 mins to spare (more or less, depending on your comp), you could use the extra security

Well, thats everything! When it's finished, you'll have a new file, "marauroa.ini". Don't lose it, as it contains the information to get your server up & running, as well as the key to do that. If marauroa won't start, and nor will your server, check to see if that ini file is there (at the same directory! NOWHERE ELSE!) and if it is, try running the genereateini command again; the file could have change with updating the RSA keys

Bash it up! Starting marauroa

Well, BASH is pretty much standard in the linux world. If you don't have it, or use a different shell, modify this to your needs:

#!/bin/bash

export LOCALCLASSPATH=.:stendhal-server.jar:marauroa.jar:jython.jar:mysql-connector.jar:log4j.jar:simple.jar:groovy.jar

java -cp "${LOCALCLASSPATH}" marauroa.server.marauroad -c marauroa.ini -l

Save it as "blah.sh", replacing blah with whatever you want. Make sure it's executeable! Warning! in the line with "LOCALCLASSPATH", is has 'stendhal-server.jar', this is my file, and may not be yours. Do not change the name of the .jar file, just modify that line to include the version after 'server' so it's now 'stendhal-server-0.55.jar' (this is an example, your version may be different!) Ensure that this is the same thing as your .jar file! In the command-line, go to the server directory and type:

./blah.sh

Remember to change "blah" to whatever you typed in when saving the file. This will start the server, and produce A LOT of output!

Have fun

Well, that's it! Just follow the last steps of Bash it up! to start the server. Pretty easy, huh? Check out the troubleshooting and extras sections for more things to do.


Extras

This is the extras section! Here you have trouble shooting, and hints & tips

Troubleshooting

Cannot find data/conf/quest.xml

This is fixed in current CVS. You can ignore this error because the quest diary is not finished and in game yet.

This is an easy one. Take stendhal-server.jar, and open it via a archive manager. Click through the folders until you are at /data/conf. Click on Add (or Import in some cases) and point it to the quests.xml file found in the source code directory of stendhal. This would be stednhal-src/data/conf/quests.xml. Click OK, and close the window. Stop your server, and start it again. You should not get this error again, unless you (accidently, right?) put the wrong file or put it on the wrong directory

Can't login!

You try logging in with the account you made when you first got Stendhal. It doesn't work in your server! You see, the MySQL database we created is the user and some other info database, meaning that we have a list of users, while the main server has it's own list. Until access is publicly granted to the MySQL database over there, we must click on Create An Account and choose localhost as the server to join. 2 different accounts. That, well, sucks.

Server bonuses

You are the man!

Want to be an admin? Now you can! It's easy! First create a file called "admins.list" This is a plain text file, with each name on a seperate line. The name must be EXACT, or it will not work. Then open stendhal-server.jar, and browse to /data/conf. Add admins.list there

Be my wife? And other server extensions

Server extensions. They add much (or little) functionality to a server, that another may not have. If you want to add the Spouse extension, which adds marriage (uh-oh!) to your server, just add these to your marauroa.ini file we created earlier:

# load StendhalServerExtension(s)
groovy=games.stendhal.server.scripting.StendhalGroovyRunner
http=games.stendhal.server.StendhalHttpServer
spouse=games.stendhal.server.extension.SpouseExtension
server_extension=groovy,http,spouse

http.port = 8080

The first 3 lines (not including the comment) point to specfic classes in your code. Ther server_extension line tells marauroa to load those extensions at start time. After adding these, restart your server. Don't worry - the RSA keys won't break because you added these lines. I personally have 3 server extensions that I wrote as well, 2 of which are broken (help!). To add those, just add this:

my_extention=java.class.path.to.my_extension

And add "my_extention" to the end of server_extention (don't forget the comma seperating everything!)

Finished

Well, that's it. You're done. Finito. Fi. Whatever. You now have your own localhost server! No one can access yet; sign up for a free dynamic dns service at www.dyndns.com and connect a server they host to your IP. Then, all people have to do is go to whatever you set as your domain name with DynDNS. Party time!