Code clean up and optimization
This commit is contained in:
parent
1064c06902
commit
46548688bf
1 changed files with 11 additions and 17 deletions
28
update.pl
28
update.pl
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# This script will check and update minetest mods as needed. It is not 100% perfect, but it does work.
|
||||||
|
# Currently, any version checking is done against the mod file generated from a previous run.
|
||||||
|
|
||||||
# This was a bash script until I determined the level of invoking the ancient gods of the console required to make
|
# 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
|
# that work would be just too much
|
||||||
|
|
||||||
use Storable;
|
use Storable;
|
||||||
#use Data::Dumper;
|
|
||||||
|
|
||||||
# I know declaring a empty hash is 100% unnessecary but I am anyway
|
# I know declaring a empty hash is 100% unnessecary but I am anyway
|
||||||
%conf = {}; # this will be stored used to keep track of stuff
|
%conf = {}; # this will be stored used to keep track of stuff
|
||||||
|
@ -67,12 +69,6 @@ store \%conf, 'mods';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_file () {
|
|
||||||
# get the
|
|
||||||
system("wget -O index2.json $updlsturl");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub do_update ($mod,$ver,$author) {
|
sub do_update ($mod,$ver,$author) {
|
||||||
# https://content.minetest.net/packages/TenPlus1/mob_horse/download/
|
# https://content.minetest.net/packages/TenPlus1/mob_horse/download/
|
||||||
# https://content.minetest.net/packages/jp/i3/releases/14157/download/
|
# https://content.minetest.net/packages/jp/i3/releases/14157/download/
|
||||||
|
@ -98,20 +94,18 @@ return;
|
||||||
# Maybe get ready and check update should be called every time
|
# Maybe get ready and check update should be called every time
|
||||||
|
|
||||||
if (-e "mods"){
|
if (-e "mods"){
|
||||||
# load data
|
|
||||||
|
# load data and business as usual
|
||||||
|
|
||||||
print "Loading data\n";
|
print "Loading data\n";
|
||||||
$conf = retrieve('mods');
|
$conf = retrieve('mods');
|
||||||
get_file();
|
system("wget -O index2.json $updlsturl"); # Don't need a whole sub for one command
|
||||||
chk_update();
|
chk_update();
|
||||||
update_files();
|
update_files();
|
||||||
}else{
|
}else{
|
||||||
# check if index.json exists if not then create it
|
# if the mods file doesn't exist then we need to create it
|
||||||
if (-e "index.json") {
|
print "Creating mods file\n";
|
||||||
# do noothing
|
|
||||||
}else{
|
|
||||||
system("wget -O index.json $updlsturl");
|
system("wget -O index.json $updlsturl");
|
||||||
}
|
|
||||||
get_ready();
|
get_ready();
|
||||||
# chk_update expects a hash retrived from storables so program needs to be run again after this
|
print "Done. You will need to run me again to update mods.\n";
|
||||||
#chk_update();
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue