]> www.dxcluster.org Git - spider.git/blob - perl/update_sysop.pl
update sh/qrz and start get/keps
[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 #
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 }
24
25 use DXVars;
26 use DXUser;
27
28 sub create_it
29 {
30         my $ref;
31         
32         while ($ref = DXUser::get(uc $mycall)) {
33                 print "old call $mycall deleted\n";
34                 $ref->del();
35         }
36         
37         my $self = DXUser->new(uc $mycall);
38         $self->{alias} = uc $myalias;
39         $self->{name} = $myname;
40         $self->{qth} = $myqth;
41         $self->{qra} = uc $mylocator;
42         $self->{lat} = $mylatitude;
43         $self->{long} = $mylongitude;
44         $self->{email} = $myemail;
45         $self->{bbsaddr} = $mybbsaddr;
46         $self->{homenode} = uc $mycall;
47         $self->{sort} = 'S';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
48         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
49         $self->{lastin} = 0;
50         $self->{dxok} = 1;
51         $self->{annok} = 1;
52
53         # write it away
54         $self->close();
55         print "new call $mycall added\n";
56
57         # now do one for the alias
58         while ($ref = DXUser::get($myalias)) {
59                 print "old call $myalias deleted\n";
60                 $ref->del();
61         }
62
63         $self = DXUser->new(uc $myalias);
64         $self->{name} = $myname;
65         $self->{qth} = $myqth;
66         $self->{qra} = uc $mylocator;
67         $self->{lat} = $mylatitude;
68         $self->{long} = $mylongitude;
69         $self->{email} = $myemail;
70         $self->{bbsaddr} = $mybbsaddr;
71         $self->{homenode} = uc $mycall;
72         $self->{sort} = 'U';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
73         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
74         $self->{lastin} = 0;
75         $self->{dxok} = 1;
76         $self->{annok} = 1;
77         $self->{lang} = 'en';
78         $self->{group} = [qw(local #9000)];
79   
80         # write it away
81         $self->close();
82         print "new call $myalias added\n";
83
84 }
85
86 die "\$myalias \& \$mycall are the same ($mycall)!, they must be different (hint: make \$mycall = '${mycall}-2';).\n" if $mycall eq $myalias;
87
88 $lockfn = "$root/local/cluster.lck";       # lock file name
89 if (-e $lockfn) {
90         open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!";
91         my $pid = <CLLOCK>;
92         chomp $pid;
93         die "Sorry, Lockfile ($lockfn) and process $pid exist, a cluster is running\n" if kill 0, $pid;
94         close CLLOCK;
95 }
96
97 DXUser->init($userfn, 1);
98 create_it();
99 DXUser->finish();
100 print "Update of $myalias on cluster $mycall successful\n";
101 exit(0);
102