[Tut]Setup OdinMS (Valhalla) on Linux OS

Newbie Spellweaver
Joined
Jan 8, 2009
Messages
11
Reaction score
0
First of all if you dont know why you should try Linux.... then dont try this tut its kinda hard and requires some Unix Skills :P (jk)

Why did i pick Linux ?
In my opinion the Linux OS and kernel you can have on it its a lot better than windows since windows uses a lot of memory on kernel and other programs running in background, Linux in this case is more kinda "Clean" and uses a lot less memory on this....

So pick up between windows and Linux, yea windows is easy and Linux is kinda more... hard to control and manage etc.....

Well lets start :) Step by step and just to let you know Red color font is something you have to change as you want, the rest is as it should be.

Programs needed:

Mysql
Subversion
Java Development Kit (With Netbeans)
Java Strength Files
WZ Files


First of all lets get everything set before we start compiling and working on the configs....

Alright in any version of linux you have installed the commands can change... for this changes visit the forums / helpdesk from your linux OS and view the changes of the commands. Ex. (i'm using fedora 10 so my Super User command is SU this can change in Ubuntu since its Sudo)
Fedora commands: su, yum
Ubuntu commands: sudo, apt-get
So just check out what commands im showing here and change them for your OS Usage....

Getting Subversion:

Alright first lets log on as "admin" and then get the program.
Code:
bash: su -
password: ****(type your admin password)
root@bash: yum install subversion -y

And download / installation should start

Getting MySQL:

Code:
bash: su -
password:*****
root@bash: yum install mysql mysql-server

After MySQL is installed lets configure it :)

Code:
root@bash: chkconfig --levels 235 mysqld on (this means we want our mysql server to start up everytime our server / pc is restarted)
root@bash: /etc/init.d/mysqld start (starts our mysql server)
Starting MySQL                                                [[COLOR="Lime"]On[/COLOR]]
Alright our server is started, lets set our root password
Code:
root@bash: mysqladmin -u root password [COLOR="Red"]changethepassword[/COLOR]
This like is as is change the red words to the password you wish :)

alright lets test up our mysql has accepted our new password and its running fine

Code:
root@bash: mysql -u root -p
password: entermysqlpasshere

mysql>

Alright lets get now JDK for linux
You can get it or go to the java site and get the JDK by your own....

after JDK has downloaded.... lets start installing (you dont have to install it as super user / admin privs)

Code:
user@downloads: chmod +x jdk-6u11-nb-6_5-linux-ml.sh (lets make it executable file)
user@downloads: ./jdk-6u11-nb-6_5-linux-ml.sh

Some text of the installer will appear on your Terminal window... just gotta wait till the main window installer pops up and install it as default on your home folder or anywhere you want i used:

Code:
/home/user/

After JDK installs you will see the NetBeans icon on your desktop....

Now the JCE files (Java Strength Files) also get them from the java site.....
After downloading them, lets open them up and extract them to every folder of jdk....

The WZ files, you can get them from many forums and websites, incluiding valhalla forums, just look up in the posts or do a search for the WZ v62 XML files....

Alright since we have everything setup lets start working on our emulator.

Lets get our Valhalla source:
Code:
user@Desktop: mkdir mapleserver
user@Desktop: svn co svn://valhalla.com/maplestory/trunk /home/user/Desktop/mapleserver/
After SVN gets all the files for the emulator.... we have to compile it so open up NetBeans

Go to File - New project

Another window will pop-up, select JAVA and on the right side - Java with existing sources and click next.

On the next window, lets call our filename: Valhalla.jar
Directory for our project: /home/user/

Then click next.... in the next window:

Lets add our existing files for this project:

On the upper right click on ADD - and go to /home/user/Desktop/mapleserver/src/ folder and click ok.

Then click finish.

On the top left, you will see now your project "Valhalla" but we gotta add the jar files on it, click on your project, and will expand 2 more folders, expand Libraries now, and right click on libraries - select jar/folder, and lets add the files we downloaded with the SVN, (/home/user/Desktop/mapleserver/dist/) and add all the jar files you have in there.

Now you can build it, click on the "Hammer" on the top :) And wait till its done.
After its done go to /home/user/ and you will see your dist folder in there, copy the valhalla.jar file from there and paste in /home/user/Desktop/mapleserver/dist/ folder.

