Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
c35742a24d | |||
![]() |
75e8629de2 | ||
![]() |
234fd090ca | ||
![]() |
96dd09948c | ||
![]() |
92c157110c | ||
![]() |
ec8b3b498e | ||
![]() |
5164ab6e8f | ||
![]() |
5f7cceafb3 | ||
![]() |
48f1a0f6fd | ||
![]() |
00ffcbc05a |
7 changed files with 169 additions and 1 deletions
12
README.md
12
README.md
|
@ -1,3 +1,13 @@
|
|||
# Minetest
|
||||
|
||||
Minetest related code
|
||||
My Dev branch for minetest server related code. Currently it contains a mod updater for a minetest server. This is a work in progress, use at your own risk.
|
||||
|
||||
# Notes
|
||||
|
||||
Version checking and comparing works. index.json is the current index of all avaialble minetest mods as pulled from content.minecraft.net. index2.json should be
|
||||
a current copy from the aforementioned site using the API. index.json can be kept as is after your first run, only index2.json really needs to change for the version
|
||||
detection to work. I suggest setting up a cron job to refresh index2.jon and rotate out index2.json to index.json if you want the script out put to properly reflect the old version numbers. I'll proably include a small bash script you can run to handle that later.
|
||||
|
||||
# Update as of 8/21/22
|
||||
|
||||
Needs a potential functions to rescan installed mods as needed. Needs to proably have some sort of a backup for existing mods, before updating. Also this program isn't meant to install mods off the main minetest content db site, its purpose is to make updating easy. Also hopefully I can make that safe as well. Maybe this will be expanded in the future into a tool to fully manage mods install/update/remove included and maybe full server backups as well. Thus far though its just centered around updating mods easily. I'm open to expanding this into a full tool set for minetest servers though.
|
17
buildstable.bash
Normal file
17
buildstable.bash
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
# wget https://github.com/minetest/minetest/archive/master.tar.gz
|
||||
wget https://github.com/minetest/minetest/archive/refs/tags/5.6.1.tar.gz
|
||||
tar xf 5.6.1.tar.gz
|
||||
cd minetest-5.6.1
|
||||
cd games/
|
||||
wget https://github.com/minetest/minetest_game/archive/master.tar.gz
|
||||
tar xf master.tar.gz
|
||||
mv minetest_game-master minetest_game
|
||||
cd ..
|
||||
cd lib/
|
||||
wget https://github.com/minetest/irrlicht/archive/master.tar.gz
|
||||
tar xf master.tar.gz
|
||||
mv irrlicht-master irrlichtmt
|
||||
cd ..
|
||||
cmake . -DRUN_IN_PLACE=TRUE -DBUILD_SERVER=TRUE -DBUILD_CLIENT=FALSE
|
||||
make -j$(nproc)
|
1
index.json
Normal file
1
index.json
Normal file
File diff suppressed because one or more lines are too long
1
index2.json
Normal file
1
index2.json
Normal file
File diff suppressed because one or more lines are too long
BIN
mods
Normal file
BIN
mods
Normal file
Binary file not shown.
29
server.bash
Normal file
29
server.bash
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
# script to start and stop minetest server
|
||||
|
||||
|
||||
if [[ $1 == "start" ]]
|
||||
then
|
||||
echo "STARTING"
|
||||
/home/kake26/minetest-5.6.1/bin/minetestserver --quiet --logfile /home/kake26/minetest/minetest.log --config /home/kake26/minetest/conf/minetest.conf --world /home/kake26/minetest/minetest-server/.minetest/worlds/world2/ &
|
||||
pid=$!
|
||||
echo $pid > /home/kake26/minetest/mintest.pid
|
||||
fi
|
||||
|
||||
if pidof minetestserver
|
||||
then
|
||||
# Horribly cheap but works
|
||||
echo "OK"
|
||||
else
|
||||
# Seriously why not
|
||||
/home/kake26/minetest-5.6.1/bin/minetestserver --quiet --logfile /home/kake26/minetest/minetest.log --config /home/kake26/minetest/conf/minetest.conf --world /home/kake26/minetest/minetest-server/.minetest/worlds/world2/ &
|
||||
fi
|
||||
|
||||
if [[ $1 == "stop" ]]
|
||||
then
|
||||
echo "STOPING"
|
||||
$(pidof minetestserver | xargs kill -s INT)
|
||||
fi
|
||||
exit 0
|
||||
|
110
update.pl
Normal file
110
update.pl
Normal file
|
@ -0,0 +1,110 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# This was a bash script until I determined the level of invoking the ancient gods of the console required to make
|
||||
# that work would be just too much
|
||||
|
||||
use Storable;
|
||||
#use Data::Dumper;
|
||||
|
||||
# I know declaring a empty hash is 100% unnessecary but I am anyway
|
||||
%conf = {}; # this will be stored used to keep track of stuff
|
||||
|
||||
$updfile = "index.json"; # I could use JSON here, but it might be easier to abuse jq
|
||||
$updlsturl = "https://content.minetest.net/api/packages/"; # give use a json file of everything available
|
||||
$modpath = "/home/kake26/.minetest/mods/"; # where your server stores its mods
|
||||
|
||||
sub chk_update () {
|
||||
|
||||
print "Checking for updates...\n";
|
||||
|
||||
foreach my $key (keys %{ $conf->{"mods"}}) { # the fing arrow -> sigh could have saved so much time
|
||||
|
||||
print "Checking mod $key \n";
|
||||
|
||||
# So we can now check against index2.json
|
||||
|
||||
$author2 = `jq -c '.[] | select(.name =="$key") | .author' index2.json`;
|
||||
$author2 =~ s/\"//g;
|
||||
|
||||
$release2 = `jq -c '.[] | select(.name =="$key") | .release' index2.json`;
|
||||
$release2 =~ s/\"//g;
|
||||
|
||||
chomp($author2);
|
||||
chomp($release2);
|
||||
|
||||
if ($conf->{"mods"}{$key}{"release"} != $release2) {
|
||||
print "Mod $key current release: " . $release2 . " installed: " . $conf->{"mods"}{$key}{"release"} ."!\n";
|
||||
# we should trigger the updater here
|
||||
|
||||
&do_update($key,$release2,$author2);
|
||||
}else{
|
||||
print "Mod $key up to date\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sub get_ready (){
|
||||
$mods = `find $modpath -type d -maxdepth 1 -print`; # -print is there for a reason, find saved a huge amount of time
|
||||
@mods = split("\n",$mods);
|
||||
foreach(@mods){
|
||||
@tmods = split("\/",$_);
|
||||
$tmname = pop(@tmods);
|
||||
if ($tmname eq "mods"){
|
||||
next;
|
||||
}
|
||||
# At this point we should have a mod's name
|
||||
$author = `jq -c '.[] | select(.name =="$tmname") | .author' index.json`; #jq is a time saver
|
||||
$author =~ s/\"//g;
|
||||
chomp($author);
|
||||
$release = `jq -c '.[] | select(.name =="$tmname") | .release' index.json`;
|
||||
$release =~ s/\"//g;
|
||||
chomp($release);
|
||||
$conf{"mods"}{$tmname}{"author"} = $author;
|
||||
$conf{"mods"}{$tmname}{"release"} = $release;
|
||||
}
|
||||
store \%conf, 'mods';
|
||||
return;
|
||||
}
|
||||
|
||||
sub get_file () {
|
||||
# get the
|
||||
system("wget -O index2.json $updlsturl");
|
||||
return;
|
||||
}
|
||||
|
||||
sub do_update ($mod,$ver,$author) {
|
||||
# https://content.minetest.net/packages/TenPlus1/mob_horse/download/
|
||||
# https://content.minetest.net/packages/jp/i3/releases/14157/download/
|
||||
$mod = $_[0];
|
||||
$ver = $_[1];
|
||||
$author = $_[2];
|
||||
|
||||
system("wget -O $mod.zip https://content.minetest.net/packages/$author/$mod/releases/$ver/download/");
|
||||
system("unzip -o $mod.zip");
|
||||
# print "Update info $mod $ver $author\n";
|
||||
}
|
||||
|
||||
sub update_files () {
|
||||
# This is triggered when mod updates are detected
|
||||
system("rm index.json");
|
||||
system("cp index2.json index.json");
|
||||
system("rm mods");
|
||||
undef(%conf);
|
||||
&get_ready();
|
||||
return;
|
||||
}
|
||||
# Maybe get ready and check update should be called every time
|
||||
|
||||
if (-e "mods"){
|
||||
# load data
|
||||
print "Loading data\n";
|
||||
$conf = retrieve('mods');
|
||||
get_file();
|
||||
chk_update();
|
||||
update_files();
|
||||
}else{
|
||||
get_ready();
|
||||
# chk_update expects a hash retrived from storables so program needs to be run again after this
|
||||
#chk_update();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue