Working version of mod updater
This is a fully working version of the mod updater. I've used it serveral times and it does work.
This commit is contained in:
parent
234fd090ca
commit
75e8629de2
1 changed files with 18 additions and 5 deletions
23
update.pl
23
update.pl
|
@ -11,7 +11,7 @@ use Storable;
|
|||
|
||||
$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/.var/app/net.minetest.Minetest/.minetest/mods/"; # where your server stores its mods
|
||||
$modpath = "/home/kake26/.minetest/mods/"; # where your server stores its mods
|
||||
|
||||
sub chk_update () {
|
||||
|
||||
|
@ -34,6 +34,9 @@ foreach my $key (keys %{ $conf->{"mods"}}) { # the fing arrow -> sigh could have
|
|||
|
||||
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";
|
||||
}
|
||||
|
@ -42,7 +45,7 @@ foreach my $key (keys %{ $conf->{"mods"}}) { # the fing arrow -> sigh could have
|
|||
}
|
||||
|
||||
sub get_ready (){
|
||||
$mods = `find $modpath -maxdepth 1 -type d -print`; # -print is there for a reason, find saved a huge amount of time
|
||||
$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("\/",$_);
|
||||
|
@ -70,10 +73,20 @@ system("wget -O index2.json $updlsturl");
|
|||
return;
|
||||
}
|
||||
|
||||
sub do_update () {
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
# Maybe get ready and check update should be called every time
|
||||
|
||||
if (-e "mods"){
|
||||
# load data
|
||||
print "Loading data\n";
|
||||
|
@ -83,4 +96,4 @@ if (-e "mods"){
|
|||
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