Commit 6f19276d authored by Franco Fichtner's avatar Franco Fichtner

vpn: kill config dirs consistently

parent fc381754
...@@ -35,7 +35,7 @@ function vpn_configure() ...@@ -35,7 +35,7 @@ function vpn_configure()
return array( return array(
'vpn_pptpd_configure', 'vpn_pptpd_configure',
'vpn_pppoes_configure', 'vpn_pppoes_configure',
'vpn_l2tp_configure' 'vpn_l2tp_configure',
); );
} }
...@@ -111,6 +111,7 @@ function vpn_pptpd_configure() ...@@ -111,6 +111,7 @@ function vpn_pptpd_configure()
$pptpdcfg = $config['pptpd']; $pptpdcfg = $config['pptpd'];
killbypid('/var/run/pptp-vpn.pid', 'TERM', true); killbypid('/var/run/pptp-vpn.pid', 'TERM', true);
mwexec('rm -rf /var/etc/pptp-vpn');
if (!isset($pptpdcfg['mode']) || $pptpdcfg['mode'] == 'off') { if (!isset($pptpdcfg['mode']) || $pptpdcfg['mode'] == 'off') {
return 0; return 0;
...@@ -125,7 +126,6 @@ function vpn_pptpd_configure() ...@@ -125,7 +126,6 @@ function vpn_pptpd_configure()
return; return;
} }
mwexec('rm -rf /var/etc/pptp-vpn');
mkdir('/var/etc/pptp-vpn'); mkdir('/var/etc/pptp-vpn');
switch ($pptpdcfg['mode']) { switch ($pptpdcfg['mode']) {
...@@ -331,6 +331,7 @@ function vpn_pppoe_configure(&$pppoecfg) ...@@ -331,6 +331,7 @@ function vpn_pppoe_configure(&$pppoecfg)
$syscfg = $config['system']; $syscfg = $config['system'];
killbypid("/var/run/pppoe{$pppoecfg['pppoeid']}-vpn.pid", 'TERM', true); killbypid("/var/run/pppoe{$pppoecfg['pppoeid']}-vpn.pid", 'TERM', true);
mwexec("rm -rf /var/etc/pppoe{$pppoecfg['pppoeid']}-vpn");
if (!isset($pppoecfg['mode']) || $pppoecfg['mode'] == 'off') { if (!isset($pppoecfg['mode']) || $pppoecfg['mode'] == 'off') {
return 0; return 0;
...@@ -340,12 +341,10 @@ function vpn_pppoe_configure(&$pppoecfg) ...@@ -340,12 +341,10 @@ function vpn_pppoe_configure(&$pppoecfg)
echo gettext("Configuring PPPoE VPN service..."); echo gettext("Configuring PPPoE VPN service...");
} }
switch ($pppoecfg['mode']) { mkdir("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn");
switch ($pppoecfg['mode']) {
case 'server': case 'server':
/* create directory if it does not exist */
@mkdir("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn");
$pppoe_interface = get_real_interface($pppoecfg['interface']); $pppoe_interface = get_real_interface($pppoecfg['interface']);
if ($pppoecfg['paporchap'] == "chap") { if ($pppoecfg['paporchap'] == "chap") {
...@@ -354,7 +353,7 @@ function vpn_pppoe_configure(&$pppoecfg) ...@@ -354,7 +353,7 @@ function vpn_pppoe_configure(&$pppoecfg)
$paporchap = "set link enable pap"; $paporchap = "set link enable pap";
} }
/* write mpd.conf */ /* write mpd.conf */
$fd = fopen("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.conf", "w"); $fd = fopen("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.conf", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open mpd.conf in vpn_pppoe_configure().") . "\n"); printf(gettext("Error: cannot open mpd.conf in vpn_pppoe_configure().") . "\n");
...@@ -468,7 +467,7 @@ EOD; ...@@ -468,7 +467,7 @@ EOD;
fclose($fd); fclose($fd);
unset($mpdconf); unset($mpdconf);
/* write mpd.links */ /* write mpd.links */
$fd = fopen("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.links", "w"); $fd = fopen("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.links", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open mpd.links in vpn_pppoe_configure().") . "\n"); printf(gettext("Error: cannot open mpd.links in vpn_pppoe_configure().") . "\n");
...@@ -495,7 +494,7 @@ EOD; ...@@ -495,7 +494,7 @@ EOD;
unset($mpdlinks); unset($mpdlinks);
if ($pppoecfg['username']) { if ($pppoecfg['username']) {
/* write mpd.secret */ /* write mpd.secret */
$fd = fopen("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.secret", "w"); $fd = fopen("/var/etc/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.secret", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open mpd.secret in vpn_pppoe_configure().") . "\n"); printf(gettext("Error: cannot open mpd.secret in vpn_pppoe_configure().") . "\n");
...@@ -537,6 +536,7 @@ function vpn_l2tp_configure() ...@@ -537,6 +536,7 @@ function vpn_l2tp_configure()
global $config; global $config;
killbypid('/var/run/l2tp-vpn.pid', 'TERM', true); killbypid('/var/run/l2tp-vpn.pid', 'TERM', true);
mwexec('rm -rf /var/etc/l2tp-vpn');
$syscfg = $config['system']; $syscfg = $config['system'];
if (isset($config['l2tp'])) { if (isset($config['l2tp'])) {
...@@ -553,7 +553,7 @@ function vpn_l2tp_configure() ...@@ -553,7 +553,7 @@ function vpn_l2tp_configure()
echo gettext('Configuring L2TP VPN service...'); echo gettext('Configuring L2TP VPN service...');
} }
@mkdir('/var/etc/l2tp-vpn'); mkdir('/var/etc/l2tp-vpn');
switch (isset($l2tpcfg['mode'])?$l2tpcfg['mode']:null) { switch (isset($l2tpcfg['mode'])?$l2tpcfg['mode']:null) {
...@@ -564,7 +564,7 @@ function vpn_l2tp_configure() ...@@ -564,7 +564,7 @@ function vpn_l2tp_configure()
$paporchap = "set link enable pap"; $paporchap = "set link enable pap";
} }
/* write mpd.conf */ /* write mpd.conf */
$fd = fopen("/var/etc/l2tp-vpn/mpd.conf", "w"); $fd = fopen("/var/etc/l2tp-vpn/mpd.conf", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open mpd.conf in vpn_l2tp_configure().") . "\n"); printf(gettext("Error: cannot open mpd.conf in vpn_l2tp_configure().") . "\n");
...@@ -666,7 +666,7 @@ EOD; ...@@ -666,7 +666,7 @@ EOD;
fclose($fd); fclose($fd);
unset($mpdconf); unset($mpdconf);
/* write mpd.links */ /* write mpd.links */
$fd = fopen("/var/etc/l2tp-vpn/mpd.links", "w"); $fd = fopen("/var/etc/l2tp-vpn/mpd.links", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open mpd.links in vpn_l2tp_configure().") . "\n"); printf(gettext("Error: cannot open mpd.links in vpn_l2tp_configure().") . "\n");
...@@ -693,7 +693,7 @@ EOD; ...@@ -693,7 +693,7 @@ EOD;
fclose($fd); fclose($fd);
unset($mpdlinks); unset($mpdlinks);
/* write mpd.secret */ /* write mpd.secret */
$fd = fopen("/var/etc/l2tp-vpn/mpd.secret", "w"); $fd = fopen("/var/etc/l2tp-vpn/mpd.secret", "w");
if (!$fd) { if (!$fd) {
printf(gettext("Error: cannot open mpd.secret in vpn_l2tp_configure().") . "\n"); printf(gettext("Error: cannot open mpd.secret in vpn_l2tp_configure().") . "\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment