From b9621559c31e51a191982514026fe1d749043e8a Mon Sep 17 00:00:00 2001 From: remittor Date: Tue, 14 Jan 2025 09:14:14 +0300 Subject: [PATCH] luci: Add support custom.d scripts --- .../resources/view/zapret/settings.js | 17 +++++++++++++++++ .../luci-static/resources/view/zapret/tools.js | 4 ++++ .../usr/share/rpcd/acl.d/luci-app-zapret.json | 4 +++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js index 522e4c7..e65fce4 100644 --- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js +++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js @@ -320,6 +320,23 @@ return view.extend({ o.onclick = () => new tools.fileEditDialog(fn, name, '', '', 15).show(); } + /* custom.d files */ + + tabname = 'custom_d_tab'; + s.tab(tabname, 'custom.d'); + + for (let i = 0; i < tools.customdPrefixList.length; i++) { + let num = tools.customdPrefixList[i]; + let fn = tools.customdFileFormat.format(num.toString()); + let name = _('custom.d script #' + num); + o = s.taboption(tabname, form.Button, '_customd_file%d_btn'.format(num), name); + o.inputtitle = _('Edit'); + o.inputstyle = 'edit btn'; + o.description = fn; + let desc = (num == tools.discord_num) ? _('Example') + ': %s'.format(tools.discord_url) : ''; + o.onclick = () => new tools.fileEditDialog(fn, name, desc, '', 15).show(); + } + let map_promise = m.render(); map_promise.then(node => node.classList.add('fade-in')); return map_promise; diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js index 274baee..e9927ff 100644 --- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js +++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js @@ -49,6 +49,10 @@ return baseclass.extend({ iplstUserExcludeFN: '/opt/zapret/ipset/zapret-ip-user-exclude.txt', custFileMax : 4, custFileTemplate : '/opt/zapret/ipset/cust%s.txt', + customdPrefixList : [ 10, 20, 50, 60, 90 ] , + customdFileFormat : '/opt/zapret/init.d/openwrt/custom.d/%s-script.sh', + discord_num : 50, + discord_url : 'https://github.com/bol-van/zapret/blob/master/init.d/custom.d.examples.linux/50-discord', autoHostListFN : '/opt/zapret/ipset/zapret-hosts-auto.txt', autoHostListDbgFN : '/opt/zapret/ipset/zapret-hosts-auto-debug.log', diff --git a/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json b/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json index 18e9617..7243e57 100644 --- a/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json +++ b/luci-app-zapret/root/usr/share/rpcd/acl.d/luci-app-zapret.json @@ -8,6 +8,7 @@ "/opt/zapret/ipset/*": [ "read" ], "/etc/crontabs/root": [ "read" ], "/etc/init.d/zapret*": [ "exec" ], + "/bin/ps*": [ "exec" ], "/bin/busybox*": [ "exec" ], "/bin/opkg*": [ "exec" ], "/usr/bin/apk*": [ "exec" ], @@ -22,7 +23,8 @@ "write": { "file": { "/opt/zapret/config": [ "write" ], - "/opt/zapret/ipset/*.txt": [ "write" ], + "/opt/zapret/ipset/*": [ "write" ], + "/opt/zapret/init.d/openwrt/custom.d/*": [ "write" ], "/etc/crontabs/root": [ "write" ] }, "uci": [ "zapret" ]