-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
luci-app-ssr-plus: Add script gets dnsmasq configuration path.
1、Resolve compile-time occurrences: ./etc/init.d/shadowsocksr: uci command not found grep: /tmp/dnasmq.conf: not such file or directory 2、make version apk compatible Signed-off-by: Zxl hhyccc <[email protected]>
- Loading branch information
zxlhhyccc
committed
Nov 16, 2024
1 parent
d021fc8
commit 4fc3f45
Showing
4 changed files
with
55 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
luci-app-ssr-plus/root/usr/share/shadowsocksr/dnsmasqconfdir.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/lua | ||
|
||
local uci = require("uci") | ||
local cursor = uci.cursor() | ||
|
||
-- Function to get the DNSMasq configuration ID | ||
local function get_dnsmasq_cfg_id() | ||
local id = nil | ||
cursor:foreach("dhcp", "dnsmasq", function(s) | ||
if not id then | ||
id = s[".name"] -- Get the internal ID of the first dnsmasq entry | ||
end | ||
end) | ||
return id | ||
end | ||
|
||
-- Get the DNSMasq configuration ID | ||
local DEFAULT_DNSMASQ_CFGID = get_dnsmasq_cfg_id() | ||
local DNSMASQ_CONF_DIR = nil | ||
local TMP_DNSMASQ_PATH = nil | ||
|
||
if DEFAULT_DNSMASQ_CFGID then | ||
local dnsmasq_conf_path = io.popen("grep -l '^conf-dir=' /tmp/etc/dnsmasq.conf." .. DEFAULT_DNSMASQ_CFGID):read("*a") | ||
dnsmasq_conf_path = dnsmasq_conf_path:gsub("%s+", "") -- Trim whitespace | ||
|
||
if dnsmasq_conf_path ~= "" then | ||
local dnsmasq_conf_dir = io.popen("grep '^conf-dir=' " .. dnsmasq_conf_path .. " | cut -d'=' -f2 | head -n 1"):read("*a") | ||
dnsmasq_conf_dir = dnsmasq_conf_dir:gsub("%s+", "") -- Trim whitespace | ||
|
||
if dnsmasq_conf_dir ~= "" then | ||
DNSMASQ_CONF_DIR = dnsmasq_conf_dir:gsub("/$", "") -- Remove trailing slash | ||
TMP_DNSMASQ_PATH = DNSMASQ_CONF_DIR .. "/dnsmasq-ssrplus.d" | ||
end | ||
end | ||
end | ||
|
||
-- Output variables in a format usable by shell scripts | ||
io.write("DNSMASQ_CONF_DIR='", DNSMASQ_CONF_DIR or "", "'\n") | ||
io.write("TMP_DNSMASQ_PATH='", TMP_DNSMASQ_PATH or "", "'\n") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters