]> www.dxcluster.org Git - spider.git/blob - perl/update_sysop.pl
take the length for dupe checking after normalisation
[spider.git] / perl / update_sysop.pl
1 #!/usr/bin/perl
2 #
3 # remove all records with the sysop/cluster callsign and recreate
4 # it from the information contained in DXVars
5 #
6 # WARNING - this must be run when the cluster.pl is down!
7 #
8 # This WILL NOT delete an old sysop call if you are simply
9 # changing the callsign.
10 #
11 # Copyright (c) 1998 Dirk Koopman G1TLH
12 #
13 # $Id$
14
15
16 # make sure that modules are searched in the order local then perl
17 BEGIN {
18         # root of directory tree for this system
19         $root = "/spider"; 
20         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
21
22         unshift @INC, "$root/local";
23         sub main::mkver {}
24 }
25
26 use DXVars;
27 use DXUser;
28
29 sub create_it
30 {
31         my $ref;
32         
33         while ($ref = DXUser->get(uc $mycall)) {
34                 print "old call $mycall deleted\n";
35                 $ref->del();
36         }
37         
38         my $self = DXUser->new(uc $mycall);
39         $self->{alias} = uc $myalias;
40         $self->{name} = $myname;
41         $self->{qth} = $myqth;
42         $self->{qra} = uc $mylocator;
43         $self->{lat} = $mylatitude;
44         $self->{long} = $mylongitude;
45         $self->{email} = $myemail;
46         $self->{bbsaddr} = $mybbsaddr;
47         $self->{homenode} = uc $mycall;
48         $self->{sort} = 'S';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
49         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
50         $self->{lastin} = 0;
51         $self->{dxok} = 1;
52         $self->{annok} = 1;
53
54         # write it away
55         $self->close();
56         print "new call $mycall added\n";
57
58         # now do one for the alias
59         while ($ref = DXUser->get($myalias)) {
60                 print "old call $myalias deleted\n";
61                 $ref->del();
62         }
63
64         $self = DXUser->new(uc $myalias);
65         $self->{name} = $myname;
66         $self->{qth} = $myqth;
67         $self->{qra} = uc $mylocator;
68         $self->{lat} = $mylatitude;
69         $self->{long} = $mylongitude;
70         $self->{email} = $myemail;
71         $self->{bbsaddr} = $mybbsaddr;
72         $self->{homenode} = uc $mycall;
73         $self->{sort} = 'U';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
74         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
75         $self->{lastin} = 0;
76         $self->{dxok} = 1;
77         $self->{annok} = 1;
78         $self->{lang} = 'en';
79   
80         # write it away
81         $self->close();
82         print "new call $myalias added\n";
83
84 }
85
86 $lockfn = "$root/local/cluster.lck";       # lock file name
87 if (-e $lockfn) {
88         open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!";
89         my $pid = <CLLOCK>;
90         chomp $pid;
91         die "Sorry, Lockfile ($lockfn) and process $pid exist, a cluster is running\n" if kill 0, $pid;
92         close CLLOCK;
93 }
94
95 DXUser->init($userfn, 1);
96 create_it();
97 DXUser->finish();
98 print "Update of $myalias on cluster $mycall successful\n";
99 exit(0);
100