diff options
Diffstat (limited to 'pptpd-1.3.3/debian/pptpdconfig.pl')
-rw-r--r-- | pptpd-1.3.3/debian/pptpdconfig.pl | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/pptpd-1.3.3/debian/pptpdconfig.pl b/pptpd-1.3.3/debian/pptpdconfig.pl new file mode 100644 index 00000000..9d0452a8 --- /dev/null +++ b/pptpd-1.3.3/debian/pptpdconfig.pl @@ -0,0 +1,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; +} |