From e63da7d9724cee74dc237129ff2e15342c6a455d Mon Sep 17 00:00:00 2001 From: danrl Date: Fri, 17 Feb 2017 11:06:06 +0100 Subject: [PATCH] utils/luci-app-lxc: removed application Moved over to the LuCI repository. Signed-off-by: Dan Luedtke --- utils/luci-app-lxc/Makefile | 68 --- utils/luci-app-lxc/files/controller/lxc.lua | 167 ------- utils/luci-app-lxc/files/lxc.config | 6 - utils/luci-app-lxc/files/model/cbi/lxc.lua | 31 -- utils/luci-app-lxc/files/view/lxc.htm | 458 ------------------ .../www/luci-static/resources/cbi/green.gif | Bin 310 -> 0 bytes .../www/luci-static/resources/cbi/purple.gif | Bin 317 -> 0 bytes .../www/luci-static/resources/cbi/red.gif | Bin 320 -> 0 bytes 8 files changed, 730 deletions(-) delete mode 100644 utils/luci-app-lxc/Makefile delete mode 100644 utils/luci-app-lxc/files/controller/lxc.lua delete mode 100644 utils/luci-app-lxc/files/lxc.config delete mode 100644 utils/luci-app-lxc/files/model/cbi/lxc.lua delete mode 100644 utils/luci-app-lxc/files/view/lxc.htm delete mode 100644 utils/luci-app-lxc/files/www/luci-static/resources/cbi/green.gif delete mode 100644 utils/luci-app-lxc/files/www/luci-static/resources/cbi/purple.gif delete mode 100644 utils/luci-app-lxc/files/www/luci-static/resources/cbi/red.gif diff --git a/utils/luci-app-lxc/Makefile b/utils/luci-app-lxc/Makefile deleted file mode 100644 index 026f714cdf..0000000000 --- a/utils/luci-app-lxc/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (C) 2014 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-lxc -PKG_RELEASE:=20161030 - -PKG_LICENSE:=Apache-2.0 - -PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) - -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-lxc - SECTION:=luci - CATEGORY:=LuCI - SUBMENU:=3. Applications - TITLE:=LXC management Web UI - DEPENDS:=+luci-mod-admin-full +lxc +lxc-create +liblxc +rpcd-mod-lxc +getopt +xz - MAINTAINER:=Petar Koretic -endef - -define Package/luci-app-lxc/description - This package will install LXC management Web UI. -endef - -define Build/Prepare -endef - -define Build/Configure -endef - -define Build/Compile -endef - -define Package/luci-app-lxc/install - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/ - $(INSTALL_BIN) \ - ./files/controller/lxc.lua \ - $(1)/usr/lib/lua/luci/controller/ - - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/ - $(INSTALL_DATA) \ - ./files/view/lxc.htm \ - $(1)/usr/lib/lua/luci/view/ - - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/ - $(INSTALL_BIN) \ - ./files/model/cbi/lxc.lua \ - $(1)/usr/lib/lua/luci/model/cbi/ - - $(INSTALL_DIR) $(1)/etc/config/ - $(INSTALL_DATA) \ - ./files/lxc.config \ - $(1)/etc/config/lxc - - $(INSTALL_DIR) $(1)/www - $(CP) -R \ - ./files/www/* \ - $(1)/www -endef - -$(eval $(call BuildPackage,luci-app-lxc)) diff --git a/utils/luci-app-lxc/files/controller/lxc.lua b/utils/luci-app-lxc/files/controller/lxc.lua deleted file mode 100644 index ea7adbafbb..0000000000 --- a/utils/luci-app-lxc/files/controller/lxc.lua +++ /dev/null @@ -1,167 +0,0 @@ ---[[ - -LuCI LXC module - -Copyright (C) 2014, Cisco Systems, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Author: Petar Koretic - -]]-- - -module("luci.controller.lxc", package.seeall) - -require "ubus" -local conn = ubus.connect() -if not conn then - error("Failed to connect to ubus") -end - - -function fork_exec(command) - local pid = nixio.fork() - if pid > 0 then - return - elseif pid == 0 then - -- change to root dir - nixio.chdir("/") - - -- patch stdin, out, err to /dev/null - local null = nixio.open("/dev/null", "w+") - if null then - nixio.dup(null, nixio.stderr) - nixio.dup(null, nixio.stdout) - nixio.dup(null, nixio.stdin) - if null:fileno() > 2 then - null:close() - end - end - - -- replace with target command - nixio.exec("/bin/sh", "-c", command) - end -end - -function index() - page = node("admin", "services", "lxc") - page.target = cbi("lxc") - page.title = _("LXC Containers") - page.order = 70 - - page = entry({"admin", "services", "lxc_create"}, call("lxc_create"), nil) - page.leaf = true - - page = entry({"admin", "services", "lxc_action"}, call("lxc_action"), nil) - page.leaf = true - - page = entry({"admin", "services", "lxc_get_downloadable"}, call("lxc_get_downloadable"), nil) - page.leaf = true - - page = entry({"admin", "services", "lxc_configuration_get"}, call("lxc_configuration_get"), nil) - page.leaf = true - - page = entry({"admin", "services", "lxc_configuration_set"}, call("lxc_configuration_set"), nil) - page.leaf = true - -end - -function lxc_get_downloadable() - luci.http.prepare_content("application/json") - - local f = io.popen('uname -m', 'r') - local target = f:read('*a') - f:close() - target = target:gsub("^%s*(.-)%s*$", "%1") - - local templates = {} - - local f = io.popen('lxc-create -n just_want_to_list_available_lxc_templates -t download -- --list', 'r') - - for line in f:lines() do - local dist,version = line:match("^(%S+)%s+(%S+)%s+" .. target .. "%s+default%s+%S+$") - if dist~=nil and version~=nil then templates[#templates + 1] = dist .. ":" .. version end - end - - f:close() - luci.http.write_json(templates) -end - -function lxc_create(lxc_name, lxc_template) - luci.http.prepare_content("text/plain") - - local uci = require("uci").cursor() - - local url = uci:get("lxc", "lxc", "url") - - if not pcall(dofile, "/etc/openwrt_release") then - return luci.http.write("1") - end - - local f = io.popen('uname -m', 'r') - local target = f:read('*a') - f:close() - target = target:gsub("^%s*(.-)%s*$", "%1") - - local lxc_dist = lxc_template:gsub("(.*):(.*)", '%1') - local lxc_release = lxc_template:gsub("(.*):(.*)", '%2') - - local data = conn:call("lxc", "create", { name = lxc_name, template = "download", args = { "--server", url, "--no-validate", "--dist", lxc_dist, "--release", lxc_release, "--arch", target } } ) - - luci.http.write(data) -end - -function lxc_action(lxc_action, lxc_name) - luci.http.prepare_content("application/json") - - local data, ec = conn:call("lxc", lxc_action, lxc_name and { name = lxc_name} or {} ) - - luci.http.write_json(ec and {} or data) -end - -function lxc_get_config_path() - local f = io.open("/etc/lxc/lxc.conf", "r") - local content = f:read("*all") - f:close() - local ret = content:match('^%s*lxc.lxcpath%s*=%s*([^%s]*)') - if ret then - return ret .. "/" - else - return "/srv/lxc/" - end -end - -function lxc_configuration_get(lxc_name) - luci.http.prepare_content("text/plain") - - local f = io.open(lxc_get_config_path() .. lxc_name .. "/config", "r") - local content = f:read("*all") - f:close() - - luci.http.write(content) -end - -function lxc_configuration_set(lxc_name) - luci.http.prepare_content("text/plain") - - local lxc_configuration = luci.http.formvalue("lxc_configuration") - - if lxc_configuration == nil then - return luci.http.write("1") - end - - local f, err = io.open(lxc_get_config_path() .. lxc_name .. "/config","w+") - if not f then - return luci.http.write("2") - end - - f:write(lxc_configuration) - f:close() - - luci.http.write("0") -end - diff --git a/utils/luci-app-lxc/files/lxc.config b/utils/luci-app-lxc/files/lxc.config deleted file mode 100644 index 5572c735fa..0000000000 --- a/utils/luci-app-lxc/files/lxc.config +++ /dev/null @@ -1,6 +0,0 @@ -# -# lxc uci configuration -# - -config lxc 'lxc' - option url 'virtualwrt.org/containers/' diff --git a/utils/luci-app-lxc/files/model/cbi/lxc.lua b/utils/luci-app-lxc/files/model/cbi/lxc.lua deleted file mode 100644 index ac0fdff332..0000000000 --- a/utils/luci-app-lxc/files/model/cbi/lxc.lua +++ /dev/null @@ -1,31 +0,0 @@ ---[[ - -LuCI LXC module - -Copyright (C) 2014, Cisco Systems, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Author: Petar Koretic - -]]-- - -local fs = require "nixio.fs" - -m = Map("lxc", translate("LXC Containers")) - -if fs.access("/etc/config/lxc") then - m:section(SimpleSection).template = "lxc" - - s = m:section(TypedSection, "lxc", translate("Options")) - s.anonymous = true - s.addremove = false - - s:option(Value, "url", translate("Containers URL")) -end - -return m diff --git a/utils/luci-app-lxc/files/view/lxc.htm b/utils/luci-app-lxc/files/view/lxc.htm deleted file mode 100644 index edfff8e063..0000000000 --- a/utils/luci-app-lxc/files/view/lxc.htm +++ /dev/null @@ -1,458 +0,0 @@ -<%# - -LuCI LXC module - -Copyright (C) 2014, Cisco Systems, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Author: Petar Koretic - --%> - -
- <%:Available Containers%> -
- - - - - - -
<%:Name%><%:Status%><%:Actions%>
-
-
- -
- -
- -
-
- <%:Create New Container%> -
- - - - - - - - - - - -
<%:Name%><%:Template%><%:Actions%>
- - - - - - -
-
-
- -
- -
- -
- - - diff --git a/utils/luci-app-lxc/files/www/luci-static/resources/cbi/green.gif b/utils/luci-app-lxc/files/www/luci-static/resources/cbi/green.gif deleted file mode 100644 index d09febf1273b9a20ed89f69b19c9837c325b6db2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 310 zcmV-60m=SHNk%w1VG;lm0K^{vZ~bkE`i3IOOtAj1%l^tt)@2&AVF&*PSoufY_~E|k z)JgwHS>#w4z1r7`qnUWO@4hjMkkD&(? z0tz3V7O9d47M&sq1`M&7ve%u0>iE{m+T+XZwTj1Er9cj@j0>9S$296cLx79uX8676b;Mmj(nD z0vijDs2vL%0v{X*39y$P2?!h_5Df&mpS%PO5F-K&7<&n-5d+>4 S5eN;-E)Uxq8{)YwApkob^ml{+ -- 2.30.2