After this lets set our Environment Variables for Java...
(This location of the file could be variable depending on the OS and version you are using, just use search for files in your linux system and open it up)
Lets find our file "Profile" and open it up with a text editor, at the very end of the file, press enter (leaving 1 space) and paste the next code following your java directory.

Code:
export PATH=/home/user/jdk1.6.0_11/bin PATH
export JAVA_HOME="/home/user/jdk1.6.0_11/"
export CLASSPATH=.:/home/user/jdk1.6.0_11/

After this, save it and restart.
(If you cant save the file, change the owner to your user, or edit it as admin):
Code:
user@bash: su-
password:*****
root@bash: gedit /etc/profile

After our environment is set lets make the keystores and truststores for our emulator. (You cant use the ones the SVN has.... since the password is encrypted)

Creating Keystore:
Code:
user@desktop: keytool -genkey -alias [COLOR="Red"]keokikey[/COLOR] -keyalg RSA -keysize 1024 -keypass [COLOR="Red"]keoki[/COLOR] -keystore channel.keystore -storepass [COLOR="Red"]keoki[/COLOR]
What is your first and last name?
  [Unknown]:  example.company.com
What is the name of your organizational unit?
  [Unknown]:  Development
What is the name of your organization?
  [Unknown]:  Sun Microsystems
What is the name of your City or Locality?
  [Unknown]:  Monrovia
What is the name of your State or Province?
  [Unknown]:  California
What is the two-letter country code for this unit?
  [Unknown]:  US
Is CN=example.company.com, OU=Development, O=Sun Microsystems, L=Monrovia, 
ST=California, C=US correct?
  [no]:  yes

keytool -export -alias [COLOR="Red"]keokikey[/COLOR] -file [COLOR="Red"]keokikey[/COLOR].cer -keystore channel.keystore -storepass [COLOR="Red"]keoki[/COLOR]

If everything went well, we have our keystore in our desktop as channel.keystore now our truststore....

Code:
user@bash: keytool -import -v -trustcacerts -alias [COLOR="Red"]keokikey[/COLOR] -keypass [COLOR="Red"]keoki[/COLOR] -file [COLOR="Red"]keokikey[/COLOR].cer -keystore channel.keystore -storepass [COLOR="Red"]keoki[/COLOR]

And wa-la we have our keystore and truststore now with our own password....

Copy the channel.keystore and channel.truststore we just made to our server folder (/home/user/mapleserver/) overwriting the existing ones and then copy and paste again and rename to login.keystore, login.truststore, world.keystore and world.truststore, so you have 6 keys made by your own with your own password.

Now lets configure our properties files.

Channel.properties:
Code:
# hostname or IP address of your world server
net.sf.odinms.world.host=[COLOR="Red"]127.0.0.1[/COLOR] (or your server address)

# number of channels to host in this process
net.sf.odinms.channel.count=1

# channel keys (these are defined in the channels table)
net.sf.odinms.channel.0.key=release1
net.sf.odinms.channel.1.key=release2

db.properties:
Code:
# qualified class name of your JDBC driver
driver=com.mysql.jdbc.Driver

# JDBC URL to your database
url=jdbc:mysql://[COLOR="Red"]127.0.0.1[/COLOR]:3306/odinms

# credentials for database access
user = root
password = [COLOR="Red"]yoursqlpassword[/COLOR]

login.propesties:
Code:
# hostname or IP address of your world server
net.sf.odinms.world.host=[COLOR="Red"]127.0.0.1[/COLOR]

# login server key (this is defined in the loginserver table)
net.sf.odinms.login.key=releaselogin

world.properties:
Code:
# Rates
net.sf.odinms.world.exp=1
net.sf.odinms.world.meso=1
net.sf.odinms.world.drop=1
net.sf.odinms.world.bossdrop=1
net.sf.odinms.world.petExp=1

# Name of the Server
net.sf.odinms.login.serverName=Valhalla

# Event Message at Channel Selection 
net.sf.odinms.login.eventMessage=Welcome to ValhallaDEV\rBrand new adventure\rof Pirates!\rEnjoy your stay here!

# Flag at Channel Selection  0: Nothing 1: Event 2: New 3: Hot
net.sf.odinms.login.flag=0

# Maximum amount of characters per account
net.sf.odinms.login.maxCharacters=3

