From: Dirk Koopman Date: Wed, 17 Aug 2016 15:24:01 +0000 (+0100) Subject: fix various issues X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=4f1c00b0c181d994b13bb9b0ff9ea03ee0cf120c;p=spider.git fix various issues 1. Make cluster.lck checking consistent and accurate. 2. Fix export_user actions to always put them in local_data. 3. Fix create_prefix.pl output file and input file searching. Basically this now looks for cty.dat and wpxloc.raw in local_data first and then falls backs to data. But puts the result in local_data unless the --system flag is set. --- diff --git a/cmd/export_users.pl b/cmd/export_users.pl index a7a2c6ec..753a48fa 100644 --- a/cmd/export_users.pl +++ b/cmd/export_users.pl @@ -4,7 +4,7 @@ # # my $self = shift; -my $line = shift || localdata("user_asc"); +my $line = shift || "user_asc"; return (1, $self->msg('e5')) unless $self->priv >= 9; my ($fn, $flag) = split /\s+/, $line; diff --git a/perl/DXUser.pm b/perl/DXUser.pm index dd31e6f6..60fc1afd 100644 --- a/perl/DXUser.pm +++ b/perl/DXUser.pm @@ -412,15 +412,17 @@ sub fields sub export { - my $fn = shift; + my $name = shift; my $basic_info_only = shift; + + my $fn = "$main::local_data/$name"; # save old ones - rename "$fn.oooo", "$fn.ooooo" if -e "$fn.oooo"; - rename "$fn.ooo", "$fn.oooo" if -e "$fn.ooo"; - rename "$fn.oo", "$fn.ooo" if -e "$fn.oo"; - rename "$fn.o", "$fn.oo" if -e "$fn.o"; - rename "$fn", "$fn.o" if -e "$fn"; + move "$fn.oooo", "$fn.ooooo" if -e "$fn.oooo"; + move "$fn.ooo", "$fn.oooo" if -e "$fn.ooo"; + move "$fn.oo", "$fn.ooo" if -e "$fn.oo"; + move "$fn.o", "$fn.oo" if -e "$fn.o"; + move "$fn", "$fn.o" if -e "$fn"; my $count = 0; my $err = 0; diff --git a/perl/cluster.pl b/perl/cluster.pl index 86785a97..d82dd2e7 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -43,7 +43,10 @@ BEGIN { my $pid = ; if ($pid) { chomp $pid; - die "Lockfile ($lockfn) and process $pid exist, another cluster running?" if kill 0, $pid; + if (kill 0, $pid) { + warn "Lockfile ($lockfn) and process $pid exist, another cluster running?\n"; + exit 1; + } } unlink $lockfn; close CLLOCK; @@ -56,6 +59,7 @@ BEGIN { $systime = time; } + use Mojo::IOLoop; use DXVars; diff --git a/perl/create_prefix.pl b/perl/create_prefix.pl index daf4a09e..60d7d2a1 100755 --- a/perl/create_prefix.pl +++ b/perl/create_prefix.pl @@ -20,6 +20,7 @@ BEGIN { unshift @INC, "$root/local"; } +use DXVars; use SysVar; use Data::Dumper; @@ -33,18 +34,22 @@ my %locn = (); # the inverse of the above my %pre = (); # the prefix hash my %pren = (); # the inverse -if (@ARGV && $ARVG[0] =~ /^--system$/) { +my $prefix; + +if (@ARGV && $ARGV[0] =~ /^--system$/) { $prefix = $main::data; shift; } else { - $prefix = $main:local_data; + $prefix = $main::local_data; } -# open the input file -my $ifn = $ARGV[0] if $ARGV[0]; +my $ifn; -$ifn = "$prefix/wpxloc.raw" if !$ifn; -open (IN, $ifn) or die "can't open $ifn ($!)"; +$ifn = "$prefix/wpxloc.raw"; +unless (open (IN, $ifn)) { + $ifn = "$main::data/wpxloc.raw"; + open(IN, $ifn) or die "can't open $ifn ($!)"; +} # first pass, find all the 'master' location records while () { @@ -104,10 +109,17 @@ close(IN); #print Data::Dumper->Dump([\%pre, \%locn], [qw(pre locn)]); # now open the cty.dat file if it is there +my $r; +$ifn = "$prefix/cty.dat"; +unless ($r = open (IN, $ifn)) { + $ifn = "$main::data/cty.dat"; + $r = open(IN, $ifn); +} + my @f; my @a; $line = 0; -if (open(IN, "$prefix/cty.dat")) { +if ($r) { my $state = 0; while () { $line++; diff --git a/perl/create_sysop.pl b/perl/create_sysop.pl index 6e7db09d..99f3e060 100755 --- a/perl/create_sysop.pl +++ b/perl/create_sysop.pl @@ -81,7 +81,7 @@ sub create_it die "\$myalias \& \$mycall are the same ($mycall)!, they must be different (hint: make \$mycall = '${mycall}-2';).\n" if $mycall eq $myalias; -$lockfn = localdata("cluster.lck"); # lock file name +$lockfn = "$main::local_data/cluster.lck"; # lock file name (now in local data) if (-e $lockfn) { open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!"; my $pid = ; diff --git a/perl/lock_nodes.pl b/perl/lock_nodes.pl index 3ab0e7d1..2443e48b 100755 --- a/perl/lock_nodes.pl +++ b/perl/lock_nodes.pl @@ -15,7 +15,7 @@ BEGIN { # root of directory tree for this system $root = "/spider"; $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'}; - unshift @INC, "$root/perl"; # this IS the right way round! + unshift @INC, "$root/perl"; # this IS the right way round! unshift @INC, "$root/local"; } @@ -23,7 +23,7 @@ use SysVar; use DXUser; use DXUtil; -my $lockfn = localdata("cluster.lck"); # lock file name +$lockfn = "$main::local_data/cluster.lck"; # lock file name (now in local d if (-e $lockfn) { open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!"; my $pid = ; diff --git a/perl/update_sysop.pl b/perl/update_sysop.pl index 613e91f0..168ee16a 100755 --- a/perl/update_sysop.pl +++ b/perl/update_sysop.pl @@ -87,7 +87,7 @@ sub create_it die "\$myalias \& \$mycall are the same ($mycall)!, they must be different (hint: make \$mycall = '${mycall}-2';).\n" if $mycall eq $myalias; -$lockfn = localdata("cluster.lck"); # lock file name +$lockfn = "$main::local_data/cluster.lck"; # lock file name (now in local d if (-e $lockfn) { open(CLLOCK, "$lockfn") or die "Can't open Lockfile ($lockfn) $!"; my $pid = ;