summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2020-07-17 13:16:14 +0200
committerFlorian Eckert <fe@dev.tdt.de>2020-07-28 14:16:14 +0200
commita4a9f0a68379faf0a73525fdd745d3b9d36f8583 (patch)
treebc49f5252f8e1c0af84f92774a0a88207fb7c21a
parent88ced182031200ffa6a102cdac0c12865d135a22 (diff)
luci-app-dockerman: use uci from docker-ce
Change the source to user docker-ce and update docker uci options name. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
-rw-r--r--applications/luci-app-dockerman/luasrc/controller/dockerman.lua8
-rw-r--r--applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua8
-rw-r--r--applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua56
-rw-r--r--applications/luci-app-dockerman/luasrc/model/docker.lua20
-rw-r--r--applications/luci-app-dockerman/root/usr/share/rpcd/acl.d/luci-app-dockerman.json4
5 files changed, 54 insertions, 42 deletions
diff --git a/applications/luci-app-dockerman/luasrc/controller/dockerman.lua b/applications/luci-app-dockerman/luasrc/controller/dockerman.lua
index aabad3360..6f4e43df5 100644
--- a/applications/luci-app-dockerman/luasrc/controller/dockerman.lua
+++ b/applications/luci-app-dockerman/luasrc/controller/dockerman.lua
@@ -16,13 +16,13 @@ function index()
entry({"admin","docker","overview"},cbi("dockerman/overview"),_("Overview"),0).leaf=true
- local remote = luci.model.uci.cursor():get("dockerman", "local", "remote_endpoint")
+ local remote = luci.model.uci.cursor():get("dockerd", "globals", "remote_endpoint")
if remote == nil then
- local socket = luci.model.uci.cursor():get("dockerman", "local", "socket_path")
+ local socket = luci.model.uci.cursor():get("dockerd", "globals", "socket_path")
if socket and not nixio.fs.access(socket) then return end
elseif remote == "true" then
- local host = luci.model.uci.cursor():get("dockerman", "local", "remote_host")
- local port = luci.model.uci.cursor():get("dockerman", "local", "remote_port")
+ local host = luci.model.uci.cursor():get("dockerd", "globals", "remote_host")
+ local port = luci.model.uci.cursor():get("dockerd", "globals", "remote_port")
if not host or not port then return end
end
diff --git a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua
index 7c0c96933..1c39ebf4f 100644
--- a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua
+++ b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/container.lua
@@ -537,10 +537,10 @@ elseif action == "console" then
luci.util.exec(kill_ttyd)
local hosts
local uci = (require "luci.model.uci").cursor()
- local remote = uci:get("dockerman", "local", "remote_endpoint")
- local socket_path = (remote == "false" or not remote) and uci:get("dockerman", "local", "socket_path") or nil
- local host = (remote == "true") and uci:get("dockerman", "local", "remote_host") or nil
- local port = (remote == "true") and uci:get("dockerman", "local", "remote_port") or nil
+ local remote = uci:get("dockerd", "globals", "remote_endpoint")
+ local socket_path = (remote == "false" or not remote) and uci:get("dockerd", "globals", "socket_path") or nil
+ local host = (remote == "true") and uci:get("dockerd", "globals", "remote_host") or nil
+ local port = (remote == "true") and uci:get("dockerd", "globals", "remote_port") or nil
if remote and host and port then
hosts = host .. ':'.. port
elseif socket_path then
diff --git a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua
index 0c2dbd365..8cd97d982 100644
--- a/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua
+++ b/applications/luci-app-dockerman/luasrc/model/cbi/dockerman/overview.lua
@@ -18,7 +18,12 @@ function byte_format(byte)
end
end
-local map_dockerman = Map("dockerman", translate("Docker"), translate("DockerMan is a Simple Docker manager client for LuCI, If you have any issue please visit:") .. " ".. [[<a href="https://github.com/lisaac/luci-app-dockerman" target="_blank">]] ..translate("Github") .. [[</a>]])
+local map_dockerman = Map("dockerd", translate("Docker"),
+ translate("DockerMan is a Simple Docker manager client for LuCI, If you have any issue please visit:") ..
+ " " ..
+ [[<a href="https://github.com/lisaac/luci-app-dockerman" target="_blank">]] ..
+ translate("Github") ..
+ [[</a>]])
local docker_info_table = {}
-- docker_info_table['0OperatingSystem'] = {_key=translate("Operating System"),_value='-'}
-- docker_info_table['1Architecture'] = {_key=translate("Architecture"),_value='-'}
@@ -42,7 +47,7 @@ s.images_total = '-'
s.networks_total = '-'
s.volumes_total = '-'
local containers_list
--- local socket = luci.model.uci.cursor():get("dockerman", "local", "socket_path")
+-- local socket = luci.model.uci.cursor():get("dockerd", "globals", "socket_path")
if (require "luci.model.docker").new():_ping().code == 200 then
local dk = docker.new()
containers_list = dk.containers:list({query = {all=true}}).body
@@ -86,9 +91,8 @@ if (require "luci.model.docker").new():_ping().code == 200 then
end
s.template = "dockerman/overview"
-local section_dockerman = map_dockerman:section(NamedSection, "local", "section", translate("Setting"))
+local section_dockerman = map_dockerman:section(NamedSection, "globals", "section", translate("Setting"))
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"))
@@ -117,23 +121,31 @@ remote_port.default = "2375"
-- local debug_path = section_dockerman:taboption("dockerman", Value, "debug_path", translate("Debug Tempfile Path"), translate("Where you want to save the debug tempfile"))
if nixio.fs.access("/usr/bin/dockerd") then
- local dockerd_enable = section_dockerman:taboption("daemon", Flag, "daemon_ea", translate("Enable"))
- dockerd_enable.enabled = "true"
- dockerd_enable.rmempty = true
- 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: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'))
- log_level:value("debug", "debug")
- log_level:value("info", "info")
- log_level:value("warn", "warn")
- 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: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
+ local o
+
+ o = section_dockerman:taboption("daemon", Value, "data_root",
+ translate("Docker Root Dir"))
+ o.placeholder = "/opt/docker/"
+
+ o = section_dockerman:taboption("daemon", DynamicList, "registry_mirrors",
+ translate("Registry Mirrors"))
+ o:value("https://hub-mirror.c.163.com", "https://hub-mirror.c.163.com")
+
+ o = section_dockerman:taboption("daemon", ListValue, "log_level",
+ translate("Log Level"),
+ translate('Set the logging level'))
+ o:value("debug", "debug")
+ o:value("info", "info")
+ o:value("warn", "warn")
+ o:value("error", "error")
+ o:value("fatal", "fatal")
+
+ o = section_dockerman:taboption("daemon", DynamicList, "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'))
+ o:value("unix:///var/run/docker.sock", "unix:///var/run/docker.sock")
+ o:value("tcp://0.0.0.0:2375", "tcp://0.0.0.0:2375")
+ o.rmempty = true
end
+
return map_dockerman
diff --git a/applications/luci-app-dockerman/luasrc/model/docker.lua b/applications/luci-app-dockerman/luasrc/model/docker.lua
index e62454a8f..999c4c63d 100644
--- a/applications/luci-app-dockerman/luasrc/model/docker.lua
+++ b/applications/luci-app-dockerman/luasrc/model/docker.lua
@@ -222,22 +222,22 @@ end
_docker.new = function(option)
local option = option or {}
- local remote = uci:get("dockerman", "local", "remote_endpoint")
+ local remote = uci:get("dockerd", "globals", "remote_endpoint")
options = {
- host = (remote == "true") and (option.host or uci:get("dockerman", "local", "remote_host")) or nil,
- port = (remote == "true") and (option.port or uci:get("dockerman", "local", "remote_port")) or nil,
- debug = option.debug or uci:get("dockerman", "local", "debug") == 'true' and true or false,
- debug_path = option.debug_path or uci:get("dockerman", "local", "debug_path")
+ host = (remote == "true") and (option.host or uci:get("dockerd", "globals", "remote_host")) or nil,
+ port = (remote == "true") and (option.port or uci:get("dockerd", "globals", "remote_port")) or nil,
+ debug = option.debug or uci:get("dockerd", "globals", "debug") == 'true' and true or false,
+ debug_path = option.debug_path or uci:get("dockerd", "globals", "debug_path") or "/tmp/.docker_debug"
}
- options.socket_path = (remote ~= "true" or not options.host or not options.port) and (option.socket_path or uci:get("dockerman", "local", "socket_path") or "/var/run/docker.sock") or nil
+ options.socket_path = (remote ~= "true" or not options.host or not options.port) and (option.socket_path or uci:get("dockerd", "globals", "socket_path") or "/var/run/docker.sock") or nil
local _new = docker.new(options)
- _new.options.status_path = uci:get("dockerman", "local", "status_path")
+ _new.options.status_path = uci:get("dockerd", "globals", "status_path") or "/tmp/.docker_status"
_new.containers_upgrade = upgrade
_new.containers_duplicate_config = duplicate_config
return _new
end
_docker.options={}
-_docker.options.status_path = uci:get("dockerman", "local", "status_path")
+_docker.options.status_path = uci:get("dockerd", "globals", "status_path") or "/tmp/.docker_status"
_docker.append_status=function(self,val)
if not val then return end
@@ -330,7 +330,7 @@ end
_docker.create_macvlan_interface = function(name, device, gateway, subnet)
if not nixio.fs.access("/etc/config/network") or not nixio.fs.access("/etc/config/firewall") then return end
- if uci:get("dockerman", "local", "remote_endpoint") == "true" then return end
+ if uci:get("dockerd", "globals", "remote_endpoint") == "true" then return end
local ip = require "luci.ip"
local if_name = "docker_"..name
local dev_name = "macvlan_"..name
@@ -371,7 +371,7 @@ end
_docker.remove_macvlan_interface = function(name)
if not nixio.fs.access("/etc/config/network") or not nixio.fs.access("/etc/config/firewall") then return end
- if uci:get("dockerman", "local", "remote_endpoint") == "true" then return end
+ if uci:get("dockerd", "globals", "remote_endpoint") == "true" then return end
local if_name = "docker_"..name
local dev_name = "macvlan_"..name
uci:foreach("firewall", "zone", function(s)
diff --git a/applications/luci-app-dockerman/root/usr/share/rpcd/acl.d/luci-app-dockerman.json b/applications/luci-app-dockerman/root/usr/share/rpcd/acl.d/luci-app-dockerman.json
index ba1a10c60..353ccaa16 100644
--- a/applications/luci-app-dockerman/root/usr/share/rpcd/acl.d/luci-app-dockerman.json
+++ b/applications/luci-app-dockerman/root/usr/share/rpcd/acl.d/luci-app-dockerman.json
@@ -2,10 +2,10 @@
"luci-app-dockerman": {
"description": "Grant UCI access for luci-app-dockerman",
"read": {
- "uci": [ "dockerman" ]
+ "uci": [ "dockerd" ]
},
"write": {
- "uci": [ "dockerman" ]
+ "uci": [ "dockerd" ]
}
}
}