• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Script and tutorial to automate install of "Leaked" 7.70 server

SilverFern

Well-Known Member
Joined
Feb 15, 2020
Messages
71
Reaction score
53
Due to a sudden resurgence of people interested in hosting the leaked 7.7 server, I came up with a script to automate all the steps outlined in the excellent tutorial by @Crevasse, and also took the opportunity to make some improvements to work on a more recent version of Ubuntu.

All you need to do is to install Ubuntu in a VM, download the required files and run the scripts.

1. Install Ubuntu 22.04.2 LTS (64 bits) on a virtual machine with VirtualBox​

Simply follow this easy tutorial from Ubuntu, then configure your VM with the recommended settings below:
  • 8 GB of RAM
  • 2 CPU cores
  • 25 GB of disk space
  • Network settings should be configured to use Bridged Adapter, so the VM will get an IP similar to your host PC (e.g.: 192.168.x.x)
Once Ubuntu is up and running, you might want to give sudo permissions to your user, which can be done by running the commands below in a terminal:
Code:
su -
sudo adduser $(whoami) sudo
reboot

2. Download all required files

Go to Crevasse's post and download all attached files. You should have 6 mandatory files and 1 optional:
Also, download the "ot-scripts-xxx.zip" attached to my post and extract all scripts.

3. Install the server​

Make sure all files above are in the same folder on your VM. If you run ls -1, your directory should look like this:
Code:
dennis-libraries.rar
game
install.sh
otserv_schema_data.rar
realotsloginserver-master.zip
realots-query-manager-master.zip
realots-schema-inc-players.zip
start-game-server.sh
start-login-server.sh
start-query-manager.sh
tibia-game.tarball.tar.gz

Run the commands below, which is giving execution permission to all scripts and running the install script:
Code:
sudo chmod +x install.sh start-query-manager.sh start-game-server.sh start-login-server.sh
sudo ./install.sh
Note: the script will ask you to enter a password for the MySQL database user. You can also pass it as an argument to the script, e.g.: sudo ./install.sh mypassword

The installation will take about 5 minutes, depending on your resources and Internet connection.

4. Run all services​

I've included scripts to run the different services required.
Simply run the following commands (in that order) to start up all the services to serve the game, each one in its own terminal:
Code:
sudo ./start-query-manager.sh
sudo ./start-game-server.sh
sudo ./start-login-server.sh

5. Customise the 7.70 client​

