blob: 9d0452a86d3e93555130929d2e0902580b1389ef (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/usr/bin/perl -w
use strict;
use Debian::DebConf::Client::ConfModule ':all';
&pptpd("/etc/pptpd.conf", get("pptpd/localip"), get("pptpd/remoteip"));
exit 0;
sub pptpd ($$$) {
my $line; # eine Zeile von IN
my $xxx;
my @lines;
my $count;
my $filename;
my $localIp;
my $remoteIp;
my $spaces;
my $foundlocal=0;
my $foundremote=0;
my $IDString="# generated by pptpdconfig";
$filename=shift;
$localIp=shift;
$remoteIp=shift;
print("Configuring pptpd to use localip(s) $localIp and remoteip(s) ");
print("$remoteIp ...\n");
open(IN, "<$filename") || die("$filename not found.\n");
@lines=<IN>;
open(OUT, ">${filename}.old");
print OUT @lines;
close OUT;
$count=0;
while ($count<=$#lines)
{
$line=$lines[$count];
if ($line=~/^\s*localip/) {
if ($line=~/$IDString/)
{
($spaces)=($line=~/^(\s*)\S*.*/);
$lines[$count]="${spaces}localip $localIp $IDString\n";
$foundlocal=1;
}
else
{
$lines[$count]="# removed by pptpdconfig --- ".$lines[$count]."\n";
}
}
if ($line=~/^\s*remoteip/) {
if ($line=~/$IDString/)
{
($spaces)=($line=~/^(\s*)\S*.*/);
$lines[$count]="${spaces}remoteip $remoteIp $IDString\n";
$foundremote=1;
}
else
{
$lines[$count]="# removed by pptpdconfig --- ".$lines[$count]."\n";
}
}
$count++;
}
if ($foundlocal==0)
{
push(@lines, "localip $localIp $IDString\n");
}
if ($foundremote==0)
{
push(@lines, "remoteip $remoteIp $IDString\n");
}
close IN;
print("done\n");
open(OUT, ">$filename");
print OUT @lines;
close OUT;
}
|