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