In case you don't want to use an IP changer, you can edit the client to point to your VM server.
Code:
test.cipsoft.com
server.tibia.com
server2.tibia.com
tibia1.cipsoft.com
tibia2.cipsoft.com
Note: make sure you replace the remaining characters with 00 bytes. Check this post for more details: Configuration - [Tutorial] Make your custom Tibia Client. (https://otland.net/threads/tutorial-make-your-custom-tibia-client.65/)

6. Log in (and have fun)​

  • On your VM, open the browser and go to http://localhost/phpmyadmin
  • Sign in with the username "otserv" and the password you provided to this install script
  • Click on the "otserv" database, then the "users" table
  • You can use any "login" and "passwd" to log in to an account on the client

Future improvements​

Some ideas for the community to improve this even further:
  • Provide a docker with everything already set up
  • Provide the download link to a VM with everything pre-installed
  • Automate the step of editing the client hex
  • Document known issues
  • When installing packages, use static versions to avoid breaking changings when downloading recent libs
  • Improve security
  • Provide all files in a single zip
  • Automatically download files if they don't exist
  • Turn it into an installer
  • Include a GUI for creating accounts
  • Add instructions to securely set it up for others to join your server
 

Attachments

  • ot-scripts-2023-04-02-0135.zip
    4.2 KB · Views: 273 · VirusTotal
Last edited:
For those who don't want to sign up to the forum, or can't/don't want to download the scripts to see what they do, I'm posting them here as plain text too.

install.sh
Bash:
#!/bin/bash

# INTRODUCTION
#
# Script by SilverFern (https://otland.net/members/silverfern.238325/)
# Tested on a clean install of Ubuntu 20.04.2 LTS in a virtual machine (VM).
# Credits to Crevasse for posting most of the steps on https://otland.net/threads/tutorial-for-running-7-7-cipsoft-server-on-ubuntu.274678/
# and to all the people who contributed to the related projects.
# Please consider improving this script (check the @TODO's) for the community.

# REQUIREMENTS
#
# - It's highly recommended to run this script on a virtual machine (VM) with Ubuntu 20.04.2 LTS (64-bit) installed (instructions here: https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#1-overview)
# - If you use VirtualBox, you might want to configure your VM with the following:
#  - 8 GB of RAM
#  - 2 CPU cores
#  - 25 GB of disk space
#  - Network settings should be configured to use Bridged Adapter, so the VM will get an IP like 192.168.x.x
#
# Note: Before running this script, make sure it is in the same folder as the following files (download links can be found on https://otland.net/threads/tutorial-for-running-7-7-cipsoft-server-on-ubuntu.274678):
#
# - dennis-libraries.rar
# - game
# - otserv_schema_data.rar
# - realotsloginserver-master.zip (from https://github.com/HeavenIsLost/realotsloginserver)
# - realots-query-manager-master.zip
# - realots-schema-inc-players.zip (optional, from https://otland.net/threads/tutorial-for-running-7-7-cipsoft-server-on-ubuntu.274678/post-2670256)
# - tibia-game.tarball.tar.gz
#
# Also, you might need to add your vm user to the sudo group. This can be done with the commands below (it will reboot your VM):
#
# su -
# sudo adduser $(whoami) sudo
# reboot


# INSTALLATION
#
# On your Ubuntu VM, open a terminal on that folder, then run the following commands to grant proper permissions and execute the installer (takes about 5 mins to complete):
#
# sudo chmod +x install.sh start-query-manager.sh start-game-server.sh start-login-server.sh
# sudo ./install.sh
#
# Note: the script will ask you to enter a password for the database user. You can also pass it as an argument to the script, e.g.: sudo ./install.sh mypassword

# RUNNING THE SERVER
#
# Run the following commands to start up all the services to serve the game, **each one in its own terminal**:
#
# sudo ./start-query-manager.sh
# sudo ./start-game-server.sh
# sudo ./start-login-server.sh

# RUNNING THE CLIENT
#
# - On a Windows PC, download and install the 7.70 client from a website like https://www.tibiabr.com/downloads/clients-antigos
# - In a hex editor (e.g.: https://hexed.it/), import the Tibia executable file (NOT the installer) from your instal path (e.g.: "C:\Program Files (x86)\Tibia\Tibia.exe")
# - Search for the hosts below and replace them with the IP address of your Ubuntu VM
#   - test.cipsoft.com
#   - server.tibia.com
#   - server2.tibia.com
#   - tibia1.cipsoft.com
#   - tibia2.cipsoft.com
# - Note: make sure you replace the remaining characters with 00 bytes. Check this post for more details: https://otland.net/threads/tutorial-make-your-custom-tibia-client.65/
# - Save the client, then execute it

# LOGGING IN WITH AN ACCOUNT
#
# - On your VM, open the browser and go to http://localhost/phpmyadmin
# - Sign in with the username "otserv" and the password you provided to this install script
# - Click on the "otserv" database, then the "users" table
# - You can use any "login" and "passwd" to log in to an account on the client

echo "Starting script..."

# Variables
GAME_PATH="/home/game"
PORT=17778
LOCAL_IP=$(hostname -I | cut -d' ' -f1)
IFS='.' read -ra LOCAL_IP_PARTS <<< "$LOCAL_IP"

MYSQL_PASSWORD=$1
if [ -z "$MYSQL_PASSWORD" ]
then
    echo "Please enter the password you want for the MySQL database user:"
    read MYSQL_PASSWORD
fi

echo "Updating system packages..."
apt update -y

echo "Installing dependencies..."
# Pre-configure phpmyadmin so it can perform an unattended installation
debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true"
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $MYSQL_PASSWORD"
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $MYSQL_PASSWORD"
debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2"
# @TODO install specific versions to avoid breaking changes from newer versions
apt-get install unrar lib32z1 apache2 mysql-server phpmyadmin libapache2-mod-php8.1 g++ cmake build-essential liblua5.2-dev libgmp3-dev libmysqlclient-dev libboost-system-dev libpugixml-dev -y

echo "Creating game directory at '$GAME_PATH'..."
mkdir -p $GAME_PATH

echo "Extracting 'tibia-game.tarball.tar.gz' to '$GAME_PATH'..."
tar -xvzf tibia-game.tarball.tar.gz -C $GAME_PATH

echo "Creating backup of files that will be edited"
cp $GAME_PATH/bin/game $GAME_PATH/bin/game-original
cp $GAME_PATH/.tibia $GAME_PATH/.tibia-original

echo "Moving file 'game' to '$GAME_PATH/bin'..."
cp game $GAME_PATH/bin

echo "Setting full read and write permissions for '$GAME_PATH/bin/game'..."
chmod 777 $GAME_PATH/bin/game

echo "Set game path in $GAME_PATH/.tibia..."
sed -i 's/ = "\/game\// = "\/home\/game\//g' $GAME_PATH/.tibia

echo "Set query manager in $GAME_PATH/.tibia..."
sed -i "s/QueryManager = {.*}/QueryManager = {(\"${LOCAL_IP}\",${PORT},\"nXE?\/>j\`\"),(\"${LOCAL_IP}\",${PORT},\"nXE?\/>j\`\"),(\"${LOCAL_IP}\",${PORT},\"nXE?\/>j\`\"),(\"${LOCAL_IP}\",${PORT},\"nXE?\/>j\`\")}/g" $GAME_PATH/.tibia

echo "Copying file '$GAME_PATH/.tibia' to '~'..."
cp $GAME_PATH/.tibia ~

echo "Deleting file '$GAME_PATH/save/game.pid'..."
rm $GAME_PATH/save/game.pid

echo "Extracting dennis-libraries.rar to '/lib'..."
unrar x dennis-libraries.rar
chmod 777 dennis-libraries/*
mv dennis-libraries/* /lib

echo "Giving firewall permissions to Apache..."
ufw allow in "Apache Full"
ufw allow 7171/tcp
ufw allow 7172/tcp
ufw enable
service apache2 status | grep "active (running)" || echo "Apache is not running. Please start it manually after the intallation."

echo "Configuring phpMyAdmin..."
PHP_INI_PATH=$(php --ini | grep 'Loaded Configuration File' | sed -e 's/.*:\s*//')
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 64M/g' $PHP_INI_PATH
echo "Include /etc/phpmyadmin/apache.conf" >> "/etc/apache2/apache2.conf"
systemctl restart apache2

echo "Configuring MySQL..."
service mysql status | grep "active (running)" || echo "MySQL is not running. Please start it manually after the intallation."
mysql -u root -p$MYSQL_PASSWORD -e "CREATE USER 'otserv'@'%' IDENTIFIED BY '$MYSQL_PASSWORD'; GRANT ALL PRIVILEGES ON *.* to 'otserv'@'%' WITH GRANT OPTION; CREATE DATABASE otserv;"
unrar x otserv_schema_data.rar
mysql -u otserv -p$MYSQL_PASSWORD otserv < otserv_schema_data.sql
if [ -f realots-schema-inc-players.zip ]; then
    unzip realots-schema-inc-players.zip
    mysql -u otserv -p$MYSQL_PASSWORD otserv < realots-schema-inc-players.sql
fi
sed -i "s/^bind-address.*/bind-address = $LOCAL_IP/g" /etc/mysql/mysql.conf.d/mysqld.cnf
systemctl restart mysql

echo "Configuring RealOTS query manager..."
unzip realots-query-manager-master.zip
sed -i "s/Cz7u89dmyPzHDNEL/$MYSQL_PASSWORD/g" realots-query-manager-master/main.cpp
sed -i "s/^std::string q_world.*/std::string q_world = \"RealOTS\";/g" realots-query-manager-master/main.cpp
sed -i "s/htonl(INADDR_LOOPBACK)/inet_addr(\"$LOCAL_IP\")/g" realots-query-manager-master/main.cpp
sed -i "s/writeMsg.addByte(213);/writeMsg.addByte(${LOCAL_IP_PARTS[0]});/g" realots-query-manager-master/main.cpp
sed -i "s/writeMsg.addByte(163);/writeMsg.addByte(${LOCAL_IP_PARTS[1]});/g" realots-query-manager-master/main.cpp
sed -i "s/writeMsg.addByte(67);/writeMsg.addByte(${LOCAL_IP_PARTS[2]});/g" realots-query-manager-master/main.cpp
sed -i "s/writeMsg.addByte(173);/writeMsg.addByte(${LOCAL_IP_PARTS[3]});/g" realots-query-manager-master/main.cpp
make -C realots-query-manager-master

echo "Configuring RealOTS login server..."
unzip realotsloginserver-master.zip
sed -i "s/Connection::read_timeout/static_cast<long>(Connection::read_timeout)/g" realotsloginserver-master/src/connection.cpp
sed -i "s/Connection::write_timeout/static_cast<long>(Connection::write_timeout)/g" realotsloginserver-master/src/connection.cpp
sed -i "s/my_bool/bool/g" realotsloginserver-master/src/database.cpp
mkdir -p realotsloginserver-master/build
cmake -S realotsloginserver-master -B realotsloginserver-master/build
make -C realotsloginserver-master/build
cp realotsloginserver-master/build/tfls realotsloginserver-master
sed -i "s/^ip = .*/ip = \"$LOCAL_IP\"/g" realotsloginserver-master/config.lua
sed -i "s/^clientVersionMin = .*/clientVersionMin = 770/g" realotsloginserver-master/config.lua
sed -i "s/^clientVersionMax = .*/clientVersionMax = 770/g" realotsloginserver-master/config.lua
sed -i "s/^clientVersionStr = .*/clientVersionStr = \"7.70\"/g" realotsloginserver-master/config.lua
sed -i "s/^mysqlHost = .*/mysqlHost = \"$LOCAL_IP\"/g" realotsloginserver-master/config.lua
sed -i "s/^mysqlUser = .*/mysqlUser = \"otserv\"/g" realotsloginserver-master/config.lua
sed -i "s/^mysqlPass = .*/mysqlPass = \"$MYSQL_PASSWORD\"/g" realotsloginserver-master/config.lua
sed -i "s/^mysqlDatabase = .*/mysqlDatabase = \"otserv\"/g" realotsloginserver-master/config.lua
sed -i "s/ip=\"127.0.0.1\"/ip=\"$LOCAL_IP\"/g" realotsloginserver-master/gameservers.xml

echo ""
echo ""
echo "Server installed!"
echo "To run the server, execute the following commands, each one in its own terminal:"
echo "sudo ./start-query-manager.sh"
echo "sudo ./start-game-server.sh"
echo "sudo ./start-login-server.sh"
echo ""
echo "To connect a client to use, edit the client executable file with the following IP address: $LOCAL_IP"
echo ""
echo "Further information can be found in the README.md file."

(note: I forgot to remove the last line where it suggests to read the README.md - I ended up documenting everything inside the script - so just ignore it)



start-query-manager.sh
Bash:
#!/bin/bash

echo "Running query manager from 'realots-query-manager-master/querymanager'..."
./realots-query-manager-master/querymanager



start-game-server.sh
Bash:
#!/bin/bash

GAME_PATH=/home/game

echo "Running game server from '$GAME_PATH/bin/game'..."
rm $GAME_PATH/save/game.pid
$GAME_PATH/bin/game



start-login-server.sh
Bash:
#!/bin/bash

echo "Running login server from 'realotsloginserver-master/tfls'..."
cd realotsloginserver-master
./tfls
 
Last edited:
I talked to you in the other tutorial bro, your idea is simply amazing! I don't know if it will work (I'm installing ubuntu 22.04 right now to test it) but if it works this works it's the best thing I've seen in the tibia community
Post automatically merged:

