]> dxcluster.net Git - spider.git/blob - perl/create_sysop.pl
add CTY-2702 prefixes
[spider.git] / perl / create_sysop.pl
1 #!/usr/bin/env 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/perl"; # this IS the right way round!
19         unshift @INC, "$root/local";
20 }
21
22 use DXVars;
23 use SysVar;
24 use DXUser;
25 use DXUtil;
26
27 sub delete_it
28 {
29         DXUser::del_file();
30 }
31
32 sub create_it
33 {
34         my $ref = DXUser::get(uc $mycall);
35         $ref->del() if $ref;
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
56         # now do one for the alias
57         $ref = DXUser::get(uc $myalias);
58         $ref->del() if $ref;
59
60         $self = DXUser->new(uc $myalias);
61         $self->{name} = $myname;
62         $self->{qth} = $myqth;
63         $self->{qra} = uc $mylocator;
64         $self->{lat} = $mylatitude;
65         $self->{long} = $mylongitude;
66         $self->{email} = $myemail;
67         $self->{bbsaddr} = $mybbsaddr;
68         $self->{homenode} = uc $mycall;
69         $self->{sort} = 'U';            # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
70         $self->{priv} = 9;                      # 0 - 9 - with 9 being the highest
71         $self->{lastin} = 0;
72         $self->{dxok} = 1;
73         $self->{annok} = 1;
74         $self->{lang} = 'en';
75         $self->{group} = [qw(local #9000)];
76   
77         # write it away
78         $self->close();
79
80 }
81
82 die "\$myalias \& \$mycall are the same ($mycall)!, they must be different (hint: make \$mycall = '${mycall}-2';).\n" if $mycall eq $myalias;
83
84 $lockfn = "$main::local_data/cluster.lck";       # lock file name (now in local data)
85 if (-e $lockfn) {
86         open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!";
87         my $pid = <CLLOCK>;
88         chomp $pid;
89         die "Sorry, Lockfile ($lockfn) and process $pid exist, a cluster is running\n" if kill 0, $pid;
90         close CLLOCK;
91 }
92
93 $DXUser::v3 = 1;
94
95 if (-e "$userfn.v2" || -e "$userfn.v3") {
96         print "Do you wish to destroy your user database (THINK!!!) [y/N]: ";
97         $ans = <STDIN>;
98         if ($ans =~ /^[Yy]/) {
99                 delete_it();
100                 DXUser::init(1);
101                 create_it();
102         } else {
103                 print "Do you wish to reset your cluster and sysop information? [y/N]: ";
104                 $ans = <STDIN>;
105                 if ($ans =~ /^[Yy]/) {
106                         DXUser::init(1);
107                         create_it();
108                 }
109         }
110   
111 } else {
112         DXUser::init(1);
113         create_it();
114 }
115 DXUser::finish();
116 exit(0);
117