summaryrefslogtreecommitdiffstats
path: root/nfs_wizard/scripts/NFSConf.pm
blob: 673f571a5e7e8b1984f30111b9aaa117dc5898c1 (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
43
44
45
46
47
48
49
#! /usr/bin/perl -w

package NFSConf;
require "__WIZ_HOME__/common/scripts/Vareqval.pm";
require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm";
use MDK::Common;
use strict;

my $o = DrakconnectConf->new();

sub	network_mask {
    my $wiz_ip_server = $o->get_from_known_dev("IP");
    my $mask = $o->get_from_known_dev("Mask");
    $mask = $mask ? $mask : "255.255.255.0";
    $wiz_ip_server = $wiz_ip_server ? $wiz_ip_server : "192.168.1.0";
    "$1.$2.$3.0/$mask" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
}

sub	chooser {
    if ($ENV{wiz_nfs_level} == 1) {
	do_it();
    }
    $ENV{wiz_nfs_level};
}

sub	do_it {
    my $line;
    my $file = "/etc/exports";
    chomp($ENV{wiz_nfs_dir});
    -f $file and cp_af($file, $file.".orig");
    if ($ENV{wiz_nfs_level} == 2) {
	my $mask = $o->get_from_known_dev("Mask");
	$line = "$ENV{wiz_nfs_dir} $ENV{wiz_netmask}(rw,no_root_squash)\n";
    }
    else {
	$line = "$ENV{wiz_nfs_dir} *(rw,no_root_squash)\n";
    }
    print "$line\n";
    my $t;
    foreach (cat_($file)) {
	if (/.*(?!\#).*$ENV{wiz_nfs_dir}\s.*/) {
	    $t = $_;
	    last;
	}
    }
    if ($t) {substInFile { s|.*(?!\#).*$ENV{wiz_nfs_dir}\s.*|\#$&|} $file }
    append_to_file($file, $line);
    system("/usr/sbin/exportfs -a")
}