BROO!! YOU ARE A GENIUS!!!!! thank you sooooo much, now I can revive this!!! one last question, how can I create my own character?
Post automatically merged:

and, how can I save the world? I walked with a random char and deactivated the server to see, when I put it back online it went back to the starting point
 
Last edited:
I talked to you in the other tutorial bro, your idea is simply amazing! I don't know if it will work (I'm installing ubuntu 22.04 right now to test it) but if it works this works it's the best thing I've seen in the tibia community
Post automatically merged:

BROO!! YOU ARE A GENIUS!!!!! thank you sooooo much, now I can revive this!!! one last question, how can I create my own character?
Post automatically merged:

and, how can I save the world? I walked with a random char and deactivated the server to see, when I put it back online it went back to the starting point
To create your own character, you can either find the SQL commands to be executed on your MySQL database, or use one of the existing account creation tools such as Gesior2012. I'll try to come up with a simple command when I'm back home.

How are you stopping the server? I think the order matters, maybe stop the services in the reverse order i.e. first the login server, then the game server, and lastly the query manager.
 
I just took a level 1 char from the database and changed the nick to play on it.. now to save I'm having problems, I closed it in several different orders but it still doesn't save
Post automatically merged:

i have a friend with the same problem.. i tried to close the terminals in all orders possible.. you just close the tabs or do with other way? like type a command in terminal or anything like that
 
