summaryrefslogtreecommitdiffstats
path: root/perl-install/network/nfs.pm
blob: 8429d1a69257e70dcf3e9f62b3a12707e0fed222 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package network::nfs;

use common;
use network::network;

sub check {
    my ($in) = @_;

    my $f = '/usr/sbin/showmount';
    -e $f or $in->do_pkgs->install('nfs-utils-clients');
    -e $f or $in->ask_warn('', "Mandatory package nfs-utils-clients is missing"), return;
    1;
}


sub find_servers() {
    local (*F, $_);
    my $pid = open F, "rpcinfo-flushed -b mountd 2 |";
    $SIG{ALRM} = sub { kill(15, $pid) };
    alarm 1;

    my $domain = chomp_(`domainname`);
    my @servers;
    while (<F>) {
	chomp;
	my ($ip, $name) = /(\S+)\s+(\S+)/ or log::l("bad line in rpcinfo output"), next;
	$name =~ s/\Q.$domain//; 
	$name =~ s/\.$//;
	push @servers, { ip => $ip, if_($name ne '(unknown)', name => $name) };
    }
    @servers;
}

sub find_exports {
    my ($server) = @_;

    my (undef, @l) = `showmount -e $server->{ip}`;
    map { /(\S+)\s*(\S+)/; { name => $1, comment => $2 } } @l;
}

1;