summaryrefslogtreecommitdiffstats
path: root/nfs_wizard/scripts/NFSConf.pm
blob: 942380d911e0f2c49aee0e05658d68ad356e975d (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
#! /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	do_it {
    my $file = "/etc/exports";
    my $ip = "$1.$2.$3.0" if $o->get_from_known_dev("IP") =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
    my $mask = $o->get_from_known_dev("Mask");
    my $line = "$ENV{wiz_nfs_dir} $ip/$mask(rw,no_root_squash)\n";
    my $t;

    foreach (cat_($file)) {
	if (/^\s*(?!\#)\s*\$ENV{wiz_nfs_dir}.*/) {
	    $t = $_;
	    last;
	}
    }
    if ($t) { substInFile { s|$t|\#$&$line|} $file }
    else { append_to_file($file, $line) }
    system("/usr/sbin/exportfs -a")
}