|
After implementing an LDAP naming service for Sunblade workstations using Sun One Directory server we needed to add support for linux client systems. The problem was that auto.home ldap maps for linux are not compatible with the auto_home maps that solaris uses and we didn't want to maintain 2 sets of maps so we decided to simply manage the maps locally on the clients by scripting the automatic building of the auto.home map by querying the ldap server for the automountinformation atribute for entries in auto_home. |
#!/usr/bin/perl -w
$LDAPSEARCH = "/usr/bin/ldapsearch -h ldapdev -LLL -x -b automountmapname=auto_home,dc=domain_central,dc=local" .
" automountkey=* automountinformation";
open(AM,">/etc/auto.master") or die "Open failed ($!)";
print AM "/home /etc/auto.home --timeout=60\n";
close(AM);
open(AH,">/etc/auto.home") or die "Open failed ($!)";
open(LDAPSEARCH,"$LDAPSEARCH|") or die "Open failed ($!)";
while ($line = ) {
if ($line =~ /^automountinformation/) {
chomp($line);
@line = split(/:/,$line);
@key = split(/\//,$line[2]);
$key = $key[$#key];
chomp($key);
$line[1] =~ s/-//g;
$line[1] = CleanString("$line[1]");
print AH "$key -fstype=nfs,$line[1]:$line[2]\n";
}
}
close(LDAPSEARCH);
close(AH);
sub CleanString {
my $Var = $_[0];
chomp($Var);
$Var =~ s/\s+$//;
$Var =~ s/^\s+//;
return $Var;
}
You are visitor number 1567