]> dxcluster.net Git - spider.git/blob - perl/create_sysop.pl
fix xmlout
[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 # $Id$
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         sub main::mkver {}
20 }
21
22 use DXVars;
23 use DXUser;
24
25 sub delete_it
26 {
27         DXUser->del_file($userfn);
28 }
29
30 sub create_it
31 {
32         my $ref = DXUser->get(uc $mycall);
33         $ref->del() if $ref;
34         
35         my $self = DXUser->new(uc $mycall);
36         $self->{alias} = uc $myalias;
37         $self->{name} = $myname;
38         $self->{qth} = $myqth;
39         $self->{qra} = uc $mylocator;
40         $self->{lat} = $mylatitude;
41         $self->{long} = $mylongitude;
42         $self->{email} = $myemail;
43         $self->{bbsaddr} = $mybbsaddr;
44         $self->{homenode} = uc $mycall;
45         $self->{sort} = 'S';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
46         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
47         $self->{lastin} = 0;
48         $self->{dxok} = 1;
49         $self->{annok} = 1;
50
51         # write it away
52         $self->close();
53
54         # now do one for the alias
55         $ref = DXUser->get(uc $myalias);
56         $ref->del() if $ref;
57
58         $self = DXUser->new(uc $myalias);
59         $self->{name} = $myname;
60         $self->{qth} = $myqth;
61         $self->{qra} = uc $mylocator;
62         $self->{lat} = $mylatitude;
63         $self->{long} = $mylongitude;
64         $self->{email} = $myemail;
65         $self->{bbsaddr} = $mybbsaddr;
66         $self->{homenode} = uc $mycall;
67         $self->{sort} = 'U';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
68         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
69         $self->{lastin} = 0;
70         $self->{dxok} = 1;
71         $self->{annok} = 1;
72         $self->{lang} = 'en';
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 if (-e "$userfn") {
89         print "Do you wish to destroy your user database (THINK!!!) [y/N]: ";
90         $ans = <STDIN>;
91         if ($ans =~ /^[Yy]/) {
92                 delete_it();
93                 DXUser->init($userfn, 1);
94                 create_it();
95         } else {
96                 print "Do you wish to reset your cluster and sysop information? [y/N]: ";
97                 $ans = <STDIN>;
98                 if ($ans =~ /^[Yy]/) {
99                         DXUser->init($userfn, 1);
100                         create_it();
101                 }
102         }
103   
104 } else {
105         DXUser->init($userfn, 1);
106         create_it();
107 }
108 DXUser->finish();
109 exit(0);
110