87 MagicBox : Magicbane in a Box
Bardiel edited this page 3 years ago

MagicBox : Magicbane MMO in a Box!


⦿ Fully containerized Magicbane server

⦿ Runs on commodity hardware

⦿ Allows anyone with a dream and a pc to run their own MMO

⦿ Full integration with the Magicbane repo for easy development

⦿ Plugin system allows for full run-time modification of the game

⦿ Automatic network configuration. Open ports on your router and play

⦿ Magicbane MMO technology; launching a new era of Shadowbane



Minutes to a MagicBox

MagicBox contains the exact same codebase, database and devops scripts that drive the Magicbane production server. Install Docker and you are only three commands away from running your own Magicbane server.

Docker

Docker is available for most all operating systems. Along with a Docker Hub account these are the only two pre-requisites to running a MagicBox. It is worth mentioning that Docker is most at home on Linux.

The following instructions will work for both Linux and Windows.

Install Docker

Docker Hub

Sign into Docker Hub

docker login

Pull the latest MagicBox image to your local machine.

docker pull magicbane/magicbox

It is advised that you pull a fresh image often.

Starting the MagicBox

The paths to mount the config directory must be absolute paths. (containerpath:hostpath)
***Users must create this directory before the first run of MagicBox. If created by the container it will be owned by root.

Linux

docker run --name magicbox -p 5000:5000 -p 6000:6000 -p 8000:8000 -v /home/mbbox/magicbane/mb.conf:/home/YOURDIRHERE/mb.conf magicbane/magicbox:latest &

Windows

docker run --name magicbox -p 5000:5000 -p 6000:6000 -p 8000:8000 -v "/mnt/c/Users/YOURDIRHERE/mb.conf:/home/mbbox/magicbane/mb.conf" magicbane/magicbox:latest &

Below is the script the MagicBane team uses to cycle MagicBox in testing.


# MagicBox : © 2022 Magicbane Project (www.magicbane.com)
# File: magicbox.sh
# Purpose: Startup magicbox docker image

# kill running container and prune if exists

echo "Killing running MagicBox images..."
docker rm -f magicbox > /dev/null 2>&1

# start container

echo "Starting MagicBox"
docker run --name magicbox -p 5000:5000 -p 6000:6000 -p 8000:8000 -v /home/mbbox/magicbane/mb.conf:/home/mbbox/mb.conf magicbane/magicbox:latest &

Logging into a fresh MagicBox

Always use a freshly patched client. Client can be obtained from www.magicbane.com

In the client folder edit the Config/ArcaneIP file to reflect the public ip of your MagicBox host machine.

SERVER NAME: MAGICBANE
SERVER= HOST.PUBLIC.IP.HERE
PORT= 6000

When a MagicBox virgin administrator first spins up his server it is assumed they might not have web registration sorted on day one. With this in mind the server is pre-configured to auto register accounts on login.

MB_LOGIN_AUTOREG="TRUE"

When the time comes, either with Discord or Forum based registration, we have the backend facilities you can plug right into.

CALL singleAccountCreate(?,?); CALL discordAccountCreate(?,?,?);

Managing your MagicBox

Once MagicBox is running the following will grant you shell access.

docker exec -it magicbox /bin/bash

MagicBox currently runs with an internal UID/GID of 1000/1000. Better integration occurs if the user running the container has 1000/1000 as well. Barely noticable side effects; running container might not have write access to the mb.conf mount or possibly could display as an incorrect user in top.

Inside the Magicbox you will find the following devops utlities.

homedirImage

Script Purpose
mbkill.sh kills a running login and world server
mbstart.sh cold starts a login and world server
mbrestart.sh kills and then restarts a running game
mbbuild.sh builds and compiles branch from the repo
mbdump.sh dumps database to sql file
mbrestore.sh restores database from sql file
sndmsg.sh sends an in-game flash message

The two bread and butter scripts in a MagicBox administrator's toolkit are mbbuild.sh and mbrestart.sh.

Automated backups can be managed by using mbdump.sh in a cron job. An example cron job would read (see below). Take note that the CronLogs/EODJobs.log may need to be manually created first, or you can save your logs at a different location of your choosing (or remove the logging altogether). This runs the mbdump.sh nightly at 2:00am server time. You're free to adjust this to your liking. CronTabGuru

00 02 * * * export CLASSPATH="/usr/share/java/*" && /home/mbbox/magicbane/mbdump.sh "Commencing Daily Rebootings" >> /home/mbbox/magicbane/CronLogs/EODJobs.log 2>&1

The vigilant MagicBox administrator will always pay close attention to console_login and console_world. Anything in either log tagged as ERROR should be addressed. This applies doubly to bootstrap.

grep "ERROR" console_server

The following two commands are very useful; most especially at bootstrap. They will show you what the server is currently doing.

tail console_login
tail console_server

MySQL client is available within MagicBox

magicbox~/magicbane$mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 437
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)

mysql> use magicbane;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update obj_account set status="ADMIN";

mbbox is in the container wheel group along with sudo pre-configured.

magicbox~/magicbane$sudo sh
#

Configuration

*mb.conf/ is a directory shared between MagicBox and the host. Inside MagicBox it is mounted at ~/magicbane/mb.conf. Where this directory is mounted on the host is user preference; controlled through the docker run command. You can use this direcotry to easily transfer files between host and container.

Upon bootstrap MagicBox will first look for magicbane.conf within the shared mb.conf/ directory. If not present the game will boot from the container's copy within mb.data/. This configuration boots using the internal MySQL server and comes pre-loaded with a wiped database.

The game will inform you on bootstrap the location of the .conf file that it loaded.

[mbbox@mta6 ~]$ ./magicbox.sh
Killing running MagicBox images...
Starting MagicBox
[mbbox@mta6 ~]$ Configure using mb.data/magicbane.conf

This shows that MagicBox did not detect a configuration file in mb.conf/ and is therefore booting with the internal config.

Note that a container is ephemeral. When the container stops all changes to it are lost. This includes the internal database. If you want your world to persist supply a config file that points to an external mysql database. This can be a done via the MySQL docker image in just a few commands. Alternative is to install MySQL directly onto a host. Instructions on configuring a MySQL server for use with Magicbane can be found on the MagicBox to Server page.

At the very least a new MagicBox administrator might wish for to change the world name to suit his fancy.

MB_WORLD_NAME="MagicBox"

Network

It is advised that the Magicbox administrator not edit the following values. 0.0.0.0 instructs Magicbane to self-configure both the bind address and public facing ip.

MB_PUBLIC_ADDR="0.0.0.0"
MB_BIND_ADDR="0.0.0.0"

MagicBox uses three ports. If behind a NAT/router the user must open ports on his router or configure a DMZ. There is no need to do anything with the firewall of the host machine. Docker will manage that for you.

Port Application
5000 Debugger
6000 Login Server
8000 World Server

It is recommended that you change the external port via the docker run command (host:container) not within magicbane.conf. Docker will automatically bridge traffic to the correct internal port.

If using a mobile phone tether in a situation where there is no router to port forward then MagicBox still will function locally. See the Troubleshootings page.

Security

The MagicBox container is perfectly secure out of the box. It is a minimal linux install that nominally exposes two ports.

This can be verified with sudo apt list --installed from inside the continer.

It will not be so secure if you start additional services and open additional ports. Try not to spin up ssh server on a container that shares the same passwords and deploy key as every other MagicBox!

Support

Support is available on the Magicbane Discord server. Join at www.magicbane.com and pick MagicBot's brain.