Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1 from wwwutz/master
migrated from NIS to hostconfig
  • Loading branch information
wwwutz committed Jun 13, 2016
2 parents 147b4ca + 3e163e5 commit 6666017
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions mxstartup2mxconfig
Expand Up @@ -248,27 +248,10 @@ sub print_ips_cfg {

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

sub walknetgroup {
my @ng;

&y(\@ng,@_);

sub y {
my ($ary,$m)=@_;
$_=`ypmatch $m netgroup 2>/dev/null`;
foreach ( split ) {
if (/\(/) {
s/[\(\),]//g;
push @$ary, $_;
} else {
foreach ( split ) {
&y($ary,$_);
}
}
}
}

return @ng;
sub hostconfig_list {
my $tag = shift;
$_=`/usr/sbin/hostconfig --list $tag 2>/dev/null`;
return ( split );
}


Expand All @@ -279,8 +262,9 @@ sub expand_hosts {

foreach my $host (@oh) {
if($host =~ /^\@(\S+)/) {
push @hosts, walknetgroup($1);
} elsif($host =~ /^(\/\S+)/) {
push @hosts, hostconfig_list($1);
}
elsif ($host =~ /^(\/\S+)/) {
next unless(-r $1);
push @hosts, expand_hosts(read_file($1));
} else {
Expand Down

0 comments on commit 6666017

Please sign in to comment.