fixed create_sysop so that the it has the correct BEGIN sequence, which will
[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/perl";  # this IS the right way round!
19   unshift @INC, "$root/local";
20 }
21
22 use DXVars;
23 use DXUser;
24
25 sub create_it
26 {
27   system("rm -f $userfn*");
28   DXUser->init($userfn);
29   my $self = DXUser->new($mycall);
30   $self->{alias} = $myalias;
31   $self->{name} = $myname;
32   $self->{qth} = $myqth;
33   $self->{qra} = $mylocator;
34   $self->{lat} = $mylatitude;
35   $self->{long} = $mylongtitude;
36   $self->{email} = $myemail;
37   $self->{bbsaddr} = $mybbsaddr;
38   $self->{sort} = 'U';           # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
39   $self->{priv} = 9;             # 0 - 9 - with 9 being the highest
40   $self->{lastin} = 0;
41   $self->{dxok} = 1;
42   $self->{annok} = 1;
43
44   # write it away
45   $self->close();
46
47   # now do one for the alias
48   $self = DXUser->new($myalias);
49   $self->{name} = $myname;
50   $self->{qth} = $myqth;
51   $self->{qra} = $mylocator;
52   $self->{lat} = $mylatitude;
53   $self->{long} = $mylongtitude;
54   $self->{email} = $myemail;
55   $self->{bbsaddr} = $mybbsaddr;
56   $self->{sort} = 'U';           # C - Console user, S - Spider cluster, A - AK1A, U - User, B - BBS
57   $self->{priv} = 9;             # 0 - 9 - with 9 being the highest
58   $self->{lastin} = 0;
59   $self->{dxok} = 1;
60   $self->{annok} = 1;
61
62   # write it away
63   $self->close();
64
65   DXUser->finish();
66   print "New user database created as $userfn\n";
67 }
68
69 if (-e "$userfn") {
70   print "This program will destroy your user database!!!!\n\nDo you wish to continue [y/N]: ";
71   $ans = <STDIN>;
72   create_it() if ($ans =~ /^[Yy]/);
73 } else {
74   create_it();
75 }
76 exit(0);
77