]> scm.dxcluster.org Git - spider.git/blob - perl/update_sysop.pl
actually commit the set/isolate patch!
[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 }
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   
79         # write it away
80         $self->close();
81         print "new call $myalias added\n";
82
83 }
84
85 $lockfn = "$root/local/cluster.lck";       # lock file name
86 if (-e $lockfn) {
87         open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!";
88         my $pid = <CLLOCK>;
89         chomp $pid;
90         die "Sorry, Lockfile ($lockfn) and process $pid exist, a cluster is running\n" if kill 0, $pid;
91         close CLLOCK;
92 }
93
94 DXUser->init($userfn, 1);
95 create_it();
96 DXUser->finish();
97 print "Update of $myalias on cluster $mycall successful\n";
98 exit(0);
99