summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/network/nfs.pm42
-rw-r--r--perl-install/network/smb.pm42
-rw-r--r--perl-install/network/smbnfs.pm50
3 files changed, 99 insertions, 35 deletions
diff --git a/perl-install/network/nfs.pm b/perl-install/network/nfs.pm
index 859e1e63d..6c9a02b6b 100644
--- a/perl-install/network/nfs.pm
+++ b/perl-install/network/nfs.pm
@@ -1,27 +1,34 @@
-package network::nfs;
+package network::nfs; # $Id$
+
+use strict;
+use diagnostics;
use common;
use network::network;
+use network::smbnfs;
use log;
-sub check {
- my ($in) = @_;
+our @ISA = 'network::smbnfs';
- my $pkg = 'nfs-utils-clients';
- my $f = '/usr/sbin/showmount';
- if (! -e $f) {
- $in->ask_okcancel('', _("The package %s needs to be installed. Do you want to install it?", $pkg), 1) or return;
- $in->do_pkgs->install($pkg);
- }
- if (! -e $f) {
- $in->ask_warn('', _("Mandatory package %s is missing", $pkg));
- return;
- }
- 1;
+sub to_fstab_entry {
+ my ($class, $e) = @_;
+ $class->to_fstab_entry_raw($e, 'nfs');
+}
+sub from_dev {
+ my ($class, $dev) = @_;
+ $dev =~ m|(.*?):(.*)|;
+}
+sub to_dev_raw {
+ my ($class, $server, $name) = @_;
+ $server . ':' . $name;
}
+sub check {
+ my ($class, $in) = @_;
+ $class->raw_check($in, 'nfs-utils-clients', '/usr/sbin/showmount');
+}
-sub find_servers() {
+sub find_servers {
local *F;
my $pid = open F, "rpcinfo-flushed -b mountd 2 |";
$SIG{ALRM} = sub { kill(15, $pid) };
@@ -40,7 +47,7 @@ sub find_servers() {
}
sub find_exports {
- my ($server) = @_;
+ my ($class, $server) = @_;
local *F;
my $s = $server->{ip} || $server->{name};
@@ -49,8 +56,7 @@ sub find_exports {
alarm 5;
my (undef, @l) = <F>;
- map { /(\S+)\s*(\S+)/; { name => $1, comment => $2 } } @l;
+ map { /(\S+)\s*(\S+)/; { name => $1, comment => $2, server => $server } } @l;
}
1;
-
diff --git a/perl-install/network/smb.pm b/perl-install/network/smb.pm
index 1e141fe48..0061f94b2 100644
--- a/perl-install/network/smb.pm
+++ b/perl-install/network/smb.pm
@@ -1,26 +1,34 @@
-package network::smb;
+package network::smb; # $Id$
+
+use strict;
+use diagnostics;
use common;
use network::network;
+use network::smbnfs;
-sub check {
- my ($in) = @_;
+our @ISA = 'network::smbnfs';
- my $pkg = 'samba-client';
- my $f = '/usr/bin/nmblookup';
- if (! -e $f) {
- $in->ask_okcancel('', _("The package %s needs to be installed. Do you want to install it?", $pkg), 1) or return;
- $in->do_pkgs->install($pkg);
- }
- if (! -e $f) {
- $in->ask_warn('', _("Mandatory package %s is missing", $pkg));
- return;
- }
- 1;
+sub to_fstab_entry {
+ my ($class, $e) = @_;
+ $class->to_fstab_entry_raw($e, 'nfs');
+}
+sub from_dev {
+ my ($class, $dev) = @_;
+ $dev =~ m|//(.*?)/(.*)|;
+}
+sub to_dev_raw {
+ my ($class, $server, $name) = @_;
+ '//' . $server . '/' . $name;
+}
+
+sub check {
+ my ($class, $in) = @_;
+ $class->raw_check($in, 'samba-client', '/usr/bin/nmblookup');
}
-sub find_servers() {
+sub find_servers {
my (undef, @l) = `nmblookup "*"`;
s/\s.*\n// foreach @l;
my @servers = grep { network::network::is_ip($_) } @l;
@@ -41,7 +49,7 @@ sub find_servers() {
}
sub find_exports {
- my ($server) = @_;
+ my ($class, $server) = @_;
my @l;
my $name = $server->{name} || $server->{ip};
my $ip = $server->{ip} ? "-I $server->{ip}" : '';
@@ -55,7 +63,7 @@ sub find_exports {
s/^\t//;
my ($name, $type, $comment) = unpack "A15 A10 A*", $_;
if ($name eq '---------' && $type eq '----' && $comment eq '-------' .. /^$/) {
- push @l, { name => $name, type => $type, comment => $comment }
+ push @l, { name => $name, type => $type, comment => $comment, server => $server }
if $type eq 'Disk' && $name !~ /\$$/;
}
}
diff --git a/perl-install/network/smbnfs.pm b/perl-install/network/smbnfs.pm
new file mode 100644
index 000000000..1958ce167
--- /dev/null
+++ b/perl-install/network/smbnfs.pm
@@ -0,0 +1,50 @@
+package network::smbnfs; # $Id$
+
+use strict;
+use diagnostics;
+
+
+sub new {
+ my ($class, $v) = @_;
+ bless($v || {}, $class);
+}
+
+sub server_to_string {
+ my ($class, $server) = @_;
+ $server->{name} || $server->{ip};
+}
+sub to_dev {
+ my ($class, $e) = @_;
+ $class->to_dev_raw($class->server_to_string($e->{server}), $e->{name} || $e->{ip});
+}
+sub to_string {
+ my ($class, $e) = @_;
+ ($e->{name} || $e->{ip}) . ($e->{comment} ? " ($e->{comment})" : '');
+}
+
+sub to_fullstring {
+ my ($class, $e) = @_;
+ $class->to_dev($e) . ($e->{comment} ? " ($e->{comment})" : '');
+}
+sub to_fstab_entry_raw {
+ my ($class, $e, $type) = @_;
+ my $fs_entry = { device => $class->to_dev($e), type => $type };
+ fs::set_default_options($fs_entry);
+ $fs_entry;
+}
+
+sub raw_check {
+ my ($class, $in, $pkg, $file) = @_;
+ if (! -e $file) {
+ $in->ask_okcancel('', _("The package %s needs to be installed. Do you want to install it?", $pkg), 1) or return;
+ $in->do_pkgs->install($pkg);
+ }
+ if (! -e $file) {
+ $in->ask_warn('', _("Mandatory package %s is missing", $pkg));
+ return;
+ }
+ 1;
+}
+
+1;
+