Last edited:
I just took a level 1 char from the database and changed the nick to play on it.. now to save I'm having problems, I closed it in several different orders but it still doesn't save
Post automatically merged:

i have a friend with the same problem.. i tried to close the terminals in all orders possible.. you just close the tabs or do with other way? like type a command in terminal or anything like that

I just tested it on my VM and it works as expected. I simply press Ctrl+C in each terminal to stop the services.

Did you download the optional file "realots-schema-inc-players.zip" ? If so, can you try logging in to any existing player instead of using the one you edited? (use 100 for both username and password, and pick any player).
 
it finally works!!! bro, thank you so much for all your support all this time.. all the best in your life and I hope you continue to contribute to this poor and closed tibia community!
 
how can I create my own character?

I'll put one of my personal scripts here in case someone doesn't want to download another project or just want a quick way to create a new char:

Create a file called "create-char.sh" on your Ubuntu with the following content:
Code:
#!/bin/bash

if ! service mysql status > /dev/null; then
    echo "MySQL service is not running. Please start it before running this script."
    exit 1
fi

read -e -p "Enter the name of the new char: " CHAR_NAME

read -e -p "Enter a unique account ID (10001001): " ACCOUNT_ID
ACCOUNT_ID="${ACCOUNT_ID:-10001001}"

