2 Einträge, 1 Seite |
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
#!/opt/perl/bin/perl
print "Hostname: ";
$host = <>;
chomp($host);
$path = '/var/opt/ignite/recovery/archives/';
$access = '-anon=2,access=';
$complete = "$path".$host." "."$access".$host;
$found_host = 0;
$found_host2 = 0;
$file = "/etc/exports";
open(EXPORTS, "$file")|| die "/etc/exports konnte nicht geoeffnet werden";
while(<EXPORTS>)
{
if(index($_, ":$host") > -1)
{
$found_host2 = 1;
}
elsif(index($_, "$path".$host." "."$access".$host) > -1)
{
$found_host = 1;
}
}
close(EXPORTS);
unless($found_host == 1)
{
open(EXPORTS, ">>$file")|| die "Konnte /etc/exports nicht oeffnen ";
print EXPORTS "$complete";
close(EXPORTS);
print "Host $host erfolgreich importert\n";
mkdir "$path$host";
}
unless($found_host2 == 1)
{
open FILE, $file;
my @lines = <FILE>;
map (chomp, @lines);
$lines[0] .= ":$host";
open FILE, ">$file";
print FILE join("\n", @lines);
close(FILE);
mkdir "$path$host";
}
else
{
print "Host $host bereits vorhanden\n";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
unless($found_host2 == 1)
{
open FILE, $file;
my @lines = <FILE>;
chomp(@lines);
my $search = $path.$host." ".$access.$host;
foreach(@lines){
$_ .= ":$host" if($_ =~ /$search/);
}
open FILE, ">$file";
print FILE join("\n", @lines);
close(FILE);
mkdir "$path$host";
}
2 Einträge, 1 Seite |