# Server Scrolling Message
net.sf.odinms.world.serverMessage=Welcome to ValhallaDEV Source

# allow cashshop to be used
net.sf.odinms.world.cashshop=true

# allow undroppable items to be dropped
net.sf.odinms.world.alldrop=false

# allow characters to pick up more than one "one-of-a-kind" items
net.sf.odinms.world.morethanone=false

# allow GM's to talk in white background text
net.sf.odinms.world.gmWhiteText=true

# spawn a character for debugging purposes on every map
net.sf.odinms.world.faekchar=false

# time in milliseconds between loginqueue runs
net.sf.odinms.login.interval=5000

# time in milliseconds between ranking updates (default: 30 minutes)
net.sf.odinms.login.ranking.interval=1800000

# total user limit of the server
net.sf.odinms.login.userlimit=20

# defaults for channelservers
net.sf.odinms.channel.net.port=7575
net.sf.odinms.channel.net.interface=[COLOR="Red"]127.0.0.1[/COLOR]

# active event scripts
net.sf.odinms.channel.events=lolcastle,3rdjob,ZakumPQ,KerningPQ,GuildQuest,LudiMazePQ,AirPlane,Dollhouse,elevator,Subway
Set this rates as you wish.... dont move the rest if you dont know what you're doing, also change your ip :)

Now lets configure our .SH files (executables for linux)

launch_channel.sh:
Code:
#!/bin/sh
export CLASSPATH=".:dist/valhalla.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar"
java -Dnet.sf.odinms.recvops=recvops.properties \
-Dnet.sf.odinms.sendops=sendops.properties \
-Dnet.sf.odinms.wzpath=wz\
-Dnet.sf.odinms.channel.config=channel.properties \
-Djavax.net.ssl.keyStore=channel.keystore \
-Djavax.net.ssl.keyStorePassword=[COLOR="Red"]keoki[/COLOR] \
-Djavax.net.ssl.trustStore=channel.truststore \
-Djavax.net.ssl.trustStorePassword=[COLOR="Red"]keoki[/COLOR] \
net.sf.odinms.net.channel.ChannelServer

launch_login.sh:
Code:
#!/bin/sh
export CLASSPATH=".:dist/valhalla.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar"
java -Dnet.sf.odinms.recvops=recvops.properties \
-Dnet.sf.odinms.sendops=sendops.properties \
-Dnet.sf.odinms.wzpath=wz \
-Dnet.sf.odinms.login.config=login.properties \
-Djavax.net.ssl.keyStore=login.keystore \
-Djavax.net.ssl.keyStorePassword=[COLOR="Red"]keoki[/COLOR] \
-Djavax.net.ssl.trustStore=login.truststore \
-Djavax.net.ssl.trustStorePassword=[COLOR="Red"]keoki[/COLOR] \
net.sf.odinms.net.login.LoginServer

launch_world.sh:
Code:
#!/bin/sh
export CLASSPATH=".:dist/valhalla.jar:mina-core.jar:slf4j-api.jar:slf4j-jdk14.jar:mysql-connector-java-bin.jar"
java -Dnet.sf.odinms.recvops=recvops.properties \
-Dnet.sf.odinms.sendops=sendops.properties \
-Dnet.sf.odinms.wzpath=wz \
-Djavax.net.ssl.keyStore=world.keystore \
-Djavax.net.ssl.keyStorePassword=[COLOR="Red"]keoki[/COLOR] \
-Djavax.net.ssl.trustStore=world.truststore \
-Djavax.net.ssl.trustStorePassword=[COLOR="Red"]keoki[/COLOR]\
net.sf.odinms.net.world.WorldServer

Okay now we're kinda set to get this working.... remember to add your WZ files folder in your server folder (/home/user/mapleserver/) and rename it to wz.

open up a terminal again and lets make this files executables....

Code:
user@bash: cd /home/user/Desktop/mapleserver/
user@mapleserver: chmod +x *.sh

Now lets dump our database:

Code:
user@bash: cd/home/user/Desktop/mapleserver/
user@mapleserver: mysql -u root -p 
password: [COLOR="Red"]mysqlpassword[/COLOR]
mysql> CREATE DATABASE odinms;
mysql> exit
Bye...
user@mapleserver: mysql-u root -p < odinms.sql
password: [COLOR="Red"]mysqlpassword[/COLOR]

