Skip to content

filipopo/MF-ansible

Repository files navigation

MF-ansible

This project allows you to automatically provision a Mobile Forces game server together with a responsive website for server management. The website is integrated with Ko-fi and PayPal for donation processing, uses an SQLite3 database to store donation info and displays it on the landing page with more detailed info such as the top donators available on the statistics page. Ask DeepWiki

image

The project is deployed on Hetzner at https://mf.nofisto.com through GitHub Actions and uses Cloudflare as a CDN and domain registrar, the root of the website code can be found at templates/webserver/website

The website was made with symfony new website --version="7.2.x" and the cli was installed with

curl -sS https://get.symfony.com/cli/installer | bash
sudo mv "$HOME/.symfony5/bin/symfony" /usr/local/bin/symfony

Setup instructions

Put your MobileForces.zip in the root folder and run

ansible-playbook playbook.yml -u root -i mf.nofisto.com,

You may configure various options in vars.yml, notably the sync paypal script relies on PAYPAL_CLIENTID and PAYPAL_SECRETKEY variables which can be obtained here, and AdminName will be used in MasterServer-Settings.j2 and passed as KOFI_NAME. This example relies on MobileForces.zip creating a MobileForces folder

The Ansible playbook transfers game files, installs necessary packages and sets up Systemd services for the game server, master server and FastDL of game files through an Apache2 web server which is also used for the website, an SSL certificate is automatically added to it by using Let's Encrypt's certbot tool, these steps are made in a modular way and can be excluded

Run these commands in the website folder to see if you have everything needed to run the app

composer install
symfony check:requirements

Then start it with

ADMIN_PASSWORD=P@ssword123! php bin/console doctrine:migrations:migrate -n
export APP_SECRET=secret KOFI_TOKEN=token KOFI_NAME=admin
symfony server:start

Some other environment variables can be found in .env

APP_ENV=dev
DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"
COST_HISTORY='[{"date":"2023-10-22 15:35:11","cost":12.49},{"date":"2026-04-01 00:00:00","cost":16.49}]'
KOFI_CURRENCY=€

Useful info

Consider optimising the php config: https://symfony.com/doc/current/performance.html

If you can't change the apache vhost run this which will make a .htaccess file in public

composer require symfony/apache-pack

You can test the donation route after setting KOFI_TOKEN with

curl -L --data-urlencode data@data.json http://127.0.0.1:8000/donate_notify

If you change the database files, run this to make migration files and then migrate up

php bin/console make:migration

If you need to change the password, downgrade with the following command and then migrate up

php bin/console doctrine:migrations:execute --down DoctrineMigrations\\Version20250107003305

Thanks to

Masterserver-Qt5 for the master server implementing the Gamespy v0 protocol

elFinder and FMElfinderBundle for the file manager

UnrealTournamentPatches for the updated System64 packages

About

Automatic provisioning of a game server through Ansible featuring a responsive PHP management website for the server

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages