summaryrefslogtreecommitdiffstats
path: root/nfs_wizard/scripts/NFSConf.pm
blob: 10387805e40c4b78c46f04b115755101d77046b8 (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
#! /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 {
    $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";
    }
    my $t;
    foreach (cat_($file)) {
	if (/^(?!\#).*$ENV{wiz_nfs_dir}\s.*/) {
	    $t = $_;
	    last;
	}
    }
    substInFile { s|^(?!\#).*$ENV{wiz_nfs_dir}\s.*|\#$&|} $file;
    append_to_file($file, $line);
    system("/usr/sbin/exportfs -a");
    10;
}