From bb17672ed8badbc6162fe0ea4e0d165bc02f4464 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 22 Feb 2024 08:36:58 +0100 Subject: [PATCH] wizard: further tweaking for #7263 --- src/wizard/system.xml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/wizard/system.xml b/src/wizard/system.xml index ef7fa2f2f..5a8704838 100644 --- a/src/wizard/system.xml +++ b/src/wizard/system.xml @@ -602,21 +602,22 @@ if (!empty($input_errors)) { gatewayIterator() as $gw) { if (!empty($gw['defaultgw'])) { $defaultgw_found = true; } + if ($gw['name'] == 'WAN_GW' && !empty($gw['uuid'])) { - $found = true; $gateways->createOrUpdateGateway(['gateway' => $config['wizardtemp']['wangateway']], $gw['uuid']); - $config['interfaces']['wan']['gateway'] = $gw['name']; + $found = true; } } + if (!$found) { - $newgw = [ + $gateways->createOrUpdateGateway([ 'interface' => 'wan', 'gateway' => $config['wizardtemp']['wangateway'], 'name' => 'WAN_GW', @@ -624,15 +625,17 @@ if (!$found) { 'monitor_disable' => 1, 'descr' => "WAN Gateway", 'defaultgw' => !$defaultgw_found, - ]; - - $gateways->createOrUpdateGateway($newgw); + ]); } +/* Assignments to $config only after this went through! */ $config = OPNsense\Core\Config::getInstance()->toArray(listtags()); $config['system']['hostname'] = $config['wizardtemp']['system']['hostname']; $config['system']['domain'] = $config['wizardtemp']['system']['domain']; +if ($found) { + $config['interfaces']['wan']['gateway'] = 'WAN_GW'; +} unset($config['wizardtemp']); write_config();