fix messages in DXDb.pm to point to the correct ones. Thanks Rene (oz1lqh)
[spider.git] / perl / cluster.pl
index 169900cc1afc5f674299d373244dafed42eba6f2..b33a8b6e0cf81a14832e424182b70a8d2b2453f0 100755 (executable)
@@ -23,6 +23,14 @@ BEGIN {
        unshift @INC, "$root/perl";     # this IS the right way round!
        unshift @INC, "$root/local";
 
+       # do some validation of the input
+       die "The directory $root doesn't exist, please RTFM" unless -d $root;
+       die "$root/local doesn't exist, please RTFM" unless -d "$root/local";
+       die "$root/local/DXVars.pm doesn't exist, please RTFM" unless -e "$root/local/DXVars.pm";
+       
+       mkdir "$root/local_cmd", 0777 unless -d "$root/local_cmd";
+       
+
        # try to create and lock a lockfile (this isn't atomic but 
        # should do for now
        $lockfn = "$root/perl/cluster.lck";       # lock file name
@@ -86,6 +94,7 @@ use Timer;
 use Route;
 use Route::Node;
 use Route::User;
+use Editable;
 
 use Data::Dumper;
 use IO::File;
@@ -99,20 +108,21 @@ package main;
 use strict;
 use vars qw(@inqueue $systime $version $starttime $lockfn @outstanding_connects 
                        $zombies $root @listeners $lang $myalias @debug $userfn $clusteraddr 
-                       $clusterport $mycall $decease $is_win $routeroot $me
+                       $clusterport $mycall $decease $is_win $routeroot $me $reqreg
                   );
 
 @inqueue = ();                                 # the main input queue, an array of hashes
 $systime = 0;                                  # the time now (in seconds)
-$version = "1.48";                             # the version no of the software
+$version = "1.50";                             # the version no of the software
 $starttime = 0;                 # the starting time of the cluster   
 #@outstanding_connects = ();     # list of outstanding connects
 @listeners = ();                               # list of listeners
+$reqreg = 0;                                   # 1 = registration required, 2 = deregister people
 
 use vars qw($VERSION $BRANCH $build $branch);
 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
-$main::build += 13;                            # add an offset to make it bigger than last system
+$main::build += 12;                            # add an offset to make it bigger than last system
 $main::build += $VERSION;
 $main::branch += $BRANCH;
 
@@ -291,7 +301,7 @@ sub process_inqueue
        while (@inqueue) {
                my $self = shift @inqueue;
                return if !$self;
-       
+
                my $data = $self->{data};
                my $dxchan = $self->{dxchan};
                my $error;
@@ -300,16 +310,20 @@ sub process_inqueue
        
                # do the really sexy console interface bit! (Who is going to do the TK interface then?)
                dbg("<- $sort $call $line\n") if $sort ne 'D' && isdbg('chan');
-
+               if ($self->{disconnecting}) {
+                       dbg('In disconnection, ignored');
+                       next;
+               }
+               
                # handle A records
                my $user = $dxchan->user;
                if ($sort eq 'A' || $sort eq 'O') {
                        $dxchan->start($line, $sort);  
                } elsif ($sort eq 'I') {
                        die "\$user not defined for $call" if !defined $user;
+
                        # normal input
                        $dxchan->normal($line);
-                       $dxchan->disconnect if ($dxchan->{state} eq 'bye');
                } elsif ($sort eq 'Z') {
                        $dxchan->disconnect;
                } elsif ($sort eq 'D') {
@@ -361,7 +375,7 @@ $build = "$build.$branch" if $branch;
 Log('cluster', "DXSpider V$version, build $build started");
 
 # banner
-dbg("Copyright (c) 1998-2001 Dirk Koopman G1TLH");
+dbg("Copyright (c) 1998-2002 Dirk Koopman G1TLH");
 dbg("DXSpider Version $version, build $build started");
 
 # load Prefixes
@@ -376,6 +390,14 @@ Bands::load();
 dbg("loading user file system ..."); 
 DXUser->init($userfn, 1);
 
+# look for the sysop and the alias user and complain if they aren't there
+{
+       my $ref = DXUser->get($mycall);
+       die "$mycall missing, run the create_sysop.pl script and please RTFM" unless $ref && $ref->priv == 9;
+       $ref = DXUser->get($myalias);
+       die "$myalias missing, run the create_sysop.pl script and please RTFM" unless $ref && $ref->priv == 9;
+}
+
 # start listening for incoming messages/connects
 dbg("starting listeners ...");
 my $conn = IntMsg->new_server($clusteraddr, $clusterport, \&login);
@@ -465,12 +487,6 @@ eval {
 };
 dbg("Local::init error $@") if $@;
 
-dbg("cleaning out old debug files");
-DXDebug::dbgclean();
-
-# print various flags
-#dbg("seful info - \$^D: $^D \$^W: $^W \$^S: $^S \$^P: $^P");
-
 # this, such as it is, is the main loop!
 dbg("orft we jolly well go ...");
 my $script = new Script "startup";