bugfix: could not delete client connections from vpnc page

fixes AREDN->ticket:170

Change-Id: Ieacdfd3eebf288e6fc83dcade7903eb96419dff4
This commit is contained in:
Darryl Quinn 2016-06-16 16:07:42 -05:00
parent ae6688dc33
commit 39efd11beb
2 changed files with 38 additions and 0 deletions

View File

@ -178,6 +178,27 @@ sub uci_add_named_section()
return $rc;
}
sub uci_rename_named_section()
{
my ($config,$sname,$snewname)=@_;
my $cmd=sprintf('uci rename %s.%s=%s',$config,$sname,$snewname);
#uci rename vtun.server_2=server_1
my $res=`$cmd`;
my $rc=$?;
return $rc;
}
sub uci_delete_named_section()
{
my ($config,$sname,$stype)=@_;
system `touch /etc/config/$config` if (! -f "/etc/config/$config");
my $cmd=sprintf('uci delete "%s.%s"',$config,$sname);
#uci delete vtun.server_9
my $res=`$cmd`;
my $rc=$?;
return $rc;
}
### UCI Helpers --DELETE-- ###
sub uci_delete_option()

View File

@ -71,6 +71,23 @@ if($parms{button_reset})
$rc=&uci_commit("vtun");
}
#################
# HANDLE connection deletes
#################
for($i = 0; $i < 10; $i++)
{
$varname="conn${i}_del";
if($parms{$varname})
{
&uci_delete_named_section("vtun","server_${i}");
for($x = $i+1; $x < 10; $x++)
{
$y=$x-1;
&uci_rename_named_section("vtun","server_$x","server_${y}");
}
}
}
#################
# If RESET or FIRST TIME, load servers into parms
#################