38 lines
1.2 KiB
Plaintext

{
use strict;
use warnings;
use esmith::ConfigDB;
my $configDB = esmith::ConfigDB->open_ro or die("can't open Config DB");
my $ipsecDB = esmith::ConfigDB->open_ro('ipsec_connections') or die("cant connect to ipsec database");
my $ipsecDBkey = "ipsec";
my $xl2tpdDBkey = "xl2tpd";
my $ipsecprop = "L2TPD-PSK";
my $systemMode = $configDB->get("SystemMode")->value;
my $ExternalIP = $configDB->get_prop( "ExternalInterface", "IPAddress" );
if ( $systemMode ne 'servergateway' ) {
$OUT .= "# L2TPD - System not in Server Gateway mode\n";
}
elsif ( $configDB->get_prop( $ipsecDBkey, 'status' ) ne 'enabled' ) {
$OUT .= "# ipsec is disabled\n";
}
elsif ( $configDB->get_prop( $xl2tpdDBkey, 'status' ) ne 'enabled' ) {
$OUT .= "# xl2tpd is disabled\n";
}
elsif ( $ipsecDB->get_prop( $ipsecprop, 'status' ) ne 'enabled' ) {
$OUT .= "# l2tpd connection is disabled\n";
}
else {
my $right = $ipsecDB->get_prop( $ipsecprop, 'right' ) || '%any';
my $passwd = $ipsecDB->get_prop( $ipsecprop, 'passwd' ) || '';
$OUT .= "$ExternalIP $right \: PSK \"$passwd\"";
$OUT .= "\n";
}
}