]> scm.dxcluster.org Git - spider.git/blob - perl/create_sysop.pl
restore talk "<call> not visible on cluster" message
[spider.git] / perl / create_sysop.pl
1 #!/usr/bin/perl
2 #
3 # create a NEW user database and the sysop record
4 #
5 # WARNING - running this will destroy any existing user database
6 #
7 # Copyright (c) 1998 Dirk Koopman G1TLH
8 #
9 #
10
11
12 # make sure that modules are searched in the order local then perl
13 BEGIN {
14         # root of directory tree for this system
15         $root = "/spider"; 
16         $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
17
18         unshift @INC, "$root/local";
19 }
20
21 use DXVars;
22 use DXUser;
23
24 sub delete_it
25 {
26         DXUser->del_file($userfn);
27 }
28
29 sub create_it
30 {
31         my $ref = DXUser->get(uc $mycall);
32         $ref->del() if $ref;
33         
34         my $self = DXUser->new(uc $mycall);
35         $self->{alias} = uc $myalias;
36         $self->{name} = $myname;
37         $self->{qth} = $myqth;
38         $self->{qra} = uc $mylocator;
39         $self->{lat} = $mylatitude;
40         $self->{long} = $mylongitude;
41         $self->{email} = $myemail;
42         $self->{bbsaddr} = $mybbsaddr;
43         $self->{homenode} = uc $mycall;
44         $self->{sort} = 'S';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
45         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
46         $self->{lastin} = 0;
47         $self->{dxok} = 1;
48         $self->{annok} = 1;
49
50         # write it away
51         $self->close();
52
53         # now do one for the alias
54         $ref = DXUser->get(uc $myalias);
55         $ref->del() if $ref;
56
57         $self = DXUser->new(uc $myalias);
58         $self->{name} = $myname;
59         $self->{qth} = $myqth;
60         $self->{qra} = uc $mylocator;
61         $self->{lat} = $mylatitude;
62         $self->{long} = $mylongitude;
63         $self->{email} = $myemail;
64         $self->{bbsaddr} = $mybbsaddr;
65         $self->{homenode} = uc $mycall;
66         $self->{sort} = 'U';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
67         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
68         $self->{lastin} = 0;
69         $self->{dxok} = 1;
70         $self->{annok} = 1;
71         $self->{lang} = 'en';
72         $self->{group} = [qw(local #9000)];
73   
74         # write it away
75         $self->close();
76
77 }
78
79 $lockfn = "$root/local/cluster.lck";       # lock file name
80 if (-e $lockfn) {
81         open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!";
82         my $pid = <CLLOCK>;
83         chomp $pid;
84         die "Sorry, Lockfile ($lockfn) and process $pid exist, a cluster is running\n" if kill 0, $pid;
85         close CLLOCK;
86 }
87
88 $DXUser::v3 = 1;
89
90 if (-e "$userfn.v2" || -e "$userfn.v3") {
91         print "Do you wish to destroy your user database (THINK!!!) [y/N]: ";
92         $ans = <STDIN>;
93         if ($ans =~ /^[Yy]/) {
94                 delete_it();
95                 DXUser->init($userfn, 1);
96                 create_it();
97         } else {
98                 print "Do you wish to reset your cluster and sysop information? [y/N]: ";
99                 $ans = <STDIN>;
100                 if ($ans =~ /^[Yy]/) {
101                         DXUser->init($userfn, 1);
102                         create_it();
103                 }
104         }
105   
106 } else {
107         DXUser->init($userfn, 1);
108         create_it();
109 }
110 DXUser->finish();
111 exit(0);
112