set pppoeserver to nas

This commit is contained in:
sirpdboy 2021-02-07 13:07:53 +08:00
parent 3e27903304
commit 55e6e540f3
8 changed files with 113 additions and 124 deletions

View File

@ -19,11 +19,13 @@ end
function get_template_config()
local b
local d = ""
for cnt in io.lines("/tmp/resolv.conf.d/resolv.conf.auto") do
b=string.match (cnt,"^[^#]*nameserver%s+([^%s]+)$")
if (b~=nil) then
d=d.." - "..b.."\n"
local file = "/tmp/resolv.conf.d/resolv.conf.auto"
if not fs.access(file) then
file = "/tmp/resolv.conf.auto"
end
for cnt in io.lines(file) do
b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$")
if (b ~= nil) then d = d .. " - " .. b .. "\n" end
end
local f = io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
local tbl = {}
@ -94,13 +96,7 @@ function get_log()
return
end
http.prepare_content("text/plain; charset=utf-8")
local fdp
if fs.access("/var/run/lucilogreload") then
fdp=0
fs.remove("/var/run/lucilogreload")
else
fdp=tonumber(fs.readfile("/var/run/lucilogpos")) or 0
end
local fdp = tonumber(fs.readfile("/var/run/lucilogpos")) or 0
local f = io.open(logfile, "r+")
f:seek("set", fdp)
local a = f:read(2048000) or ""

View File

