Skip to content

Commit

Permalink
mxmirror: Remove redundant whitespace
Browse files Browse the repository at this point in the history
Remove dangling whitespace and repeated blank lines.
  • Loading branch information
donald committed May 13, 2019
1 parent 60747d6 commit d44cf4b
Showing 1 changed file with 11 additions and 43 deletions.
54 changes: 11 additions & 43 deletions mxmirror/mxmirror
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Socket;
use Sys::Hostname;
use Getopt::Long;

use Date::Calc;

use strict;
Expand All @@ -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;
Expand Down Expand Up @@ -52,35 +50,32 @@ if($opt{help}) {
print <<"EOF";
$0 [options] [action]
actions:
<default> 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=<fmt> define output format
--execute execute <fmt> if <cmd> is not specified
--command=<cmd> execute <cmd> for every host listed
--config=<file> read mirror-definitions from <file>
--jbodmap=<map> read amd-map for jbods from <map>
EOF
exit 0;
}



if(defined $opt{destinationhosts}) {
exit print_and_exec_hostlist(mirrors_reverse($mirrors));
}
Expand All @@ -93,8 +88,6 @@ if(defined $opt{all}) {
exit print_and_exec_all($mirrors);
}



if(defined $opt{check}) {
my $host = $opt{check} || $hostname;

Expand Down Expand Up @@ -146,10 +139,8 @@ foreach(@{$mirrors->{$hostname}}) {
}
}


exit($err);


###################################################################

sub print_and_exec_all {
Expand 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;
}
Expand All @@ -180,7 +171,6 @@ sub print_and_exec_all {

my @hosts = sort keys %{$list};


foreach my $h (@hosts) {
my %vars = (
);
Expand All @@ -198,8 +188,6 @@ sub print_and_exec_all {
return 0;
}



sub print_and_exec_hostlist {
my $list = shift;

Expand Down Expand Up @@ -232,7 +220,6 @@ sub print_and_exec_hostlist {
return 0;
}


sub mirrors_reverse {
my $mirrors = shift;

Expand All @@ -247,7 +234,6 @@ sub mirrors_reverse {
return $r;
}


sub get_mirror_status {
my $mirror = shift;

Expand All @@ -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';
Expand Down Expand Up @@ -307,8 +290,6 @@ sub do_format {
return $fmt;
}



sub to_jbod_path {
my $host = shift;
my $jbod = shift;
Expand Down Expand Up @@ -343,8 +324,6 @@ sub to_amd_path {
# isempty(<p2>): <host2>:<path2>
#



# from := <jbod1><path1>
# /jbod/<jbod1><path1>

Expand Down Expand Up @@ -389,8 +368,6 @@ sub convert_to_sourcepath {
path => $path,
hostpath => $path });



}
return;
}
Expand Down Expand Up @@ -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}";
Expand All @@ -485,8 +461,6 @@ sub convert_to_destinationpath {

}



return;
}

Expand All @@ -503,8 +477,6 @@ sub read_mirrormap {

open(F, '<', $file) or die "can't open $file: $?";



foreach(<F>) {
s/^\s+//;
s/\s+$//;
Expand All @@ -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 {
Expand All @@ -545,8 +515,6 @@ sub read_mirrormap {
return $map;
}
sub read_jbodmap {
my $file = shift;
Expand Down

0 comments on commit d44cf4b

Please sign in to comment.