luci-app-acme: show button "Install package acme-acmesh-dnsapi" if DNS mode is used
authorSergey Ponomarev <[email protected]>
Sat, 1 Jun 2024 16:45:57 +0000 (19:45 +0300)
committerToke Høiland-Jørgensen <[email protected]>
Tue, 7 Oct 2025 12:01:06 +0000 (14:01 +0200)
Signed-off-by: Sergey Ponomarev <[email protected]>
applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js

index 07cac56416feab244ebe833f2606f1727b4a2169..937a931269013a6ce081b5ed69284803c346731e 100644 (file)
@@ -18,6 +18,7 @@ return view.extend({
                                return certs;
                        }),
                        L.resolveDefault(fs.exec_direct('/usr/libexec/acmesh-dnsinfo.sh'), ''),
+                       L.resolveDefault(fs.stat('/usr/lib/acme/client/dnsapi'), null),
                ]);
        },
 
@@ -25,7 +26,7 @@ return view.extend({
                let certs = data[0];
                let dnsApiInfoText = data[1];
                let apiInfos = dnsapi.parseFile(dnsApiInfoText);
-
+               let hasDnsApi = data[2] != null;
                let wikiUrl = 'https://github.com/acmesh-official/acme.sh/wiki/';
                let wikiInstructionUrl = wikiUrl + 'dnsapi';
                let m, s, o;
@@ -78,6 +79,19 @@ return view.extend({
                o.value('dns', _('DNS'));
                o.default = 'standalone';
 
+               if (!hasDnsApi) {
+                       let dnsApiPkg = 'acme-acmesh-dnsapi';
+                       o = s.taboption('general', form.Button, '_install');
+                       o.depends('validation_method', 'dns');
+                       o.title = _('Package is not installed');
+                       o.inputtitle = _('Install package %s').format(dnsApiPkg);
+                       o.inputstyle = 'apply';
+                       o.onclick = function () {
+                               let link = L.url('admin/system/package-manager') + '?query=' + dnsApiPkg;
+                               window.open(link, '_blank', 'noopener');
+                       };
+               }
+
                o = s.taboption('general', form.DynamicList, "domains", _("Domain names"),
                        _("Domain names to include in the certificate. " +
                                "The first name will be the subject name, subsequent names will be alt names. " +