read -e -p "Enter the account number (100): " ACCOUNT_NUMBER
ACCOUNT_NUMBER="${ACCOUNT_NUMBER:-100}"

read -e -p "Enter gender, 0 = female or 1 = male (1): " GENDER_ID
GENDER_ID="${GENDER_ID:-1}"

MYSQL_COMMAND="INSERT INTO \`players\` (\`charname\`, \`account_id\`, \`account_nr\`, \`gender\`) VALUES ('$CHAR_NAME', $ACCOUNT_ID, $ACCOUNT_NUMBER, $GENDER_ID);"

read -e -p "The following command will be executed on MySQL:

${MYSQL_COMMAND}

Confirm? (y/N) 
" CONFIRM
if [[ ! $CONFIRM =~ ^[Yy]$ ]]; then
    echo "Aborted by user."
    exit 1
fi

read -e -p "Enter MySQL username (root): " MYSQL_USERNAME
MYSQL_USERNAME="${MYSQL_USERNAME:-'root'}"

read -e -p "Enter MySQL password (otserv123): " MYSQL_PASSWORD
MYSQL_PASSWORD="${MYSQL_PASSWORD:-'otserv123'}"

read -e -p "Enter MySQL database (otserv): " MYSQL_DATABASE
MYSQL_DATABASE="${MYSQL_DATABASE:-otserv}"

mysql -u $MYSQL_USERNAME -p$MYSQL_PASSWORD $MYSQL_DATABASE -e "$MYSQL_COMMAND"

echo "Done."

Then give it the right permission by running sudo chmod +x create-char.sh

