Beammp-repo | php shell script for remote mod management

beammp-repo

Script to manage and update BeamNG mods on remote BeamMP servers

Requires php-mbstring and php-curl, along with GitHub - paquettg/php-html-parser: An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.

Installation

Clone or download repository, copy db.json.example to db.json, add your mods folder using full file path (eg /home/beammp/beammp/Resources/Client/) to the dir variable in db.json.

Usage

To update mods: php repo.php

To add mod(s): php repo.php [url to mod page] ...

for example php repo.php https://www.beamng.com/resources/6x6-d-series.22055/ https://www.beamng.com/resources/gavril-h-series-type-a-bus.24930/

To list or delete mod(s): php repo.php --del mods will be listed, enter q to cancel deletion, enter numbers separated by a space to delete those mods. Remaining mods will update after deletion

3 Likes

Please note, there is a significant, infrequent bug while updating mods. Occasionally the BeamNG website will provide a download link in a different format, and I haven’t had it happen frequently enough to account for it. If it occurs, it’ll dump a couple of variables to the output, feel free to paste them here to help with debugging it. Otherwise, just wait a few minutes and try again.

Hey, Nice work!

Might I make a suggestion, What about if you were to write this in Lua as a serverside mod, this would allow you to automatically update the mods on a server as a part of the server. This would allow it to work better for users who are using hosted solutions which are provided through a web panel.

Neat idea non the less!!

While I’ll fix a few bugs, I don’t intend on properly supporting this script. I wrote it for me, and imagine other people will find it useful.

I’m not familiar with Lua, but out of curiosity, I looked at some of your documentation, and it looks reasonable to do in roughly the same way my script does. If I feel like it, I may rewrite this as a server plugin. For posterity, a few questions related to that potential rewrite:

Where does the FD class locate relative directories? Is it in the same directory as the BeamMP-Server executable?

Does the server handle Client mods being changed, updated, etc? If so, how?

Hello! The relative directory begins at the server executable, confirm in the server console by entering a lua state with lua and using print(FS.Exists("BeamMP-Server.exe")) which outputs true:
image

At present, the server only handles the mods that were present when it started. If mods are updated while the server is running, clients will experience issues downloading. If part of the script either notifies the owner that mods were updated and they need to restart the server, or notifies and then shuts the server down when updates are done downloading, I think this would be a fine way to deal with the fact that they aren’t live updated; but I believe there are plans for streamable mod updating where this would be moot.

Among other server functions, FS.ListFiles() might come in handy for your purposes, FS.ListFiles("Resources/Client") would return a table of the mod filenames:
image

2 Likes