diff --git a/mxmirror/mxmirror b/mxmirror/mxmirror index 75eb6e1..79a7750 100755 --- a/mxmirror/mxmirror +++ b/mxmirror/mxmirror @@ -3,7 +3,6 @@ use Socket; use Sys::Hostname; use Getopt::Long; - use Date::Calc; use strict; @@ -15,14 +14,13 @@ my $MIRRORMAP='/etc/mxmirrors'; my %CONFIG = ( CMD => 'STRING', ); - + my %opt = ( from => undef, to => undef, check => undef, verbose => 0, debug => 0, - ); my $fullhostname = hostname; @@ -52,35 +50,32 @@ if($opt{help}) { print <<"EOF"; $0 [options] [action] - + actions: - + print mirror-cmds to mirror local filesystems - + --sourcehosts list all hosts to mirror --destinationhosts list all mirror hosts - + --all list all defined mirrors - + --check check mirrorstatus of localhost - + options: - + --format= define output format --execute execute if is not specified - + --command= execute for every host listed --config= read mirror-definitions from --jbodmap= read amd-map for jbods from - - + EOF exit 0; } - - if(defined $opt{destinationhosts}) { exit print_and_exec_hostlist(mirrors_reverse($mirrors)); } @@ -93,8 +88,6 @@ if(defined $opt{all}) { exit print_and_exec_all($mirrors); } - - if(defined $opt{check}) { my $host = $opt{check} || $hostname; @@ -146,10 +139,8 @@ foreach(@{$mirrors->{$hostname}}) { } } - exit($err); - ################################################################### sub print_and_exec_all { @@ -158,7 +149,7 @@ sub print_and_exec_all { my $default_fmt = "SRCHOST:SRCPATH DSTHOST:DSTPATH ARGS"; my $fmt = (defined $opt{format})?$opt{format}:$default_fmt; my $cmd = $opt{command}; - + if(not defined $cmd and $opt{execute}) { $cmd = $fmt; } @@ -180,7 +171,6 @@ sub print_and_exec_all { my @hosts = sort keys %{$list}; - foreach my $h (@hosts) { my %vars = ( ); @@ -198,8 +188,6 @@ sub print_and_exec_all { return 0; } - - sub print_and_exec_hostlist { my $list = shift; @@ -232,7 +220,6 @@ sub print_and_exec_hostlist { return 0; } - sub mirrors_reverse { my $mirrors = shift; @@ -247,7 +234,6 @@ sub mirrors_reverse { return $r; } - sub get_mirror_status { my $mirror = shift; @@ -265,15 +251,12 @@ sub get_mirror_status { if($status eq 'OK') { my ($year,$month,$day, $hour,$min,$sec, $doy,$dow,$dst) = Date::Calc::Gmtime($days); - $days = Date::Calc::Delta_Days($year,$month,$day, Date::Calc::Today()); return $days; } - return $line; - } return 'UNKNOWN'; @@ -307,8 +290,6 @@ sub do_format { return $fmt; } - - sub to_jbod_path { my $host = shift; my $jbod = shift; @@ -343,8 +324,6 @@ sub to_amd_path { # isempty(): : # - - # from := # /jbod/ @@ -389,8 +368,6 @@ sub convert_to_sourcepath { path => $path, hostpath => $path }); - - } return; } @@ -460,7 +437,6 @@ sub convert_to_destinationpath { if(($host,$partition,$path) = $string =~ /^(.*?):(\d+)(.*?)$/) { - unless($path) { if(defined $source->{jbod}) { $path = "/mirror/$source->{jbod}$source->{path}"; @@ -485,8 +461,6 @@ sub convert_to_destinationpath { } - - return; } @@ -503,8 +477,6 @@ sub read_mirrormap { open(F, '<', $file) or die "can't open $file: $?"; - - foreach() { s/^\s+//; s/\s+$//; @@ -525,13 +497,11 @@ sub read_mirrormap { $source = convert_to_sourcepath($from); $destination = convert_to_destinationpath($to, $source); - unless($source and $destination) { print STDERR "**ERROR: CAN'T PARSE FROM/TO: $_\n"; next; } - push @{$map->{$source->{host}}}, {string => $string, source => $source, destination => $destination, args => $args}; } else { @@ -545,8 +515,6 @@ sub read_mirrormap { return $map; } - - sub read_jbodmap { my $file = shift;