You can use MySQL query browser or any other MySQL client if you dont want to do it by commands ^^

(Extra Command if you want other ppl or yourself to have the SQL available or opened for other computers and not only localhost.)
Code:
user@bash: mysql -u root -p
password: [COLOR="Red"]mysqlpassword[/COLOR]
mysql> use mysql;
changed databse to mysql.
mysql> UPDATE user SET host='%' where host='localhost';
THIS IS OPTINAL YOU WILL ALLOW ANY COMPUTER TO GET IN YOUR MYSQL (Mysql still will ask for user and password)
If you want only your own computer to get on your mysql server (incase your server is dedicated or other remote pc) change the "%" sign for your ip.

Now we need to open up some firewall ports..... get on your firewall options (look further in your linux OS)
and we have to open up the next ports:

Code:
1099 = RMI port (java ssl port for register)
7575 = channel ports (this port will increase if you add more channels 7576 and so on)
8484 = login port
3306 = mysql port

Alright, we have our database setted up, our server configured so lets try it up :).
(you can do this with screen command (google how to resume screens and etc)) in this tut ill be using 3 terminals for each executable....

Code:
user@mapleserver: ./launch_world.sh

This window will stand by....

Code:
user@mapleserver: ./launch_channel.sh

Gotta wait till you get on your world.sh terminal they registered the channel.

Code:
user@mapleserver: ./launch_login.sh
after 5~10 secs....
INFO: Listening on port 8484

And there it goes :) You can try now to get into your new linux server, remember the usage could depend on your Linux OS and version.... but im sure Linux will hold more users than you can usually hold in windows.

Good luck and have fun...

Credits: Valhalla for the amazing source :P, Keoki (me) for this tut and all the work on trying to make it work on linux o.o 1 week wasted but finally is working :).

Forgot to mention, if you get an error about SEVERE: Host not found, you gotta edit your hosts file (etc/hosts) and add "releaselogin" after the localhost line so it will end up like.
Code:
127.0.0.1             localhost  pcname  etcetcetcetc releaselogin
::1                  localhost etc etc etc

Do this at your own responsability i've tested it and didnt harm the OS.
 
Last edited:
nice tut!

I got a few errors though...
I am on ubuntu 8.10
When I add this:
Code:
export PATH=/home/user/jdk1.6.0_11/bin PATH
export JAVA_HOME="/home/user/jdk1.6.0_11/"
export CLASSPATH=.:/home/user/jdk1.6.0_11/
I will be unable to login using the normal session.
My only choice would be to use a failsafe session, or edit the /etc/profile
This is what my file currently looks like:
Code:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

if [ "$PS1" ]; then
  if [ "$BASH" ]; then
    PS1='\u@\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
	. /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

umask 022
export PATH=/home/eric/jdk1.6.0_11/bin PATH
export JAVA_HOME="/home/eric/jdk1.6.0_11/"
export CLASSPATH=.:/home/eric/jdk1.6.0_11/

I tried adding the truststore files and it didn't work
Code:
eric@ubuntu:~/Desktop$ keytool -import -v -trustcacerts -alias skeerkey -keypass skeer -file skeerkey.cer -keystore channel.keystore -storepass skeer
keytool error: java.security.cert.CertPathValidatorException: Failed to establish chain-of-trust from reply
 
I have linux text based. Can you compile the java files and post it on rapid or something?

Theres a way to compile it.... but it will take you 3 times longer than by netbeans... so just compile it on your PC first... then upload it to your Linux PC text based or w/e ......

@Skeer

For ubuntu you dont have to add that to the profiles file....

You will have to create a java script and put it inside the folder profile.d

About the keystores and etc o.o no idea what could be wrong... did u created the keystore and then the trustore... etc ???
 
When I try importing the key, I get this error..

Code:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
 
Ok, got key importing working, but now when I do ./launch_world.properties, I get this error.

[root@ip-xxx-xx-xxx-xxx trunk]# ./launch_world.sh
Picked up _JAVA_OPTIONS: -Xms20m -Xmx64m
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mina/common/ByteBufferAllocator
Caused by: java.lang.ClassNotFoundException: org.apache.mina.common.ByteBufferAllocator
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: net.sf.odinms.net.login.LoginServer. Program will exit.
 
Back