luci-app-squid: add package
authorMarko Ratkaj <marko.ratkaj@sartura.hr>
Mon, 8 Jun 2015 13:13:43 +0000 (15:13 +0200)
committerLuka Perkov <luka@openwrt.org>
Tue, 9 Jun 2015 10:18:04 +0000 (12:18 +0200)
Signed-off-by: Marko Ratkaj <marko.ratkaj@sartura.hr>
net/luci-app-squid/Makefile [new file with mode: 0644]
net/luci-app-squid/files/squid-cbi.lua [new file with mode: 0644]
net/luci-app-squid/files/squid-controller.lua [new file with mode: 0644]

diff --git a/net/luci-app-squid/Makefile b/net/luci-app-squid/Makefile
new file mode 100644 (file)
index 0000000..91ce724
--- /dev/null
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2015 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-squid
+PKG_RELEASE:=20150608
+
+PKG_LICENSE:=Apache-2.0
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/luci-app-squid
+  SECTION:=luci
+  CATEGORY:=LuCI
+  SUBMENU:=3. Applications
+  TITLE:=Squid Web UI
+  DEPENDS:=+luci-mod-admin-full +squid
+  MAINTAINER:=Marko Ratkaj <marko.ratkaj@sartura.hr>
+endef
+
+define Package/luci-app-squid/description
+ This package will install Squid Web UI.
+endef
+
+define Build/Prepare
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/luci-app-squid/install
+       $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/
+       $(INSTALL_BIN) \
+               ./files/squid-controller.lua \
+               $(1)/usr/lib/lua/luci/controller/squid.lua
+
+       $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/
+       $(INSTALL_BIN) \
+               ./files//squid-cbi.lua \
+               $(1)/usr/lib/lua/luci/model/cbi/squid.lua
+endef
+
+$(eval $(call BuildPackage,luci-app-squid))
diff --git a/net/luci-app-squid/files/squid-cbi.lua b/net/luci-app-squid/files/squid-cbi.lua
new file mode 100644 (file)
index 0000000..0ac554a
--- /dev/null
@@ -0,0 +1,67 @@
+--[[
+
+LuCI Squid module
+
+Copyright (C) 2015, OpenWrt.org
+
+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: Marko Ratkaj <marko.ratkaj@sartura.hr>
+
+]]--
+
+local fs = require "nixio.fs"
+local sys = require "luci.sys"
+require "ubus"
+
+m = Map("squid", translate("Squid"))
+m.on_after_commit = function() luci.sys.call("/etc/init.d/squid restart") end
+
+s = m:section(TypedSection, "squid")
+s.anonymous = true
+s.addremove = false
+
+s:tab("general", translate("General Settings"))
+
+http_port = s:taboption("general", Value, "http_port", translate("Port"))
+http_port.datatype = "portrange"
+http_port.placeholder = "0-65535"
+
+visible_hostname = s:taboption("general", Value, "visible_hostname", translate("Visible Hostname"))
+visible_hostname.datatype="string"
+visible_hostname.placeholder = "OpenWrt"
+
+coredump_dir = s:taboption("general", Value, "coredump_dir", translate("Coredump files directory"))
+coredump_dir.datatype="string"
+coredump_dir.placeholder = "/tmp/squid"
+
+s:tab("advanced", translate("Advanced Settings"))
+
+squid_config_file = s:taboption("advanced", TextValue, "_data", "")
+squid_config_file.wrap = "off"
+squid_config_file.rows = 25
+squid_config_file.rmempty = false
+
+function squid_config_file.cfgvalue()
+       local uci = require "luci.model.uci".cursor_state()
+       local file = uci:get("squid", "squid", "config_file")
+       if file then
+               return fs.readfile(file) or ""
+       else
+               return ""
+       end
+end
+
+function squid_config_file.write(self, section, value)
+    if value then
+               local uci = require "luci.model.uci".cursor_state()
+               local file = uci:get("squid", "squid", "config_file")
+       fs.writefile(file, value:gsub("\r\n", "\n"))
+    end
+end
+
+return m
diff --git a/net/luci-app-squid/files/squid-controller.lua b/net/luci-app-squid/files/squid-controller.lua
new file mode 100644 (file)
index 0000000..09946a1
--- /dev/null
@@ -0,0 +1,21 @@
+--[[
+
+LuCI Squid module
+
+Copyright (C) 2015, OpenWrt.org
+
+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: Marko Ratkaj <marko.ratkaj@sartura.hr>
+
+]]--
+
+module("luci.controller.squid", package.seeall)
+
+function index()
+       entry({"admin", "services", "squid"}, cbi("squid"), _("Squid"))
+end