diff --git a/applications/luci-app-socat/Makefile b/applications/luci-app-socat/Makefile index 523c05780a0..64f5454804d 100644 --- a/applications/luci-app-socat/Makefile +++ b/applications/luci-app-socat/Makefile @@ -5,11 +5,15 @@ include $(TOPDIR)/rules.mk +PKG_VERSION:=20220823-1 +PKG_RELEASE:= LUCI_TITLE:=LuCI support for Socat LUCI_DEPENDS:=+socat LUCI_PKGARCH:=all -PKG_RELEASE:=3 -PKG_DATE:=20200824 + +define Package/luci-app-socat/conffiles +/etc/config/socat_luci +endef include ../../luci.mk diff --git a/applications/luci-app-socat/luasrc/controller/socat.lua b/applications/luci-app-socat/luasrc/controller/socat.lua index 88498e99985..9caea41233b 100644 --- a/applications/luci-app-socat/luasrc/controller/socat.lua +++ b/applications/luci-app-socat/luasrc/controller/socat.lua @@ -3,7 +3,7 @@ module("luci.controller.socat", package.seeall) local http = require "luci.http" function index() - if not nixio.fs.access("/etc/config/socat") then return end + if not nixio.fs.access("/etc/config/socat_luci") then return end entry({"admin", "network", "socat"}, cbi("socat/index"), _("Socat"), 100).acl_depends = { "luci-app-socat" } entry({"admin", "network", "socat", "config"}, cbi("socat/config")).leaf = true diff --git a/applications/luci-app-socat/luasrc/model/cbi/socat/config.lua b/applications/luci-app-socat/luasrc/model/cbi/socat/config.lua index afbc0849b23..5cc0e0b2221 100644 --- a/applications/luci-app-socat/luasrc/model/cbi/socat/config.lua +++ b/applications/luci-app-socat/luasrc/model/cbi/socat/config.lua @@ -1,6 +1,6 @@ local d = require "luci.dispatcher" -m = Map("socat", translate("Socat Config")) +m = Map("socat_luci", translate("Socat Config")) m.redirect = d.build_url("admin", "network", "socat") s = m:section(NamedSection, arg[1], "config", "") diff --git a/applications/luci-app-socat/luasrc/model/cbi/socat/index.lua b/applications/luci-app-socat/luasrc/model/cbi/socat/index.lua index 0bc520e45c1..f224062980c 100644 --- a/applications/luci-app-socat/luasrc/model/cbi/socat/index.lua +++ b/applications/luci-app-socat/luasrc/model/cbi/socat/index.lua @@ -1,7 +1,7 @@ local d = require "luci.dispatcher" local e = luci.model.uci.cursor() -m = Map("socat", translate("Socat"), translate("Socat is a versatile networking tool named after 'Socket CAT', which can be regarded as an N-fold enhanced version of NetCat")) +m = Map("socat_luci", translate("Socat"), translate("Socat is a versatile networking tool named after 'Socket CAT', which can be regarded as an N-fold enhanced version of NetCat")) s = m:section(NamedSection, "global", "global") s.anonymous = true diff --git a/applications/luci-app-socat/root/etc/config/socat b/applications/luci-app-socat/root/etc/config/socat_luci similarity index 100% rename from applications/luci-app-socat/root/etc/config/socat rename to applications/luci-app-socat/root/etc/config/socat_luci diff --git a/applications/luci-app-socat/root/etc/init.d/socat b/applications/luci-app-socat/root/etc/init.d/socat_luci similarity index 97% rename from applications/luci-app-socat/root/etc/init.d/socat rename to applications/luci-app-socat/root/etc/init.d/socat_luci index 579db57f54e..064286f2295 100755 --- a/applications/luci-app-socat/root/etc/init.d/socat +++ b/applications/luci-app-socat/root/etc/init.d/socat_luci @@ -97,13 +97,13 @@ stop_service() { } start() { - enable=$(uci -q get $CONFIG.@global[0].enable) + enable=$(uci -q get socat_luci.@global[0].enable) if [ "$enable" = "0" ];then stop_service else mkdir -p $CONFIG_PATH add_rule - config_load $CONFIG + config_load socat_luci config_foreach run_service "config" gen_include fi diff --git a/applications/luci-app-socat/root/etc/uci-defaults/luci-app-socat b/applications/luci-app-socat/root/etc/uci-defaults/luci-app-socat index 431f8756c31..3cf5d0b3d28 100755 --- a/applications/luci-app-socat/root/etc/uci-defaults/luci-app-socat +++ b/applications/luci-app-socat/root/etc/uci-defaults/luci-app-socat @@ -1,17 +1,31 @@ #!/bin/sh +if grep -q '^config config ' /etc/config/socat && ! grep -q '^config config ' /etc/config/socat_luci; then + echo >>/etc/config/socat_luci + cat /etc/config/socat >>/etc/config/socat_luci +fi + +uci -q get socat_luci.global >/dev/null || uci -q batch <<-EOF >/dev/null + set socat_luci.global=global + set socat_luci.global.enable=1 + commit socat_luci +EOF + uci -q batch <<-EOF >/dev/null delete firewall.socat set firewall.socat=include set firewall.socat.type=script set firewall.socat.path=/var/etc/socat.include set firewall.socat.reload=1 + commit firewall EOF +/etc/init.d/socat_luci enable + uci -q batch <<-EOF >/dev/null - delete ucitrack.@socat[-1] - add ucitrack socat - set ucitrack.@socat[-1].init=socat + delete ucitrack.@socat_luci[-1] + add ucitrack socat_luci + set ucitrack.@socat_luci[-1].init=socat_luci commit ucitrack EOF diff --git a/applications/luci-app-socat/root/usr/share/rpcd/acl.d/luci-app-socat.json b/applications/luci-app-socat/root/usr/share/rpcd/acl.d/luci-app-socat.json index a79e14a5525..be3ef017a71 100644 --- a/applications/luci-app-socat/root/usr/share/rpcd/acl.d/luci-app-socat.json +++ b/applications/luci-app-socat/root/usr/share/rpcd/acl.d/luci-app-socat.json @@ -2,10 +2,10 @@ "luci-app-socat": { "description": "Grant UCI access for luci-app-socat", "read": { - "uci": [ "socat" ] + "uci": [ "socat_luci" ] }, "write": { - "uci": [ "socat" ] + "uci": [ "socat_luci" ] } } }