diff options
author | Remy D. Farley <one-d-wide@protonmail.com> | 2024-01-07 11:50:55 +0000 |
---|---|---|
committer | Paul Donald <itsascambutmailmeanyway+github@gmail.com> | 2024-04-03 18:33:05 +0200 |
commit | f5ccfd3df4453ac44b271fd4743bf96a1b0a1199 (patch) | |
tree | bf9c18b877014b8c641c411088a030cafc3349b7 /protocols/luci-proto-yggdrasil/root | |
parent | 723507231566b61750e32284b49acdae0d0162d3 (diff) |
luci-proto-yggdrasil: add `yggdrasil-jumper` support
Signed-off-by: Remy D. Farley <one-d-wide@protonmail.com>
Diffstat (limited to 'protocols/luci-proto-yggdrasil/root')
-rwxr-xr-x | protocols/luci-proto-yggdrasil/root/usr/libexec/rpcd/luci.yggdrasil-jumper | 44 | ||||
-rw-r--r-- | protocols/luci-proto-yggdrasil/root/usr/share/rpcd/acl.d/luci-proto-yggdrasil.json | 3 |
2 files changed, 46 insertions, 1 deletions
diff --git a/protocols/luci-proto-yggdrasil/root/usr/libexec/rpcd/luci.yggdrasil-jumper b/protocols/luci-proto-yggdrasil/root/usr/libexec/rpcd/luci.yggdrasil-jumper new file mode 100755 index 0000000000..62c35b0e28 --- /dev/null +++ b/protocols/luci-proto-yggdrasil/root/usr/libexec/rpcd/luci.yggdrasil-jumper @@ -0,0 +1,44 @@ +#!/bin/sh + +. /usr/share/libubox/jshn.sh + +isInstalled() { + [ -f /usr/sbin/yggdrasil-jumper ] +} + +case "$1" in + list) + json_init + json_add_object "isInstalled" + json_close_object + json_add_object "validateConfig" + json_add_string "config" + json_close_object + json_dump + ;; + call) + case "$2" in + isInstalled) + json_init + json_add_boolean "isInstalled" "$(isInstalled && echo 1 || echo 0)" + json_dump + ;; + validateConfig) + read -r input + json_load "$input" + json_get_vars config + + output="Can't locate `yggdrasil-jumper`" + isInstalled && \ + output="$(echo "$config" \ + | yggdrasil-jumper --validate --config - 2&>1 \ + | sed -E 's/(.{100}[^ ]*) /\1\n/g')" + + json_init + json_add_string output "$output" + json_dump + ;; + esac + ;; +esac + diff --git a/protocols/luci-proto-yggdrasil/root/usr/share/rpcd/acl.d/luci-proto-yggdrasil.json b/protocols/luci-proto-yggdrasil/root/usr/share/rpcd/acl.d/luci-proto-yggdrasil.json index 0351d8610d..cb8bd9ff56 100644 --- a/protocols/luci-proto-yggdrasil/root/usr/share/rpcd/acl.d/luci-proto-yggdrasil.json +++ b/protocols/luci-proto-yggdrasil/root/usr/share/rpcd/acl.d/luci-proto-yggdrasil.json @@ -3,7 +3,8 @@ "description": "Grant access to LuCI Yggdrasil procedures", "write": { "ubus": { - "luci.yggdrasil": [ "generateKeyPair", "getPeers" ] + "luci.yggdrasil": [ "generateKeyPair", "getPeers" ], + "luci.yggdrasil-jumper": [ "isInstalled", "validateConfig" ] } } } |