summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-10-22 19:44:43 +0200
committerJo-Philipp Wich <jo@mein.io>2021-10-22 19:44:43 +0200
commit63034c36073bedf87db18d05d3fe8cca016c6490 (patch)
tree22b2cc0cff8ca98280d8992b4c7d8931b6168906 /modules/luci-base/htdocs
parent216767f420a92468b865a5ef301a1e94283dcb0e (diff)
luci-base: remove further related section types on deleting network
When removing a `config interface` section in `/etc/config/network`, drop related `rule` and `rule6` sections too, as well as related `dhcp` sections in `/etc/config/dhcp`. Ref: https://forum.openwrt.org/t/grooming-etc-config/109764/7 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/network.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js
index 17dd055e25..2a402bcd57 100644
--- a/modules/luci-base/htdocs/luci-static/resources/network.js
+++ b/modules/luci-base/htdocs/luci-static/resources/network.js
@@ -1005,9 +1005,10 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
*/
deleteNetwork: function(name) {
var requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {}),
+ loadDHCP = L.resolveDefault(uci.load('dhcp')),
network = this.instantiateNetwork(name);
- return Promise.all([ requireFirewall, initNetworkState() ]).then(function(res) {
+ return Promise.all([ requireFirewall, loadDHCP, initNetworkState() ]).then(function(res) {
var uciInterface = uci.get('network', name),
firewall = res[0];
@@ -1020,19 +1021,23 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
uci.remove('luci', s['.name']);
});
- uci.sections('network', 'alias', function(s) {
- if (s.interface == name)
- uci.remove('network', s['.name']);
- });
+ uci.sections('network', null, function(s) {
+ switch (s['.type']) {
+ case 'alias':
+ case 'route':
+ case 'route6':
+ if (s.interface == name)
+ uci.remove('network', s['.name']);
- uci.sections('network', 'route', function(s) {
- if (s.interface == name)
- uci.remove('network', s['.name']);
- });
+ break;
- uci.sections('network', 'route6', function(s) {
- if (s.interface == name)
- uci.remove('network', s['.name']);
+ case 'rule':
+ case 'rule6':
+ if (s.in == name || s.out == name)
+ uci.remove('network', s['.name']);
+
+ break;
+ }
});
uci.sections('wireless', 'wifi-iface', function(s) {
@@ -1044,6 +1049,11 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
uci.unset('wireless', s['.name'], 'network');
});
+ uci.sections('dhcp', 'dhcp', function(s) {
+ if (s.interface == name)
+ uci.remove('dhcp', s['.name']);
+ });
+
if (firewall)
return firewall.deleteNetwork(name).then(function() { return true });