]> ruin.nu Git - ndwebbie.git/blobdiff - scripts/fetchdumps.pl
LWP::Simple fix for cloudfare
[ndwebbie.git] / scripts / fetchdumps.pl
index b8be1c36ca111561d5054337d18ecba75fc84b9b..883c90f37c2a3edb4822c27d9ea913a91c9b6591 100755 (executable)
@@ -22,12 +22,16 @@ q{
 
 use strict;
 use warnings;
+use local::lib;
 use DBI;
 use DBD::Pg qw(:pg_types);
 
-use LWP::Simple;
+use LWP::Simple qw/head get $ua/;
+$ua->agent("Stupid user agent check is stupid");
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
 
-use lib qw{/var/www/ndawn/};
 use ND::DB;
 
 our $dbh = ND::DB::DB();
@@ -42,7 +46,7 @@ for my $type ("planet","alliance","galaxy"){
        $select->execute($type,$head[2]);
        unless ($select->fetchrow){
                my $file = get("http://game.planetarion.com/botfiles/${type}_listing.txt");
-               if ($file =~ /Tick: (\d+)/){
+               if (defined $file && $file =~ /Tick: (\d+)/){
                        $updated = $1;
                        $insert->execute($1,$type,$head[2],$file);
                }
@@ -51,9 +55,13 @@ for my $type ("planet","alliance","galaxy"){
 }
 
 if ($updated){
-       `/var/www/ndawn/scripts/parsedumps.pl $updated`;
-       `/var/www/ndawn/scripts/ndrank.pl`;
-       $dbh->do("UPDATE misc SET value = ? WHERE id = 'TICK'", undef, $updated);
+       `perl $FindBin::Bin/parsealliances.pl $updated`;
+       `perl $FindBin::Bin/parseplanets.pl $updated`;
+       `perl $FindBin::Bin/parsegalaxies.pl $updated`;
+       `perl $FindBin::Bin/ndrank.pl`;
+       $dbh->do(q{UPDATE misc SET value = ? WHERE id = 'TICK'}, undef, $updated);
+       system 'killall','-USR1', 'ndbot.pl';
+       local $dbh->{Warn} = 0;
 }