DxSpider update

Kin EA3CV wrote a fantastic script for updating DxSpider.

Kin Wrote :

If there is a new build, it will update and immediately restart the node.
If there are no changes, the sysop is informed.

To install it, copy the file to /spider/local_cmd
From console.pl run load/cmd the first time.
The check_build command can be used like this:

check_build Y           With Backup
check_build N           Without Backup
check_build             Without Backup

If you want to leave it automated, add in /spider/local_cmd/crontab
something like this:

0 4 * * 1,2,3,4,5 run_cmd(“check_build N”)

It can be downloaded from:

https://www.dropbox.com/s/6ttq5125qrzev67/check_build.pl?dl=0

This utility is not intended to replace the current update procedure,
it is intended for sysops who feel insecure about upgrading their cluster.
(I don’t feel insecure when it comes to updating software. I like it when it’s easier.)

Basically it does:
            git reset –hard
            git pull
            reinicio

and a full backup of the /home/spysop/spider directory in /home/sysop/backup, which will be overwritten each time check_build is run.

# You need the following package:
# apt install libfile-copy-recursive-perl  or
# cpan install File::Copy::Recursive
# Kin EA3CV, ea3cv@cronux.net
#
# 20230201 v1.0
#

use 5.10.1;
use DXDebug;
use File::Copy::Recursive;
use strict;
use warnings;

my $self = shift;
my $backup = shift;

return (1) unless $self->priv >= 9;

if ($backup eq "Y") {
        my $from_dir = "/home/sysop/spider";
        my $to_dir = "/home/sysop/backup";

        if ( !-d $to_dir ) {
                system('mkdir', $to_dir);
        }

        File::Copy::Recursive::rcopy_glob($from_dir, $to_dir);
}

system('cd /spider');

my $act = $main::gitversion;
$act =~ s/\[r\]//g;
my $res;
my $line = "cd /spider; git reset --hard; git pull";
my @out;

system('git reset --hard');

my $data = qx(git pull);
my $new = `git log --oneline | head -n 1`;

if ($data =~ /Updating/) {
        $res = "There is a new build: $new";
        dbg("DXCron::spawn: $res: $line") if isdbg('cron');
        push @out, $res;
        DXCron::run_cmd("shut");
} elsif ($data =~ /Already|actualizado/) {
        $res = "There is no new build ($main::build  $act)";
        push @out, $res;
        dbg("DXCron::spawn: $res.") if isdbg('cron');
}

return (1, @out)

 

DxSpider Crontab

An crontab example I use with my Dxspider node.

# Check Connect (At minute 0, 5, 10, 20, 30, 40, and 50)

0,5,10,20,30,40,50 * * * * start_connect('gb7htl') unless connected('gb7htl')
0,5,10,20,30,40,50 * * * * start_connect('pa1rbz') unless connected('pa1rbz')
0,5,10,20,30,40,50 * * * * start_connect('pi4cc') unless connected('pi4cc')
0,5,10,20,30,40,50 * * * * start_connect('n5wls') unless connected('n5wls')
0,5,10,20,30,40,50 * * * * start_connect('ea2rks-2') unless connected('ea2rks-2')
0,5,10,20,30,40,50 * * * * start_connect('pa2sq') unless connected('pa2sq')
0,5,10,20,30,40,50 * * * * start_connect('ed1zac-5') unless connected('ed1zac-5')

# Update stats for mrtg (At minute 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55)
00,05,10,15,20,25,30,35,40,45,50,55 * * * * run_cmd('mrtg all')

# Send announce full/local (At minute 0)
#0 * * * * run_cmd('ann full Dxspider telnet dx.packet-radio.nl 7300' . cldate . ' ' . ztime)
#0 * * * * run_cmd('ann local DXspider telnet dx.packet-radio.nl 7300 at ' . cldate . ' ' . ztime)

# Skimmers (At every minute)
* * * * * start_connect('sk0mmr') unless connected('sk0mmr')
* * * * * start_connect('sk1mmr') unless connected('sk1mmr')

# AutoUpdate DXSpider Server (At 04:00 on Monday, Tuesday, Wednesday, Thursday, and Friday)
0 4 * * 1,2,3,4,5 run_cmd("check_build Y")


# AutoUpdate USDB (At 02:00 on Monday, Wednesday, and Friday)
0 2 * * 1,3,5 spawn("cd /tmp | wget -qN ftp://ftp.w1nr.net/usdbraw.gz & /spider/perl/create_usdb.pl usdbraw.gz")
5 2 * * 1,3,5 run_cmd("load/usdb")
10 2 * * 1,3,5 spawn("rm /tmp/usdbraw.gz")

# AutoUpdate Keps (At 02:00 on Tuesday, Thursday, and Saturday)
0 2 * * 2,4,6 spawn("cd /tmp | wget -qN http://www.amsat.org/amsat/ftp/keps/current/nasabare.txt & /spider/perl/convkeps.pl -p nasabare.txt &")
5 2 * * 2,4,6 run_cmd("load/keps")
10 2 * * 2,4,6 spawn("rm /tmp/nasabare.txt")

# AutoUpdate CTY.DAT (At 03:00 on Sunday, Tuesday, and Friday)
0 3 * * 0,2,5 spawn("cd /spider/local_data | wget -qN https://www.country-files.com/cty/cty.dat &")
0 3 * * 0,2,5 spawn("cd /spider/local_data | wget -qN https://www.country-files.com/cty/wpxloc.dat &")
0 3 * * 0,2,5 spawn("cd /spider/local_data | wget -qN https://www.country-files.com/cty/wpxloc.raw &")
2 3 * * 0,2,5 spawn("cd /spider/local_data | /spider/perl/create_prefix.pl")
3 3 * * 0,2,5 run_cmd("load/prefix")

# remove old files (At 00:00 in every month from January through December)
0 0 * 1-12 * spawn(q[find /spider/local_data/debug -type f -mtime +2 -exec rm -f {} \;])
2 0 * 1-12 * spawn(q[find /spider/local_data/log -type f -mtime +2 -exec rm -f {} \;])
3 0 * 1-12 * spawn(q[find /spider/local_data/spots -type f -mtime +2 -exec rm -f {} \;])
4 0 * 1-12 * spawn(q[find /spider/local_data/wcy -type f -mtime +1 -exec rm -f {} \;])
5 0 * 1-12 * spawn(q[find /spider/local_data/wwv -type f -mtime +1 -exec rm -f {} \;])

# Blacklist. TOR & Others (At minute 30)
30 * * * * spawn('cd /spider/local_data; wget -qN http://www.dxspider.net/download/badip.torexit')
30 * * * * spawn('cd /spider/local_data; wget -qN http://www.dxspider.net/download/badip.torrelay')
30 * * * * spawn('cd /spider/local_data; wget -qN http://www.dxspider.net/download/badip.global')
31 * * * * run_cmd('load/badip')