Browse Source

luci-app-squid: add package

Signed-off-by: Marko Ratkaj <marko.ratkaj@sartura.hr>
Marko Ratkaj 9 years ago
parent
commit
1fac9ac756

+ 53
- 0
net/luci-app-squid/Makefile View File

@@ -0,0 +1,53 @@
1
+#
2
+# Copyright (C) 2015 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=luci-app-squid
11
+PKG_RELEASE:=20150608
12
+
13
+PKG_LICENSE:=Apache-2.0
14
+
15
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
16
+
17
+include $(INCLUDE_DIR)/package.mk
18
+
19
+define Package/luci-app-squid
20
+  SECTION:=luci
21
+  CATEGORY:=LuCI
22
+  SUBMENU:=3. Applications
23
+  TITLE:=Squid Web UI
24
+  DEPENDS:=+luci-mod-admin-full +squid
25
+  MAINTAINER:=Marko Ratkaj <marko.ratkaj@sartura.hr>
26
+endef
27
+
28
+define Package/luci-app-squid/description
29
+ This package will install Squid Web UI.
30
+endef
31
+
32
+define Build/Prepare
33
+endef
34
+
35
+define Build/Configure
36
+endef
37
+
38
+define Build/Compile
39
+endef
40
+
41
+define Package/luci-app-squid/install
42
+	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/
43
+	$(INSTALL_BIN) \
44
+		./files/squid-controller.lua \
45
+		$(1)/usr/lib/lua/luci/controller/squid.lua
46
+
47
+	$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/
48
+	$(INSTALL_BIN) \
49
+		./files//squid-cbi.lua \
50
+		$(1)/usr/lib/lua/luci/model/cbi/squid.lua
51
+endef
52
+
53
+$(eval $(call BuildPackage,luci-app-squid))

+ 67
- 0
net/luci-app-squid/files/squid-cbi.lua View File

@@ -0,0 +1,67 @@
1
+--[[
2
+
3
+LuCI Squid module
4
+
5
+Copyright (C) 2015, OpenWrt.org
6
+
7
+Licensed under the Apache License, Version 2.0 (the "License");
8
+you may not use this file except in compliance with the License.
9
+You may obtain a copy of the License at
10
+
11
+	http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+Author: Marko Ratkaj <marko.ratkaj@sartura.hr>
14
+
15
+]]--
16
+
17
+local fs = require "nixio.fs"
18
+local sys = require "luci.sys"
19
+require "ubus"
20
+
21
+m = Map("squid", translate("Squid"))
22
+m.on_after_commit = function() luci.sys.call("/etc/init.d/squid restart") end
23
+
24
+s = m:section(TypedSection, "squid")
25
+s.anonymous = true
26
+s.addremove = false
27
+
28
+s:tab("general", translate("General Settings"))
29
+
30
+http_port = s:taboption("general", Value, "http_port", translate("Port"))
31
+http_port.datatype = "portrange"
32
+http_port.placeholder = "0-65535"
33
+
34
+visible_hostname = s:taboption("general", Value, "visible_hostname", translate("Visible Hostname"))
35
+visible_hostname.datatype="string"
36
+visible_hostname.placeholder = "OpenWrt"
37
+
38
+coredump_dir = s:taboption("general", Value, "coredump_dir", translate("Coredump files directory"))
39
+coredump_dir.datatype="string"
40
+coredump_dir.placeholder = "/tmp/squid"
41
+
42
+s:tab("advanced", translate("Advanced Settings"))
43
+
44
+squid_config_file = s:taboption("advanced", TextValue, "_data", "")
45
+squid_config_file.wrap = "off"
46
+squid_config_file.rows = 25
47
+squid_config_file.rmempty = false
48
+
49
+function squid_config_file.cfgvalue()
50
+	local uci = require "luci.model.uci".cursor_state()
51
+	local file = uci:get("squid", "squid", "config_file")
52
+	if file then
53
+		return fs.readfile(file) or ""
54
+	else
55
+		return ""
56
+	end
57
+end
58
+
59
+function squid_config_file.write(self, section, value)
60
+    if value then
61
+		local uci = require "luci.model.uci".cursor_state()
62
+		local file = uci:get("squid", "squid", "config_file")
63
+	fs.writefile(file, value:gsub("\r\n", "\n"))
64
+    end
65
+end
66
+
67
+return m

+ 21
- 0
net/luci-app-squid/files/squid-controller.lua View File

@@ -0,0 +1,21 @@
1
+--[[
2
+
3
+LuCI Squid module
4
+
5
+Copyright (C) 2015, OpenWrt.org
6
+
7
+Licensed under the Apache License, Version 2.0 (the "License");
8
+you may not use this file except in compliance with the License.
9
+You may obtain a copy of the License at
10
+
11
+	http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+Author: Marko Ratkaj <marko.ratkaj@sartura.hr>
14
+
15
+]]--
16
+
17
+module("luci.controller.squid", package.seeall)
18
+
19
+function index()
20
+	entry({"admin", "services", "squid"}, cbi("squid"), _("Squid"))
21
+end