@ -71,15 +71,13 @@ o.optional = true
---- bin path
o = s:option(Value, "binpath", translate("Bin Path"), translate("AdGuardHome Bin path if no bin will auto download"))
o.default = "/usr/bin/AdGuardHome"
o.default = "/usr/bin/AdGuardHome/AdGuardHome"
o.datatype = "string"
o.optional = false
o.rmempty = false
o.validate = function(self, value)
if value == "" then return nil end
if fs.stat(value,"type")=="dir" then
fs.rmdir(value)
end
if fs.stat(value, "type") == "dir" then fs.rmdir(value) end
if fs.stat(value, "type") == "dir" then
if (m.message) then
m.message = m.message .. "\nerror!bin path is a dir"
@ -111,9 +109,7 @@ o.optional = false
o.rmempty=false
o.validate=function(self, value)
if value==nil then return nil end
if fs.stat(value,"type")=="dir" then
fs.rmdir(value)
end
if fs.stat(value, "type") == "dir" then fs.rmdir(value) end
if fs.stat(value, "type") == "dir" then
if m.message then
m.message = m.message .. "\nerror!config path is a dir"
@ -153,9 +149,7 @@ o = s:option(Value, "logfile", translate("Runtime log file"), translate("AdGuard
o.datatype = "string"
o.rmempty = true
o.validate = function(self, value)
if fs.stat(value,"type")=="dir" then
fs.rmdir(value)
end
if fs.stat(value, "type") == "dir" then fs.rmdir(value) end
if fs.stat(value, "type") == "dir" then
if m.message then
m.message = m.message .. "\nerror!log file is a dir"
@ -239,10 +233,10 @@ o1:depends ("backupfile", "filters")
o1:depends ("backupfile", "stats.db")
o1:depends ("backupfile", "querylog.json")
o1:depends ("backupfile", "sessions.db")
for name in fs.glob(workdir.."/data/*")
do
for name in fs.glob(workdir .. "/data/*") do
name = fs.basename(name)
if name~="filters" and name~="stats.db" and name~="querylog.json" and name~="sessions.db" then
if name ~= "filters" and name ~= "stats.db" and name ~= "querylog.json" and
name ~= "sessions.db" then
o:value(name,name)
o1:depends ("backupfile", name)
end

View File

@ -8,11 +8,13 @@ require("table")
function gen_template_config()
local b
local d = ""
for cnt in io.lines("/tmp/resolv.conf.d/resolv.conf.auto") do
b=string.match (cnt,"^[^#]*nameserver%s+([^%s]+)$")
if (b~=nil) then
d=d.." - "..b.."\n"
local file = "/tmp/resolv.conf.d/resolv.conf.auto"
if not fs.access(file) then
file = "/tmp/resolv.conf.auto"
end
for cnt in io.lines(file) do
b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$")
if (b ~= nil) then d = d .. " - " .. b .. "\n" end
end
local f = io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
local tbl = {}
@ -50,9 +52,7 @@ end
o.validate = function(self, value)
fs.writefile("/tmp/AdGuardHometmpconfig.yaml", value:gsub("\r\n", "\n"))
if fs.access(binpath) then
if (sys.call(binpath.." -c /tmp/AdGuardHometmpconfig.yaml --check-config 2> /tmp/AdGuardHometest.log")==0) then
return value
end
if (sys.call(binpath .. " -c /tmp/AdGuardHometmpconfig.yaml --check-config 2> /tmp/AdGuardHometest.log") == 0) then return value end
else
return value
end
@ -62,9 +62,8 @@ end
o.write = function(self, section, value)
fs.move("/tmp/AdGuardHometmpconfig.yaml", configpath)
end
o.remove = function(self, section, value)
fs.writefile(configpath, "")
end
o.remove = function(self, section, value) fs.writefile(configpath, "") end
--- js and reload button
o = s:option(DummyValue, "")
o.anonymous = true

View File

@ -5,7 +5,7 @@ config AdGuardHome 'AdGuardHome'
option workdir '/usr/bin/AdGuardHome'
option logfile '/tmp/AdGuardHome.log'
option verbose '0'
option binpath '/usr/bin/AdGuardHome'
option binpath '/usr/bin/AdGuardHome/AdGuardHome'
option upxflag ''
option redirect 'dnsmasq-upstream'
option waitonboot '0'

View File

@ -4,16 +4,16 @@ module("luci.controller.pppoe-server", package.seeall)
function index()
if not nixio.fs.access("/etc/config/pppoe-server") then return end
entry({"admin", "services", "pppoe-server"},
alias("admin", "services", "pppoe-server", "settings"),
_("PPPoE Server"), 3)
entry({"admin", "services", "pppoe-server", "settings"},
entry({"admin", "nas", "pppoe-server"},
alias("admin", "nas", "pppoe-server", "settings"),
_("PPPoE Server"), 13)
entry({"admin", "nas", "pppoe-server", "settings"},
cbi("pppoe-server/settings"), _("General Settings"), 10).leaf = true
entry({"admin", "services", "pppoe-server", "users"},
entry({"admin", "nas", "pppoe-server", "users"},
cbi("pppoe-server/users"), _("Users Manager"), 20).leaf = true
entry({"admin", "services", "pppoe-server", "online"},
entry({"admin", "nas", "pppoe-server", "online"},
cbi("pppoe-server/online"), _("Online Users"), 30).leaf = true
entry({"admin", "services", "pppoe-server", "status"}, call("status")).leaf =
entry({"admin", "nas", "pppoe-server", "status"}, call("status")).leaf =
true
end

View File

@ -31,6 +31,6 @@ kill = t:option(Button, "_kill", translate("Forced offline"))
kill.inputstyle = "reset"
function kill.write(e, t)
null, e.tag_error[t] = luci.sys.process.signal(e.map:get(t, "PID"), 9)
luci.http.redirect(o.build_url("admin/services/pppoe-server/online"))
luci.http.redirect(o.build_url("admin/nas/pppoe-server/online"))
end
return f

View File

@ -1,6 +1,6 @@
<% include("cbi/map") %>
<script type="text/javascript">//<![CDATA[
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "services", "pppoe-server", "status")%>', null,
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "nas", "pppoe-server", "status")%>', null,
function(x, result)
{
var status = document.getElementsByClassName('pppoe_server_status')[0];

View File

@ -5,7 +5,7 @@ config service
option count '50'
option mru '1492'
option mtu '1492'
option remoteip '10.0.1.100-254'
option remoteip '10.0.1.10-254'
option is_nat '1'
option export_interface 'default'
option client_interface 'eth0'