And finally execute it with sudo ./create-char.sh


it finally works!!! bro, thank you so much for all your support all this time.. all the best in your life and I hope you continue to contribute to this poor and closed tibia community!

I'm glad you liked it.
 
Hey @SilverFern,

First thanks for the automated script, it really helped me a lot.
I'm having trouble creating my own client. I changed it in a Hex editor, and also included the 00 bytes, but when I save the file, I can't open Tibia anymore, it seems to change the file type and I get this error:
1681124969179.png

Can you help me?

Thanks!
 
I found the problem.

When editing the Tibia.exe file, I was putting too many characters and that made the file incompatible.


After fixing it, it worked perfectly.

THANKS!
 
Amazing work. I still haven't been successful. Has it been tested on Ubuntu WSL? I tested 20.04 and 22.04 and both had errors.
 

Attachments

  • Captura de tela 2023-04-10 221101.png
    Captura de tela 2023-04-10 221101.png
    38 KB · Views: 52 · VirusTotal
  • Captura de tela 2023-04-10 221230.png
    Captura de tela 2023-04-10 221230.png
    103.2 KB · Views: 59 · VirusTotal
Amazing work. I still haven't been successful. Has it been tested on Ubuntu WSL? I tested 20.04 and 22.04 and both had errors.

I haven't tested it on WSL, but I wouldn't be surprised if it didn't work given that it comes with different packages and settings. For instance, the error messages in your shell indicate that there are missing packages in your Ubuntu. For instance, it complains about "unzip" not being installed, which is something that comes by default with the Ubuntu version I recommend in the initial post.

One thing you could do is to open the install.sh file and try to execute each command manually, then find solutions to the errors as they appear.
Around line 99 there is a command to install several required packages, and I suspect you'll need to add a few more packages - "unzip" being one of them.

Another thing is the difference in folder structure and permissions. That might explain the phpmyadmin error in one of the attachments.

If that doesn't work or is too much trouble, I suggest you use VirtualBox with Ubuntu 22.04.2 LTS, which is the environment I tested and am sure all works fine. Good luck.
 
I'm not very skilled. The downside of VM is that it consumes a lot of resources from a notebook, it even seems like it's going to take off lol I did the procedure through VM using the Ubuntu Desktop ISO, it loaded perfectly.
 
Last edited:
Nice job SilverFern! Thank you so much for this script!!!!!
Could you help me with just one question? How can I increase character session time?
 
Nice job SilverFern! Thank you so much for this script!!!!!
Could you help me with just one question? How can I increase character session time?
To be honest I had been asking that question myself, and was surprised how hard it was to find any information about this anywhere, so I tried to figure it out on my own.

Luckily, I found a way, see my post here: [Tutorial] How to edit idle timeout on Tibia server 7.70 (https://otland.net/threads/tutorial-how-to-edit-idle-timeout-on-tibia-server-7-70.284621/)
 
Last edited:
Hello folks! I've did managed to correctly use your scripts (thank you VERY much!), and created sucessfully the 7.70 client. BUT, I only can log into my offline server when I open the client with wine in ubuntu; when I try to log via windows (that is hosting my VM ubuntu), or any other computer in lan, It fails to log (even with my modified client). Any clue/help, please? :p

(I've tryed all that came to my mind to figure out, like turning off antiviruses & firewall on windows, but did not worked).
 
Hello folks! I've did managed to correctly use your scripts (thank you VERY much!), and created sucessfully the 7.70 client. BUT, I only can log into my offline server when I open the client with wine in ubuntu; when I try to log via windows (that is hosting my VM ubuntu), or any other computer in lan, It fails to log (even with my modified client). Any clue/help, please? :p

(I've tryed all that came to my mind to figure out, like turning off antiviruses & firewall on windows, but did not worked).

Run hostname -I in your Ubuntu shell. If the IP address doesn't look like it's in the same network as the IP of your host, you need to a) use Bridged Adapter in the network settings of your VM (e.g.: on VIrtualBox); and b) ideally set a static IP address on your VM, otherwise the IP might change when you reboot the server, which would require you to edit the client again (happened to me once, very annoying).
 
Back
Top