From 5b8acb177e3e7aac5f859cadb8d7279031a798d1 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 18 Dec 2024 03:26:39 +0000 Subject: [PATCH] CI: sync code --- luci/luci-app-nfs/Makefile | 18 +++ luci/luci-app-nfs/luasrc/controller/nfs.lua | 10 ++ luci/luci-app-nfs/luasrc/model/cbi/nfs.lua | 70 +++++++++++ luci/luci-app-nfs/po/zh_Hans/nfs.po | 32 +++++ luci/luci-app-nfs/root/etc/config/nfs | 6 + luci/luci-app-nfs/root/etc/init.d/nfs | 75 +++++++++++ .../root/etc/uci-defaults/luci-nfs | 14 +++ luci/luci-app-socat/Makefile | 24 ++++ .../luasrc/controller/socat.lua | 22 ++++ .../luasrc/model/cbi/socat/config.lua | 82 ++++++++++++ .../luasrc/model/cbi/socat/index.lua | 78 ++++++++++++ .../luasrc/view/socat/list_status.htm | 19 +++ .../luasrc/view/socat/status.htm | 3 + luci/luci-app-socat/po/zh_Hans/socat.po | 50 ++++++++ luci/luci-app-socat/root/etc/config/socat | 3 + .../luci-app-socat/root/etc/init.d/luci_socat | 119 ++++++++++++++++++ .../root/etc/uci-defaults/luci-app-socat | 19 +++ main.sh | 10 ++ 18 files changed, 654 insertions(+) create mode 100644 luci/luci-app-nfs/Makefile create mode 100644 luci/luci-app-nfs/luasrc/controller/nfs.lua create mode 100644 luci/luci-app-nfs/luasrc/model/cbi/nfs.lua create mode 100644 luci/luci-app-nfs/po/zh_Hans/nfs.po create mode 100644 luci/luci-app-nfs/root/etc/config/nfs create mode 100755 luci/luci-app-nfs/root/etc/init.d/nfs create mode 100755 luci/luci-app-nfs/root/etc/uci-defaults/luci-nfs create mode 100644 luci/luci-app-socat/Makefile create mode 100644 luci/luci-app-socat/luasrc/controller/socat.lua create mode 100644 luci/luci-app-socat/luasrc/model/cbi/socat/config.lua create mode 100644 luci/luci-app-socat/luasrc/model/cbi/socat/index.lua create mode 100644 luci/luci-app-socat/luasrc/view/socat/list_status.htm create mode 100644 luci/luci-app-socat/luasrc/view/socat/status.htm create mode 100644 luci/luci-app-socat/po/zh_Hans/socat.po create mode 100644 luci/luci-app-socat/root/etc/config/socat create mode 100755 luci/luci-app-socat/root/etc/init.d/luci_socat create mode 100755 luci/luci-app-socat/root/etc/uci-defaults/luci-app-socat diff --git a/luci/luci-app-nfs/Makefile b/luci/luci-app-nfs/Makefile new file mode 100644 index 0000000..8c0d909 --- /dev/null +++ b/luci/luci-app-nfs/Makefile @@ -0,0 +1,18 @@ +# Copyright (C) 2016 Openwrt.org +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support for nfs +LUCI_DEPENDS:=+nfs-utils +nfs-kernel-server +nfs-kernel-server-utils +mount-utils +LUCI_PKGARCH:=all + +PKG_NAME:=luci-app-nfs +PKG_VERSION:=1.1 +PKG_RELEASE:=1 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci/luci-app-nfs/luasrc/controller/nfs.lua b/luci/luci-app-nfs/luasrc/controller/nfs.lua new file mode 100644 index 0000000..e09b120 --- /dev/null +++ b/luci/luci-app-nfs/luasrc/controller/nfs.lua @@ -0,0 +1,10 @@ +module("luci.controller.nfs", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/nfs") then + return + end + + entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false + entry({"admin", "nas", "nfs"}, cbi("nfs"), _("NFS Manage"), 5).dependent = true +end diff --git a/luci/luci-app-nfs/luasrc/model/cbi/nfs.lua b/luci/luci-app-nfs/luasrc/model/cbi/nfs.lua new file mode 100644 index 0000000..6dabbe4 --- /dev/null +++ b/luci/luci-app-nfs/luasrc/model/cbi/nfs.lua @@ -0,0 +1,70 @@ +local fs = require "nixio.fs" + +m = Map("nfs", translate("NFS Manage")) + +-- NFS Share -- +s = m:section(TypedSection, "share", translate("Shared Directories")) +s.anonymous = true +s.addremove = true +s.template = "cbi/tblsection" + +en = s:option(Flag, "enabled", translate("Enable")) +en.rmempty = false +en.default = "1" + +ph1 = s:option(Value, "path", translate("Path")) +ph1.placeholder = "/mnt" +ph1.rmempty = false +ph1.optional = false + +ct = s:option(Value, "clients", translate("Clients")) +ct.placeholder = "192.168.1.0/24" +ct.rmempty = false +ct.optional = false + +op = s:option(Value, "options", translate("options")) +op.placeholder = "rw,sync,root_squash,all_squash,insecure,no_subtree_check" +op.rmempty = false +op.optional = false + +-- NFS Mount -- +c = m:section(TypedSection, "mount", translate("Mounted Points")) +c.anonymous = true +c.addremove = true +c.template = "cbi/tblsection" + +en = c:option(Flag, "enabled", translate("Enable")) +en.default = "1" +en.rmempty = false + +sr = c:option(Value, "source", translate("source")) +sr.placeholder = "192.168.1.1:/mnt/*" +sr.rmempty = false +sr.optional = false + +ph2 = c:option(Value, "target", translate("target")) +ph2.placeholder = "/mnt/nfs/*" +ph2.rmempty = false +ph2.optional = false + +op = c:option(Value, "options", translate("options")) +op.placeholder = "rw,nolock" +op.rmempty = false +op.optional = false + +de = c:option(Value, "delay", translate("delay")) +de.placeholder = "5" +de.rmempty = false +de.optional = false + +if nixio.fs.access("/etc/config/fstab") then + ph1.titleref = luci.dispatcher.build_url("admin", "system", "fstab") + ph2.titleref = luci.dispatcher.build_url("admin", "system", "fstab") +end + +local apply = luci.http.formvalue("cbi.apply") +if apply then + io.popen("/etc/init.d/nfs reload") +end + +return m diff --git a/luci/luci-app-nfs/po/zh_Hans/nfs.po b/luci/luci-app-nfs/po/zh_Hans/nfs.po new file mode 100644 index 0000000..e35c2e8 --- /dev/null +++ b/luci/luci-app-nfs/po/zh_Hans/nfs.po @@ -0,0 +1,32 @@ +msgid "" +msgstr "" + +msgid "NFS Manage" +msgstr "NFS 管理" + +msgid "Shared Directories" +msgstr "共享目录" + +msgid "Enable" +msgstr "启用" + +msgid "Path" +msgstr "路径" + +msgid "Clients" +msgstr "允许的客户端" + +msgid "Mounted Points" +msgstr "已挂载的目录" + +msgid "source" +msgstr "源目录" + +msgid "target" +msgstr "挂载到" + +msgid "options" +msgstr "选项" + +msgid "delay" +msgstr "延迟时间" diff --git a/luci/luci-app-nfs/root/etc/config/nfs b/luci/luci-app-nfs/root/etc/config/nfs new file mode 100644 index 0000000..7395846 --- /dev/null +++ b/luci/luci-app-nfs/root/etc/config/nfs @@ -0,0 +1,6 @@ + +config share + option enabled '0' + option path '/mnt' + option clients '*' + option options 'rw,sync,root_squash,all_squash,insecure,no_subtree_check' diff --git a/luci/luci-app-nfs/root/etc/init.d/nfs b/luci/luci-app-nfs/root/etc/init.d/nfs new file mode 100755 index 0000000..889d121 --- /dev/null +++ b/luci/luci-app-nfs/root/etc/init.d/nfs @@ -0,0 +1,75 @@ +#!/bin/sh /etc/rc.common +START=45 +STOP=99 +NAME="nfs" + +nfs_share() { + + local enabled path clients options + config_get_bool enabled "$1" enabled 0 + for opt in path clients options + do + config_get "$opt" "$1" "$opt" + done + + if [ "$enabled" = 1 ]; then + grep -qs $path /etc/exports + if [ $? -ne 0 ]; then + echo -e "$path\t$clients($options)" >>/etc/exports + exportfs -r + fi + elif [ "$enabled" = 0 ]; then + exportfs -u | grep -qs $path + if [ $? -eq 0 ]; then + exportfs -u $clients:$path + fi + fi + exportfs -r +} + +nfs_share_stop() { + exportfs -au &>/dev/null +} + +nfs_mount() { + + local enabled target source options delay + config_get_bool enabled "$1" enabled 0 + for opt in target source options delay + do + config_get "$opt" "$1" "$opt" + done + + if [ "$enabled" = 1 ]; then + if [ "$delay" -a $delay -gt 0 ]; then + logger "NetMount: Sleep $delay seconds before mount" + sleep $delay + fi + grep -qs $target /proc/mounts + if [ $? -ne 0 ]; then + mkdir -p $target + logger "NetMount: Mounting $source in $target" + mount -t nfs -o $options $source $target + fi + elif [ "$enabled" = 0 ]; then + if grep -qs $target /proc/mounts; then + umount -fr $target + sleep $delay + fi + fi +} + +start() { + config_load "$NAME" + config_foreach nfs_share share + config_foreach nfs_mount mount +} + +stop() { + nfs_share_stop +} + +restart() { + echo > /etc/exports + start +} diff --git a/luci/luci-app-nfs/root/etc/uci-defaults/luci-nfs b/luci/luci-app-nfs/root/etc/uci-defaults/luci-nfs new file mode 100755 index 0000000..f7aa139 --- /dev/null +++ b/luci/luci-app-nfs/root/etc/uci-defaults/luci-nfs @@ -0,0 +1,14 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@nfs[-1] + add ucitrack nfs + set ucitrack.@nfs[-1].init=nfs + commit ucitrack +EOF + +/etc/init.d/nfs enable && /etc/init.d/nfs restart + +rm -f /tmp/luci-indexcache + +exit 0 diff --git a/luci/luci-app-socat/Makefile b/luci/luci-app-socat/Makefile new file mode 100644 index 0000000..1840cec --- /dev/null +++ b/luci/luci-app-socat/Makefile @@ -0,0 +1,24 @@ +# Copyright (C) 2020 Lienol +# +# This is free software, licensed under the GNU General Public License v3. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-socat +PKG_VERSION:=20200824 +PKG_RELEASE:=5 + +PKG_MAINTAINER:=Lienol + +LUCI_TITLE:=LuCI support for Socat +LUCI_DEPENDS:=+socat +LUCI_PKGARCH:=all + +define Package/$(PKG_NAME)/conffiles +/etc/config/socat +endef + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci/luci-app-socat/luasrc/controller/socat.lua b/luci/luci-app-socat/luasrc/controller/socat.lua new file mode 100644 index 0000000..0e42ad6 --- /dev/null +++ b/luci/luci-app-socat/luasrc/controller/socat.lua @@ -0,0 +1,22 @@ +-- Copyright 2020 Lienol + +module("luci.controller.socat", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/socat") then + return + end + + entry({"admin", "network", "socat"}, alias("admin", "network", "socat", "index"), _("Socat"), 100).dependent = true + entry({"admin", "network", "socat", "index"}, cbi("socat/index")).leaf = true + entry({"admin", "network", "socat", "config"}, cbi("socat/config")).leaf = true + entry({"admin", "network", "socat", "status"}, call("act_status")).leaf = true +end + +function act_status() + local e = {} + e.index = luci.http.formvalue("index") + e.status = luci.sys.call(string.format("ps -w | grep -v 'grep' | grep '/var/etc/socat/%s' >/dev/null", luci.http.formvalue("id"))) == 0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/luci/luci-app-socat/luasrc/model/cbi/socat/config.lua b/luci/luci-app-socat/luasrc/model/cbi/socat/config.lua new file mode 100644 index 0000000..afbc084 --- /dev/null +++ b/luci/luci-app-socat/luasrc/model/cbi/socat/config.lua @@ -0,0 +1,82 @@ +local d = require "luci.dispatcher" + +m = Map("socat", translate("Socat Config")) +m.redirect = d.build_url("admin", "network", "socat") + +s = m:section(NamedSection, arg[1], "config", "") +s.addremove = false +s.dynamic = false + +o = s:option(Flag, "enable", translate("Enable")) +o.default = "1" +o.rmempty = false + +o = s:option(Value, "remarks", translate("Remarks")) +o.default = translate("Remarks") +o.rmempty = false + +o = s:option(ListValue, "protocol", translate("Protocol")) +o:value("port_forwards", translate("Port Forwards")) + +o = s:option(ListValue, "family", translate("Restrict to address family")) +o:value("", translate("IPv4 and IPv6")) +o:value("4", translate("IPv4 only")) +o:value("6", translate("IPv6 only")) +o:depends("protocol", "port_forwards") + +o = s:option(ListValue, "proto", translate("Protocol")) +o:value("tcp", "TCP") +o:value("udp", "UDP") +o:depends("protocol", "port_forwards") + +o = s:option(Value, "listen_port", translate("Listen port")) +o.datatype = "portrange" +o.rmempty = false +o:depends("protocol", "port_forwards") + +o = s:option(Flag, "reuseaddr", "reuseaddr", translate("Bind to a port local")) +o.default = "1" +o.rmempty = false + +o = s:option(ListValue, "dest_proto", translate("Destination Protocol")) +o:value("tcp4", "IPv4-TCP") +o:value("udp4", "IPv4-UDP") +o:value("tcp6", "IPv6-TCP") +o:value("udp6", "IPv6-UDP") +o:depends("protocol", "port_forwards") + +dest_ipv4 = s:option(Value, "dest_ipv4", translate("Destination address")) +luci.sys.net.ipv4_hints(function(ip, name) + dest_ipv4:value(ip, "%s (%s)" %{ ip, name }) +end) +function dest_ipv4.cfgvalue(self, section) + return m:get(section, "dest_ip") +end +function dest_ipv4.write(self, section, value) + m:set(section, "dest_ip", value) +end +dest_ipv4:depends("dest_proto", "tcp4") +dest_ipv4:depends("dest_proto", "udp4") + +dest_ipv6 = s:option(Value, "dest_ipv6", translate("Destination address")) +luci.sys.net.ipv6_hints(function(ip, name) + dest_ipv6:value(ip, "%s (%s)" %{ ip, name }) +end) +function dest_ipv6.cfgvalue(self, section) + return m:get(section, "dest_ip") +end +function dest_ipv6.write(self, section, value) + m:set(section, "dest_ip", value) +end +dest_ipv6:depends("dest_proto", "tcp6") +dest_ipv6:depends("dest_proto", "udp6") + +o = s:option(Value, "dest_port", translate("Destination port")) +o.datatype = "portrange" +o.rmempty = false + +o = s:option(Flag, "firewall_accept", translate("Open firewall port")) +o.default = "1" +o.rmempty = false + +return m diff --git a/luci/luci-app-socat/luasrc/model/cbi/socat/index.lua b/luci/luci-app-socat/luasrc/model/cbi/socat/index.lua new file mode 100644 index 0000000..c34e524 --- /dev/null +++ b/luci/luci-app-socat/luasrc/model/cbi/socat/index.lua @@ -0,0 +1,78 @@ +local d = require "luci.dispatcher" +local e = luci.model.uci.cursor() + +m = Map("socat") +m.title = translate("Socat") +m.description = 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 +s.addremove = false + +o = s:option(Flag, "enable", translate("Enable")) +o.rmempty = false + +s = m:section(TypedSection, "config", translate("Port Forwards")) +s.anonymous = true +s.addremove = true +s.template = "cbi/tblsection" +s.extedit = d.build_url("admin", "network", "socat", "config", "%s") +function s.filter(e, t) + if m:get(t, "protocol") == "port_forwards" then + return true + end +end +function s.create(e, t) + local uuid = string.gsub(luci.sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)"), "-", "") + t = uuid + TypedSection.create(e, t) + luci.http.redirect(e.extedit:format(t)) +end +function s.remove(e, t) + e.map.proceed = true + e.map:del(t) + luci.http.redirect(d.build_url("admin", "network", "socat")) +end + +o = s:option(Flag, "enable", translate("Enable")) +o.width = "5%" +o.rmempty = false + +o = s:option(DummyValue, "status", translate("Status")) +o.template = "socat/status" +o.value = translate("Collecting data...") + +o = s:option(DummyValue, "remarks", translate("Remarks")) + +o = s:option(DummyValue, "family", translate("Listen Protocol")) +o.cfgvalue = function(t, n) + local listen = Value.cfgvalue(t, n) or "" + local protocol = (m:get(n, "proto") or ""):upper() + if listen == "" then + return protocol + else + return "IPv" .. listen .. "-" .. protocol + end +end + +o = s:option(DummyValue, "listen_port", translate("Listen port")) + +o = s:option(DummyValue, "dest_proto", translate("Destination Protocol")) +o.cfgvalue = function(t, n) + local listen = Value.cfgvalue(t, n) + local protocol = listen:sub(0, #listen - 1):upper() + local ip_type = "IPv" .. listen:sub(#listen) + return ip_type .. "-" .. protocol +end + +o = s:option(DummyValue, "dest_ip", translate("Destination address")) + +o = s:option(DummyValue, "dest_port", translate("Destination port")) + +o = s:option(Flag, "firewall_accept", translate("Open firewall port")) +o.default = "1" +o.rmempty = false + +m:append(Template("socat/list_status")) + +return m diff --git a/luci/luci-app-socat/luasrc/view/socat/list_status.htm b/luci/luci-app-socat/luasrc/view/socat/list_status.htm new file mode 100644 index 0000000..4da041e --- /dev/null +++ b/luci/luci-app-socat/luasrc/view/socat/list_status.htm @@ -0,0 +1,19 @@ + diff --git a/luci/luci-app-socat/luasrc/view/socat/status.htm b/luci/luci-app-socat/luasrc/view/socat/status.htm new file mode 100644 index 0000000..241baae --- /dev/null +++ b/luci/luci-app-socat/luasrc/view/socat/status.htm @@ -0,0 +1,3 @@ +<%+cbi/valueheader%> +-- +<%+cbi/valuefooter%> diff --git a/luci/luci-app-socat/po/zh_Hans/socat.po b/luci/luci-app-socat/po/zh_Hans/socat.po new file mode 100644 index 0000000..9068b61 --- /dev/null +++ b/luci/luci-app-socat/po/zh_Hans/socat.po @@ -0,0 +1,50 @@ +msgid "Socat" +msgstr "Socat" + +msgid "Socat is a versatile networking tool named after 'Socket CAT', which can be regarded as an N-fold enhanced version of NetCat" +msgstr "Socat 是 Linux 下的一个多功能的网络工具,名字来由是「Socket CAT」。其功能与有瑞士军刀之称的 Netcat 类似,可以看做是 Netcat 的加强版。" + +msgid "Socat Config" +msgstr "Socat 配置" + +msgid "Status" +msgstr "状态" + +msgid "Enabled" +msgstr "启用" + +msgid "Remarks" +msgstr "备注" + +msgid "Protocol" +msgstr "协议" + +msgid "IPv6 Only" +msgstr "仅IPv6" + +msgid "When checked, only IPv6 ports are listen for, otherwise IPv4 will also be listened for." +msgstr "当勾选时,仅监听IPv6,否则将会同时监听IPv4。" + +msgid "Port Forwards" +msgstr "端口转发" + +msgid "Listen Protocol" +msgstr "监听协议" + +msgid "Listen port" +msgstr "监听端口" + +msgid "Bind to a port local" +msgstr "绑定到本地端口" + +msgid "Destination Protocol" +msgstr "目标协议" + +msgid "Destination address" +msgstr "目标地址" + +msgid "Destination port" +msgstr "目标端口" + +msgid "Open firewall port" +msgstr "打开防火墙端口" diff --git a/luci/luci-app-socat/root/etc/config/socat b/luci/luci-app-socat/root/etc/config/socat new file mode 100644 index 0000000..04e4f87 --- /dev/null +++ b/luci/luci-app-socat/root/etc/config/socat @@ -0,0 +1,3 @@ + +config global 'global' + option enable '0' diff --git a/luci/luci-app-socat/root/etc/init.d/luci_socat b/luci/luci-app-socat/root/etc/init.d/luci_socat new file mode 100755 index 0000000..1dcbc04 --- /dev/null +++ b/luci/luci-app-socat/root/etc/init.d/luci_socat @@ -0,0 +1,119 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2020 Lienol + +START=99 + +CONFIG=socat +CONFIG_PATH=/var/etc/$CONFIG + +add_rule() { + iptables -N SOCAT + iptables -I INPUT -j SOCAT + ip6tables -N SOCAT + ip6tables -I INPUT -j SOCAT +} + +del_rule() { + iptables -D INPUT -j SOCAT 2>/dev/null + iptables -F SOCAT 2>/dev/null + iptables -X SOCAT 2>/dev/null + ip6tables -D INPUT -j SOCAT 2>/dev/null + ip6tables -F SOCAT 2>/dev/null + ip6tables -X SOCAT 2>/dev/null +} + +gen_include() { + echo '#!/bin/sh' > /var/etc/$CONFIG.include + extract_rules() { + local _ipt="iptables" + [ "$1" == "6" ] && _ipt="ip6tables" + + echo "*$2" + ${_ipt}-save -t $2 | grep "SOCAT" | \ + sed -e "s/^-A \(INPUT\)/-I \1 1/" + echo 'COMMIT' + } + cat <<-EOF >> /var/etc/$CONFIG.include + iptables-save -c | grep -v "SOCAT" | iptables-restore -c + iptables-restore -n <<-EOT + $(extract_rules 4 filter) + EOT + ip6tables-save -c | grep -v "SOCAT" | ip6tables-restore -c + ip6tables-restore -n <<-EOT + $(extract_rules 6 filter) + EOT + EOF + return 0 +} + +run_service() { + config_get enable $1 enable + [ "$enable" = "0" ] && return 0 + config_get remarks $1 remarks + config_get protocol $1 protocol + config_get family $1 family + config_get proto $1 proto + config_get listen_port $1 listen_port + config_get reuseaddr $1 reuseaddr + config_get dest_proto $1 dest_proto + config_get dest_ip $1 dest_ip + config_get dest_port $1 dest_port + config_get firewall_accept $1 firewall_accept + ln -s /usr/bin/socat ${CONFIG_PATH}/$1 + + if [ "$reuseaddr" == "1" ]; then + reuseaddr=",reuseaddr" + else + reuseaddr="" + fi + + if [ "$family" == "6" ]; then + ipv6only_params=",ipv6-v6only" + else + ipv6only_params="" + fi + + # 端口转发 + if [ "$protocol" == "port_forwards" ]; then + listen=${proto}${family} + [ "$family" == "" ] && listen=${proto}6 + ${CONFIG_PATH}/$1 ${listen}-listen:${listen_port}${ipv6only_params}${reuseaddr},fork ${dest_proto}:${dest_ip}:${dest_port} >/dev/null 2>&1 & + fi + + [ "$firewall_accept" == "1" ] && { + if [ -z "$family" ] || [ "$family" == "6" ]; then + ip6tables -A SOCAT -p $proto --dport $listen_port -m comment --comment "$remarks" -j ACCEPT + fi + if [ -z "$family" ] || [ "$family" == "4" ]; then + iptables -A SOCAT -p $proto --dport $listen_port -m comment --comment "$remarks" -j ACCEPT + fi + } +} + +stop_service() { + ps -w | grep "$CONFIG_PATH/" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 & + del_rule + rm -rf $CONFIG_PATH /var/etc/$CONFIG.include +} + +start() { + enable=$(uci -q get $CONFIG.@global[0].enable) + if [ "$enable" = "0" ];then + stop_service + else + mkdir -p $CONFIG_PATH + add_rule + config_load $CONFIG + config_foreach run_service "config" + gen_include + fi +} + +stop() { + stop_service +} + +restart() { + stop + start +} diff --git a/luci/luci-app-socat/root/etc/uci-defaults/luci-app-socat b/luci/luci-app-socat/root/etc/uci-defaults/luci-app-socat new file mode 100755 index 0000000..d5af4ab --- /dev/null +++ b/luci/luci-app-socat/root/etc/uci-defaults/luci-app-socat @@ -0,0 +1,19 @@ +#!/bin/sh + +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 +EOF + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@socat[-1] + add ucitrack socat + set ucitrack.@socat[-1].init=luci_socat + commit ucitrack +EOF + +rm -rf /tmp/luci-*cache +exit 0 diff --git a/main.sh b/main.sh index 48e54aa..a2e9d0b 100755 --- a/main.sh +++ b/main.sh @@ -50,6 +50,16 @@ function sparse_checkout_lede(){ sparse_checkout $lede_dir "https://github.com/coolsnowwolf/lede" "$lede_pkg" cp -rv $lede_dir/package/lean/ddns-scripts_aliyun/update_aliyun_com.sh package/ddns-scripts-aliyun/files/ + + lede_luci_dir=feeds/coolsnowwolf/luci + lede_luci_pkg="applications/luci-app-socat applications/luci-app-nfs" + sparse_checkout $lede_luci_dir "https://github.com/coolsnowwolf/luci" "$lede_luci_pkg" + + for t in $lede_luci_pkg;do + rm -rf luci/$(basename $t) + cp -rv $lede_luci_dir/$t luci/ + done + } function sparse_checkout_immortalwrt(){