luci-app-dockerman: sync with upstream source
This commit is contained in:
parent
56dd34ec60
commit
9d5273280e
@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-dockerman
|
||||
PKG_VERSION:=v0.5.5
|
||||
PKG_VERSION:=v0.5.6
|
||||
PKG_RELEASE:=beta
|
||||
PKG_MAINTAINER:=lisaac <https://github.com/lisaac/luci-app-dockerman>
|
||||
PKG_LICENSE:=AGPL-3.0
|
||||
@ -56,6 +56,8 @@ exit 0
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr
|
||||
cp -pR $(PKG_BUILD_DIR)/root/usr/* $(1)/usr/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
cp -pR $(PKG_BUILD_DIR)/root/etc/config/* $(1)/etc/config/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
|
||||
@ -4,7 +4,7 @@ Copyright 2019 lisaac <https://github.com/lisaac/luci-app-dockerman>
|
||||
]]--
|
||||
require "luci.util"
|
||||
local docker = require "luci.model.docker"
|
||||
local uci = require "luci.model.uci"
|
||||
-- local uci = require "luci.model.uci"
|
||||
|
||||
module("luci.controller.dockerman",package.seeall)
|
||||
|
||||
|
||||
@ -401,26 +401,26 @@ if action == "info" then
|
||||
end
|
||||
|
||||
-- info end
|
||||
elseif action == "edit" then
|
||||
local editsection= m:section(SimpleSection)
|
||||
d = editsection:option( Value, "cpus", translate("CPUs"), translate("Number of CPUs. Number is a fractional number. 0.000 means no limit."))
|
||||
elseif action == "resources" then
|
||||
local resources_section= m:section(SimpleSection)
|
||||
d = resources_section:option( Value, "cpus", translate("CPUs"), translate("Number of CPUs. Number is a fractional number. 0.000 means no limit."))
|
||||
d.placeholder = "1.5"
|
||||
d.rmempty = true
|
||||
d.datatype="ufloat"
|
||||
d.default = container_info.HostConfig.NanoCpus / (10^9)
|
||||
|
||||
d = editsection:option(Value, "cpushares", translate("CPU Shares Weight"), translate("CPU shares relative weight, if 0 is set, the system will ignore the value and use the default of 1024."))
|
||||
d = resources_section:option(Value, "cpushares", translate("CPU Shares Weight"), translate("CPU shares relative weight, if 0 is set, the system will ignore the value and use the default of 1024."))
|
||||
d.placeholder = "1024"
|
||||
d.rmempty = true
|
||||
d.datatype="uinteger"
|
||||
d.default = container_info.HostConfig.CpuShares
|
||||
|
||||
d = editsection:option(Value, "memory", translate("Memory"), translate("Memory limit (format: <number>[<unit>]). Number is a positive integer. Unit can be one of b, k, m, or g. Minimum is 4M."))
|
||||
d = resources_section:option(Value, "memory", translate("Memory"), translate("Memory limit (format: <number>[<unit>]). Number is a positive integer. Unit can be one of b, k, m, or g. Minimum is 4M."))
|
||||
d.placeholder = "128m"
|
||||
d.rmempty = true
|
||||
d.default = container_info.HostConfig.Memory ~=0 and ((container_info.HostConfig.Memory / 1024 /1024) .. "M") or 0
|
||||
|
||||
d = editsection:option(Value, "blkioweight", translate("Block IO Weight"), translate("Block IO weight (relative weight) accepts a weight value between 10 and 1000."))
|
||||
d = resources_section:option(Value, "blkioweight", translate("Block IO Weight"), translate("Block IO weight (relative weight) accepts a weight value between 10 and 1000."))
|
||||
d.placeholder = "500"
|
||||
d.rmempty = true
|
||||
d.datatype="uinteger"
|
||||
@ -457,7 +457,7 @@ elseif action == "edit" then
|
||||
else
|
||||
docker:clear_status()
|
||||
end
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin/docker/container/"..container_id.."/edit"))
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin/docker/container/"..container_id.."/resources"))
|
||||
end
|
||||
end
|
||||
elseif action == "file" then
|
||||
|
||||
@ -83,9 +83,9 @@ end
|
||||
s.template = "dockerman/overview"
|
||||
|
||||
local section_dockerman = map_dockerman:section(NamedSection, "local", "section", translate("Setting"))
|
||||
section_dockerman:tab("dockerman", translate("DockerMan"), translate("DockerMan Settings"))
|
||||
section_dockerman:tab("ac", translate("Access Control"), translate("Access Control for the bridge network"))
|
||||
section_dockerman:tab("daemon", translate("Docker Daemon"), translate("Docker Daemon Settings"))
|
||||
section_dockerman:tab("daemon", translate("Docker Daemon"))
|
||||
section_dockerman:tab("ac", translate("Access Control"))
|
||||
section_dockerman:tab("dockerman", translate("DockerMan"))
|
||||
|
||||
local socket_path = section_dockerman:taboption("dockerman", Value, "socket_path", translate("Docker Socket Path"))
|
||||
socket_path.default = "/var/run/docker.sock"
|
||||
@ -118,8 +118,8 @@ if nixio.fs.access("/usr/bin/dockerd") then
|
||||
for i, v in ipairs(interfaces) do
|
||||
allowed_interface:value(v, v)
|
||||
end
|
||||
local allowed_container = section_dockerman:taboption("ac", DynamicList, "ac_allowed_container", translate("Containers allowed to be accessed"), translate("Which container(s) can be accessed, even from interfaces that are not allowed, fill-in Container Id or Name"))
|
||||
allowed_container.placeholder = "container name_or_id"
|
||||
local allowed_container = section_dockerman:taboption("ac", DynamicList, "ac_allowed_container", translate("Containers allowed to be accessed"), translate("Which container(s) under bridge network can be accessed, even from interfaces that are not allowed, fill-in Container Id or Name"))
|
||||
-- allowed_container.placeholder = "container name_or_id"
|
||||
if containers_list then
|
||||
for i, v in ipairs(containers_list) do
|
||||
if v.State == "running" and v.NetworkSettings and v.NetworkSettings.Networks and v.NetworkSettings.Networks.bridge and v.NetworkSettings.Networks.bridge.IPAddress then
|
||||
@ -134,7 +134,6 @@ if nixio.fs.access("/usr/bin/dockerd") then
|
||||
local data_root = section_dockerman:taboption("daemon", Value, "daemon_data_root", translate("Docker Root Dir"))
|
||||
data_root.placeholder = "/opt/docker/"
|
||||
local registry_mirrors = section_dockerman:taboption("daemon", DynamicList, "daemon_registry_mirrors", translate("Registry Mirrors"))
|
||||
registry_mirrors.placeholder = "https://hub-mirror.c.163.com"
|
||||
registry_mirrors:value("https://hub-mirror.c.163.com", "https://hub-mirror.c.163.com")
|
||||
|
||||
local log_level = section_dockerman:taboption("daemon", ListValue, "daemon_log_level", translate("Log Level"), translate('Set the logging level'))
|
||||
@ -144,7 +143,6 @@ if nixio.fs.access("/usr/bin/dockerd") then
|
||||
log_level:value("error", "error")
|
||||
log_level:value("fatal", "fatal")
|
||||
local hosts = section_dockerman:taboption("daemon", DynamicList, "daemon_hosts", translate("Server Host"), translate('Daemon unix socket (unix:///var/run/docker.sock) or TCP Remote Hosts (tcp://0.0.0.0:2375), default: unix:///var/run/docker.sock'))
|
||||
hosts.placeholder = "unix:///var/run/docker.sock"
|
||||
hosts:value("unix:///var/run/docker.sock", "unix:///var/run/docker.sock")
|
||||
hosts:value("tcp://0.0.0.0:2375", "tcp://0.0.0.0:2375")
|
||||
hosts.rmempty = true
|
||||
|
||||
@ -17,7 +17,6 @@ local update_image = function(self, image_name)
|
||||
if res and res.code == 200 and (#res.body > 0 and not res.body[#res.body].error and res.body[#res.body].status and (res.body[#res.body].status == "Status: Downloaded newer image for ".. image_name)) then
|
||||
_docker:append_status("done\n")
|
||||
else
|
||||
res.code = 500
|
||||
res.body.message = res.body[#res.body] and res.body[#res.body].error or (res.body.message or res.message)
|
||||
end
|
||||
new_image_id = self.images:inspect({name = image_name}).body.Id
|
||||
@ -66,13 +65,14 @@ local map_subtract = function(t1, t2)
|
||||
end
|
||||
end
|
||||
if not found then
|
||||
if v1 and type(v1) == "table" then
|
||||
if next(v1) == nil then
|
||||
res[k1] = { k = 'v' }
|
||||
else
|
||||
res[k1] = v1
|
||||
end
|
||||
end
|
||||
res[k1] = v1
|
||||
-- if v1 and type(v1) == "table" then
|
||||
-- if next(v1) == nil then
|
||||
-- res[k1] = { k = 'v' }
|
||||
-- else
|
||||
-- res[k1] = v1
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
@ -139,7 +139,7 @@ local get_config = function(container_config, image_config)
|
||||
Type = v.Type,
|
||||
Target = v.Destination,
|
||||
Source = v.Source:match("([^/]+)\/_data"),
|
||||
BindOptions = v.Type == "bind" and {Propagation = v.Propagation} or nil,
|
||||
BindOptions = (v.Type == "bind") and {Propagation = v.Propagation} or nil,
|
||||
ReadOnly = not v.RW
|
||||
})
|
||||
end
|
||||
@ -195,6 +195,7 @@ local upgrade = function(self, request)
|
||||
|
||||
-- create new container
|
||||
_docker:append_status("Container: Create" .. " " .. container_name .. "...")
|
||||
create_body = _docker.clear_empty_tables(create_body)
|
||||
res = self.containers:create({name = container_name, body = create_body})
|
||||
if res and res.code > 300 then return res end
|
||||
_docker:append_status("done\n")
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<br>
|
||||
<ul class="cbi-tabmenu">
|
||||
<li id="cbi-tab-container_info"><a id="a-cbi-tab-container_info" href=""><%:Info%></a></li>
|
||||
<li id="cbi-tab-container_edit"><a id="a-cbi-tab-container_edit" href=""><%:Edit%></a></li>
|
||||
<li id="cbi-tab-container_resources"><a id="a-cbi-tab-container_resources" href=""><%:Resources%></a></li>
|
||||
<li id="cbi-tab-container_stats"><a id="a-cbi-tab-container_stats" href=""><%:Stats%></a></li>
|
||||
<li id="cbi-tab-container_file"><a id="a-cbi-tab-container_file" href=""><%:File%></a></li>
|
||||
<li id="cbi-tab-container_console"><a id="a-cbi-tab-container_console" href=""><%:Console%></a></li>
|
||||
@ -14,7 +14,7 @@
|
||||
let path = p.split(re)
|
||||
let container_id = path[1].split('/')[0] || path[1]
|
||||
let action = path[1].split('/')[1] || "info"
|
||||
let actions=["info","edit","stats","file","console","logs"]
|
||||
let actions=["info","resources","stats","file","console","logs"]
|
||||
actions.forEach(function(item) {
|
||||
document.getElementById("a-cbi-tab-container_" + item).href= path[0]+"/admin/docker/container/"+container_id+'/'+item
|
||||
if (action === item) {
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
<% if self.title == "Events" then %>
|
||||
<% if self.title == "Events" then %>
|
||||
<%+header%>
|
||||
<h2 name="content"><%:Docker%></h2>
|
||||
<legend><%:Events%></legend>
|
||||
<div class="cbi-section">
|
||||
<h3><%:Events%></h3>
|
||||
<% end %>
|
||||
<div id="content_syslog">
|
||||
<textarea readonly="readonly" wrap="off" rows="<%=self.syslog:cmatch("\n")+2%>" id="syslog"><%=self.syslog:pcdata()%></textarea>
|
||||
<textarea readonly="readonly" wrap="off" rows="<%=self.syslog:cmatch('\n')+2%>" id="syslog"><%=self.syslog:pcdata()%></textarea>
|
||||
</div>
|
||||
<% if self.title == "Events" then %>
|
||||
</div>
|
||||
<%+footer%>
|
||||
<% end %>
|
||||
@ -283,6 +283,9 @@ msgstr "服务端"
|
||||
msgid "Daemon unix socket (unix:///var/run/docker.sock) or TCP Remote Hosts (tcp://0.0.0.0:2375), default: unix:///var/run/docker.sock"
|
||||
msgstr "后台 Unix socket (unix:///var/run/docker.sock) 或 TCP 远程服务端 (tcp://0.0.0.0:2375),默认: unix:///var/run/docker.sock"
|
||||
|
||||
msgid "Resources"
|
||||
msgstr "资源"
|
||||
|
||||
msgid "Stats"
|
||||
msgstr "状态"
|
||||
|
||||
@ -424,8 +427,8 @@ msgstr "允许访问的接口"
|
||||
msgid "Containers allowed to be accessed"
|
||||
msgstr "允许被访问的容器"
|
||||
|
||||
msgid "Which container(s) can be accessed, even from interfaces that are not allowed, fill-in Container Id or Name"
|
||||
msgstr "哪些容器可以被访问,即使访问来自不被允许的接口,填入容器ID或容器名"
|
||||
msgid "Which container(s) under bridge network can be accessed, even from interfaces that are not allowed, fill-in Container Id or Name"
|
||||
msgstr "哪些 bridge 网络下的容器可以被访问,即使访问来自不被允许的接口,填入容器ID或容器名"
|
||||
|
||||
msgid "Which interface(s) can access containers under the bridge network, fill-in Interface Name"
|
||||
msgstr "哪些接口可以访问 bridge 网络下的容器, 填入接口名"
|
||||
|
||||
@ -9,6 +9,7 @@ uci -q batch <<-EOF >/dev/null
|
||||
commit ucitrack
|
||||
EOF
|
||||
[ -x "$(which dockerd)" ] && chmod +x /etc/init.d/dockerman && /etc/init.d/dockerd disable && /etc/init.d/dockerman enable >/dev/null 2>&1
|
||||
sed -i 's/self:cfgvalue(section) or {}/self:cfgvalue(section) or self.default or {}/' /usr/lib/lua/luci/view/cbi/dynlist.htm
|
||||
/etc/init.d/uhttpd restart >/dev/null 2>&1
|
||||
rm -fr /tmp/luci-indexcache /tmp/luci-modulecache >/dev/null 2>&1
|
||||
exit 0
|
||||
@ -9,8 +9,8 @@ raw_json = luci.jsonc.parse(raw_json_str) or {}
|
||||
|
||||
new_json = {}
|
||||
new_json["data-root"] = uci:get("dockerman", "local", "daemon_data_root")
|
||||
new_json["hosts"] = uci:get("dockerman", "local", "daemon_hosts")
|
||||
new_json["registry-mirrors"] = uci:get("dockerman", "local", "daemon_registry_mirrors")
|
||||
new_json["hosts"] = uci:get("dockerman", "local", "daemon_hosts") or {}
|
||||
new_json["registry-mirrors"] = uci:get("dockerman", "local", "daemon_registry_mirrors") or {}
|
||||
new_json["log-level"] = uci:get("dockerman", "local", "daemon_log_level")
|
||||
|
||||
function comp(raw, new)
|
||||
@ -43,6 +43,8 @@ function comp(raw, new)
|
||||
end
|
||||
comp(raw_json, new_json)
|
||||
if changed then
|
||||
if next(raw_json["registry-mirrors"]) == nil then raw_json["registry-mirrors"] = nil end
|
||||
if next(raw_json["hosts"]) == nil then raw_json["hosts"] = nil end
|
||||
fs.writefile(raw_file_dir, luci.jsonc.stringify(raw_json, true):gsub("\\", ""))
|
||||
os.exit(0)
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user