luci-app-dockerman: sync with upstream source

This commit is contained in:
CN_SZTL 2020-02-07 15:44:56 +08:00
parent 1750a24f8b
commit fe6931e6b1
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
5 changed files with 91 additions and 53 deletions

View File

@ -57,7 +57,7 @@ network_selecter.render = function(self, section, scope)
Flag.render(self, section, scope)
end
network_name = network_table:option(DummyValue, "_name", translate("Name"))
network_name = network_table:option(DummyValue, "_name", translate("Network Name"))
network_driver = network_table:option(DummyValue, "_driver", translate("Driver"))
network_interface = network_table:option(DummyValue, "_interface", translate("Parent Interface"))
network_subnet = network_table:option(DummyValue, "_subnet", translate("Subnet"))

View File

@ -50,6 +50,8 @@ if cmd_line and cmd_line:match("^docker.+") then
key = "port"
elseif key == "e" then
key = "env"
elseif key == "dns" then
key = "dns"
elseif key == "net" then
key = "network"
elseif key == "cpu-shares" then
@ -64,7 +66,7 @@ if cmd_line and cmd_line:match("^docker.+") then
end
--key=value
if val then
if key == "mount" or key == "link" or key == "env" or key == "port" or key == "device" or key == "tmpfs" then
if key == "mount" or key == "link" or key == "env" or key == "dns" or key == "port" or key == "device" or key == "tmpfs" then
if not default_config[key] then default_config[key] = {} end
table.insert( default_config[key], val )
else
@ -76,7 +78,7 @@ if cmd_line and cmd_line:match("^docker.+") then
cursor = 1
-- value
elseif key and type(key) == "string" and cursor == 1 then
if key == "mount" or key == "link" or key == "env" or key == "port" or key == "device" or key == "tmpfs" then
if key == "mount" or key == "link" or key == "env" or key == "dns" or key == "port" or key == "device" or key == "tmpfs" then
if not default_config[key] then default_config[key] = {} end
table.insert( default_config[key], w )
else
@ -114,6 +116,7 @@ elseif cmd_line and cmd_line:match("^duplicate/[^/]+$") then
default_config.ip = default_config.network and default_config.network ~= "bridge" and default_config.network ~= "host" and default_config.network ~= "null" and create_body.NetworkingConfig.EndpointsConfig[default_config.network].IPAMConfig and create_body.NetworkingConfig.EndpointsConfig[default_config.network].IPAMConfig.IPv4Address or nil
default_config.link = create_body.HostConfig.Links
default_config.env = create_body.Env
default_config.dns = create_body.HostConfig.Dns
default_config.mount = create_body.HostConfig.Binds
if create_body.HostConfig.PortBindings and type(create_body.HostConfig.PortBindings) == "table" then
@ -178,12 +181,6 @@ d.disabled = 0
d.enabled = 1
d.default = default_config.tty and 1 or 0
d = s:option(Flag, "_force_pull", translate("Always pull image first"))
d.rmempty = true
d.disabled = 0
d.enabled = 1
d.default = 0
d = s:option(Value, "image", translate("Docker Image"))
d.rmempty = true
d.default = default_config.image or nil
@ -193,6 +190,12 @@ for _, v in ipairs (images) do
end
end
d = s:option(Flag, "_force_pull", translate("Always pull image first"))
d.rmempty = true
d.disabled = 0
d.enabled = 1
d.default = 0
d = s:option(Flag, "privileged", translate("Privileged"))
d.rmempty = true
d.disabled = 0
@ -217,11 +220,6 @@ d_ip.datatype="ip4addr"
d_ip:depends("network", "nil")
d_ip.default = default_config.ip or nil
d = s:option(Value, "user", translate("User"))
d.placeholder = "1000:1000"
d.rmempty = true
d.default = default_config.user or nil
d = s:option(DynamicList, "link", translate("Links with other containers"))
d.template = "docker/cbi/xdynlist"
d.placeholder = "container_name:alias"
@ -229,19 +227,30 @@ d.rmempty = true
d:depends("network", "bridge")
d.default = default_config.link or nil
d = s:option(DynamicList, "env", translate("Environmental Variable"))
d = s:option(DynamicList, "dns", translate("Set custom DNS servers"))
d.template = "docker/cbi/xdynlist"
d.placeholder = "8.8.8.8"
d.rmempty = true
d.default = default_config.dns or nil
d = s:option(Value, "user", translate("User(-u)"), translate("The user that commands are run as inside the container.(format: name|uid[:group|gid])"))
d.placeholder = "1000:1000"
d.rmempty = true
d.default = default_config.user or nil
d = s:option(DynamicList, "env", translate("Environmental Variable(-e)"), translate("Set environment variables to inside the container"))
d.template = "docker/cbi/xdynlist"
d.placeholder = "TZ=Asia/Shanghai"
d.rmempty = true
d.default = default_config.env or nil
d = s:option(DynamicList, "mount", translate("Bind Mount"))
d = s:option(DynamicList, "mount", translate("Bind Mount(-v)"), translate("Bind mount a volume"))
d.template = "docker/cbi/xdynlist"
d.placeholder = "/media:/media:slave"
d.rmempty = true
d.default = default_config.mount or nil
local d_ports = s:option(DynamicList, "port", translate("Exposed Ports"))
local d_ports = s:option(DynamicList, "port", translate("Exposed Ports(-p)"), translate("Publish container's port(s) to the host"))
d_ports.template = "docker/cbi/xdynlist"
d_ports.placeholder = "2200:22/tcp"
d_ports.rmempty = true
@ -258,14 +267,14 @@ d.disabled = 0
d.enabled = 1
d.default = default_config.advance or 0
d = s:option(DynamicList, "device", translate("Device"))
d = s:option(DynamicList, "device", translate("Device(--device)"), translate("Add host device to the container"))
d.template = "docker/cbi/xdynlist"
d.placeholder = "/dev/sda:/dev/xvdc:rwm"
d.rmempty = true
d:depends("advance", 1)
d.default = default_config.device or nil
d = s:option(DynamicList, "tmpfs", translate("Tmpfs"), translate("Mount tmpfs filesystems"))
d = s:option(DynamicList, "tmpfs", translate("Tmpfs(--tmpfs)"), translate("Mount tmpfs directory"))
d.template = "docker/cbi/xdynlist"
d.placeholder = "/run:rw,noexec,nosuid,size=65536k"
d.rmempty = true
@ -279,7 +288,7 @@ d:depends("advance", 1)
d.datatype="ufloat"
d.default = default_config.cpus or nil
d = s: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 = s: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:depends("advance", 1)
@ -321,7 +330,7 @@ end
m.handle = function(self, state, data)
if state ~= FORM_VALID then return end
local tmp
local name = data.name
local name = data.name or ("luci_" .. os.date("%Y%m%d%H%M%S"))
local tty = type(data.tty) == "number" and (data.tty == 1 and true or false) or default_config.tty or false
local interactive = type(data.interactive) == "number" and (data.interactive == 1 and true or false) or default_config.interactive or false
local image = data.image
@ -332,6 +341,7 @@ m.handle = function(self, state, data)
local privileged = type(data.privileged) == "number" and (data.privileged == 1 and true or false) or default_config.privileged or false
local restart = data.restart
local env = data.env
local dns = data.dns
local network = data.network
local ip = (network ~= "bridge" and network ~= "host" and network ~= "none") and data.ip or nil
local mount = data.mount
@ -422,6 +432,7 @@ m.handle = function(self, state, data)
create_body.Image = image
create_body.ExposedPorts = (next(exposedports) ~= nil) and exposedports or nil
create_body.HostConfig = create_body.HostConfig or {}
create_body.HostConfig.Dns = dns
create_body.HostConfig.Binds = (#mount ~= 0) and mount or nil
create_body.HostConfig.RestartPolicy = { Name = restart, MaximumRetryCount = 0 }
create_body.HostConfig.Privileged = privileged and true or false

View File

@ -82,7 +82,7 @@ s = m:section(NamedSection, "local", "section", translate("Setting"))
socket_path = s:option(Value, "socket_path", translate("Socket Path"))
status_path = s:option(Value, "status_path", translate("Action Status Tempfile Path"), translate("Where you want to save the docker status file"))
debug = s:option(Flag, "debug", translate("Enable Debug"), translate("For debug, It shows all docker API actions of luci-app-docker in Debug Tempfile Path"))
debug = s:option(Flag, "debug", translate("Enable Debug"), translate("For debug, It shows all docker API actions of luci-app-dockerman in Debug Tempfile Path"))
debug.enabled="true"
debug.disabled="false"
debug_path = s:option(Value, "debug_path", translate("Debug Tempfile Path"), translate("Where you want to save the debug tempfile"))

View File

@ -3,7 +3,7 @@
function resolv_container(op) {
let s = document.getElementById(op + '-status');
if (!s) return;
let cmd_line = prompt("Plese input <docker create/run> command line:", "");
let cmd_line = prompt("<%:Plese input <docker create/run> command line:%>", "");
if (cmd_line == null || cmd_line == "") {
s.innerHTML = "<font color='red'>Canceled</font>";
return;
@ -12,9 +12,9 @@
s.innerHTML = "<font color='red'>Command line Error</font>";
return;
}
window.location.href = "newcontainer/" + encodeURI(cmd_line)
window.location.href = "/cgi-bin/luci/admin/docker/newcontainer/" + encodeURI(cmd_line)
}
</script>
<input type="button" class="cbi-button cbi-button-apply" value="Command line" onclick="resolv_container('<%=self.option%>')" />
<input type="button" class="cbi-button cbi-button-apply" value="<%:Command line%>" onclick="resolv_container('<%=self.option%>')" />
<span id="<%=self.option%>-status"></span>
<%+cbi/valuefooter%>

View File

@ -58,8 +58,8 @@ msgstr "重启策略"
msgid "Update"
msgstr "更新"
msgid "Device"
msgstr "设备"
msgid "Device(--device)"
msgstr "设备(--device)"
msgid "Mount/Volume"
msgstr "挂载/存储卷"
@ -103,26 +103,20 @@ msgstr "CPU数量数字是小数0.000表示没有限制。"
msgid "CPU Shares Weight"
msgstr "CPU份额权重"
msgid ""
"CPU shares relative weight, if 0 is set, the system will ignore the value and use the default of 1024."
msgstr ""
"CPU份额相对权重如果设置为0则系统将忽略该值并使用默认值1024。"
msgid "CPU shares relative weight, if 0 is set, the system will ignore the value and use the default of 1024."
msgstr "CPU份额相对权重如果设置为0则系统将忽略该值并使用默认值1024。"
msgid "Memory"
msgstr "内存"
msgid ""
"Memory limit (format: <number>[<unit>]). Number is a positive integer. Unit can be one of b, k, m, or g. Minimum is 4M."
msgstr ""
"内存限制 (格式: <容量>[<单位>]). 数字是一个正整数。单位可以是bkm或g之一。最小为4M。"
msgid "Memory limit (format: <number>[<unit>]). Number is a positive integer. Unit can be one of b, k, m, or g. Minimum is 4M."
msgstr "内存限制 (格式: <容量>[<单位>]). 数字是一个正整数。单位可以是bkm或g之一。最小为4M。"
msgid "Block IO Weight"
msgstr "IO 权重"
msgid ""
"Block IO weight (relative weight) accepts a weight value between 10 and 1000."
msgstr ""
"IO 权重相对权重接受10到1000之间的权重值。"
msgid "Block IO weight (relative weight) accepts a weight value between 10 and 1000."
msgstr "IO 权重 (相对权重) 接受10到1000之间的权重值。"
msgid "Container Logs"
msgstr "容器日志"
@ -151,8 +145,8 @@ msgstr "解析命令行"
msgid "Docker Image"
msgstr "Docker 镜像"
msgid "User"
msgstr "用户"
msgid "User(-u)"
msgstr "用户(-u)"
msgid "New Container"
msgstr "新容器"
@ -167,22 +161,22 @@ msgid "Always pull image first"
msgstr "始终先拉取镜像"
msgid "Privileged"
msgstr "特权模式(Privileged)"
msgstr "特权模式(--privileged)"
msgid "IPv4 Address"
msgstr "IPv4 地址"
msgid "Links with other containers"
msgstr "与其他容器的链接(Links)"
msgstr "与其他容器的链接(--link)"
msgid "Environmental Variable"
msgstr "环境变量(Env)"
msgid "Environmental Variable(-e)"
msgstr "环境变量(-e)"
msgid "Bind Mount"
msgid "Bind Mount(-v)"
msgstr "挂载(-v)"
msgid "Exposed Ports"
msgstr "暴露端口"
msgid "Exposed Ports(-p)"
msgstr "暴露端口(-p)"
msgid "Run command"
msgstr "运行命令"
@ -190,8 +184,8 @@ msgstr "运行命令"
msgid "Advance"
msgstr "高级"
msgid "Mount tmpfs filesystems"
msgstr "挂载tmpfs文件系统"
msgid "Mount tmpfs directory"
msgstr "挂载tmpfs到容器内部目录"
msgid "New Network"
msgstr "新网络"
@ -259,8 +253,8 @@ msgstr "保存docker status文件的位置"
msgid "Enable Debug"
msgstr "启用调试"
msgid "For debug, It shows all docker API actions of luci-app-docker in Debug Tempfile Path"
msgstr "用于调试它在调试临时文件路径中显示luci-app-docker的所有docker API操作"
msgid "For debug, It shows all docker API actions of luci-app-dockermab in Debug Tempfile Path"
msgstr "用于调试,它在调试临时文件路径中显示 luci-app-dockermab 的所有docker API操作"
msgid "Debug Tempfile Path"
msgstr "调试临时文件路径"
@ -296,4 +290,37 @@ msgid "Pull Image"
msgstr "拉取镜像"
msgid "Pull"
msgstr "拉取"
msgstr "拉取"
msgid "Command line"
msgstr "输入命令行"
msgid "Plese input <docker create/run> command line:"
msgstr "请输入 docker run/create ... 命令行:"
msgid "Network Name"
msgstr "网络名"
msgid "Set custom DNS servers"
msgstr "自定义 DNS 服务器"
msgid "The user that commands are run as inside the container.(format: name|uid[:group|gid])"
msgstr "容器内部执行命令的用户(组), 格式: UID:GID"
msgid "Set environment variables to inside the container"
msgstr "容器内部环境变量"
msgid "Bind mount a volume"
msgstr "绑定挂载"
msgid "Publish container's port(s) to the host"
msgstr "将容器的端口发布到宿主"
msgid "Add host device to the container"
msgstr "添加宿主设备到容器内部"
msgid "Device"
msgstr "设备"
msgid "Finish Time"
msgstr "结束时间"