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
|
||||
|
||||
# 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
|
||||
# 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
|
||||
|
@ -67,12 +69,6 @@ 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/
|
||||
|
@ -98,20 +94,18 @@ return;
|
|||
# Maybe get ready and check update should be called every time
|
||||
|
||||
if (-e "mods"){
|
||||
# load data
|
||||
|
||||
# load data and business as usual
|
||||
|
||||
print "Loading data\n";
|
||||
$conf = retrieve('mods');
|
||||
get_file();
|
||||
system("wget -O index2.json $updlsturl"); # Don't need a whole sub for one command
|
||||
chk_update();
|
||||
update_files();
|
||||
}else{
|
||||
# check if index.json exists if not then create it
|
||||
if (-e "index.json") {
|
||||
# do noothing
|
||||
}else{
|
||||
# if the mods file doesn't exist then we need to create it
|
||||
print "Creating mods file\n";
|
||||
system("wget -O index.json $updlsturl");
|
||||
}
|
||||
get_ready();
|
||||
# chk_update expects a hash retrived from storables so program needs to be run again after this
|
||||
#chk_update();
|
||||
}
|
||||
print "Done. You will need to run me again to update mods.\n";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue