luci-mod-network: migrate network config depending on netifd version
authorRafał Miłecki <rafal@milecki.pl>
Wed, 26 May 2021 11:25:24 +0000 (13:25 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Wed, 26 May 2021 11:29:55 +0000 (13:29 +0200)
Checking netifd version is important for users of the most recent LuCI
that didn't update netifd (e.g. OpenWrt package).

Suggested-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js
modules/luci-mod-network/root/usr/share/rpcd/acl.d/luci-mod-network.json

index a1def24b0782b164d1f5816482d22457f21ab5c5..e3502c05287217b56cfe90307796f0ee3b18473c 100644 (file)
@@ -294,6 +294,7 @@ return view.extend({
                        network.getDSLModemType(),
                        network.getDevices(),
                        fs.lines('/etc/iproute2/rt_tables'),
+                       fs.read('/usr/lib/opkg/info/netifd.control'),
                        uci.changes()
                ]);
        },
@@ -354,8 +355,11 @@ return view.extend({
        },
 
        render: function(data) {
-               if (this.interfaceWithIfnameSections().length ||
-                   this.deviceWithIfnameSections().length)
+               var netifdVersion = (data[3] || '').match(/Version: ([^\n]+)/);
+
+               if (netifdVersion && netifdVersion[1] >= "2021-05-20" &&
+                   (this.interfaceWithIfnameSections().length ||
+                    this.deviceWithIfnameSections().length))
                        return this.renderMigration();
 
                var dslModemType = data[0],
index 5d7888f765245dbbd3607558f08d83d4e6c204b2..ade9915b9129543eab23707217cf210ccec935c7 100644 (file)
@@ -5,7 +5,8 @@
                        "cgi-io": [ "exec" ],
                        "file": {
                                "/etc/iproute2/rt_tables": [ "read" ],
-                               "/usr/libexec/luci-peeraddr": [ "exec" ]
+                               "/usr/libexec/luci-peeraddr": [ "exec" ],
+                               "/usr/lib/opkg/info/netifd.control": [ "read" ]
                        },
                        "ubus": {
                                "file": [ "exec" ],