diff options
author | Daniel Nilsson <dannil+github@protonmail.com> | 2024-10-08 20:12:28 +0200 |
---|---|---|
committer | Paul Donald <newtwen+github@gmail.com> | 2024-10-17 19:10:17 +0200 |
commit | 5c6b08cf89f5dd4dd0bc0ee4d0c643a19a34c9b8 (patch) | |
tree | 221be4b639b5a23ff2629580683698428efdd191 /applications/luci-app-squid/root/usr | |
parent | ade3606800a321e82082b2b7d6ba991e70ac996c (diff) |
luci-app-squid: convert to JavaScript
The conversion adds the missing parameters in the UI which is
configurable in the principal package.
Assumption has been made that the config file is stored in /etc/squid
since the principal package limits the sysconfdir to this directory. If
that assumption is changed in the future we need to adjust the ACL.
Signed-off-by: Daniel Nilsson <dannil+github@protonmail.com>
Diffstat (limited to 'applications/luci-app-squid/root/usr')
3 files changed, 50 insertions, 3 deletions
diff --git a/applications/luci-app-squid/root/usr/libexec/rpcd/luci.squid b/applications/luci-app-squid/root/usr/libexec/rpcd/luci.squid new file mode 100644 index 0000000000..040591ff4b --- /dev/null +++ b/applications/luci-app-squid/root/usr/libexec/rpcd/luci.squid @@ -0,0 +1,39 @@ +#!/bin/sh + +# Reference: https://openwrt.org/docs/techref/rpcd + +. /usr/share/libubox/jshn.sh + +get_compile_time_options() { + # Extract all options that begins with '--' as a comma-separated string + source="$(squid -v)" + options="$(echo $source | grep -o "'--[^']*'" | sed "s/'//g")" + + json_init + json_add_array 'options' + # For each option, add it to the array + set -- $options + for option; do + json_add_string '' "$option" + done + json_close_array + json_dump + json_cleanup +} + +case "$1" in + list) + json_init + json_add_object 'getCompileTimeOptions' + json_close_object + json_dump + json_cleanup + ;; + call) + case "$2" in + getCompileTimeOptions) + get_compile_time_options + ;; + esac + ;; +esac diff --git a/applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json b/applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json index 15a0d3c4d4..0f1da9554f 100644 --- a/applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json +++ b/applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json @@ -2,9 +2,8 @@ "admin/services/squid": { "title": "Squid", "action": { - "type": "cbi", - "path": "squid", - "post": { "cbi.submit": true } + "type": "view", + "path": "squid" }, "depends": { "acl": [ "luci-app-squid" ] diff --git a/applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json b/applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json index 91f8b5b348..c5fd5c5867 100644 --- a/applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json +++ b/applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json @@ -2,9 +2,18 @@ "luci-app-squid": { "description": "Grant UCI access for luci-app-squid", "read": { + "file": { + "/etc/squid/*": [ "read" ] + }, + "ubus": { + "luci.squid": [ "getCompileTimeOptions" ] + }, "uci": [ "squid" ] }, "write": { + "file": { + "/etc/squid/*": [ "write" ] + }, "uci": [ "squid" ] } } |