diff --git a/luci-app-gecoosac/Makefile b/luci-app-gecoosac/Makefile new file mode 100644 index 000000000..1e53768a3 --- /dev/null +++ b/luci-app-gecoosac/Makefile @@ -0,0 +1,22 @@ +# Copyright (C) 2016 Openwrt.org +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-gecoosac +PKG_VERSION:=1.0.1 +PKG_RELEASE:=1 + +LUCI_TITLE:=LuCI Support for gecoosac +LUCI_DEPENDS:=+luci-compat +LUCI_PKGARCH:=all + +define Package/$(PKG_NAME)/conffiles +/etc/gecoosac +endef + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-gecoosac/README.md b/luci-app-gecoosac/README.md new file mode 100644 index 000000000..c9f259efb --- /dev/null +++ b/luci-app-gecoosac/README.md @@ -0,0 +1,8 @@ +# Akimio521/luci-app-gecoosac +**集客 AC For OpenWRT** + +在 OpenWRT 中提供集客 AC 控制器 + +来源:[Openwrt插件-集客AC控制器,附Luci源码 | 恩山论坛](https://www.right.com.cn/forum/forum.php?mod=viewthread&tid=8379292) + +**本仓库仅供学习,不提供任何商业用途,若有侵权,请联系我删除** \ No newline at end of file diff --git a/luci-app-gecoosac/luasrc/controller/gecoosac.lua b/luci-app-gecoosac/luasrc/controller/gecoosac.lua new file mode 100644 index 000000000..31d5d482b --- /dev/null +++ b/luci-app-gecoosac/luasrc/controller/gecoosac.lua @@ -0,0 +1,21 @@ +module("luci.controller.gecoosac", package.seeall) +local uci=require"luci.model.uci".cursor() + +function index() + if not nixio.fs.access("/etc/config/gecoosac") then + return + end + entry({"admin", "services"}, firstchild(), _("services") , 45).dependent = false + local page + page = entry({"admin", "services", "gecoosac"}, cbi("gecoosac"), _("集客AC控制器"), 100) + page.dependent = true + entry({"admin","services","gecoosac","status"},call("act_status")).leaf=true +end + +function act_status() + local e={} + local binpath=uci:get("gecoosac","config","program_path") + e.running=luci.sys.call("pgrep "..binpath.." >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/luci-app-gecoosac/luasrc/model/cbi/gecoosac.lua b/luci-app-gecoosac/luasrc/model/cbi/gecoosac.lua new file mode 100644 index 000000000..649a7ddec --- /dev/null +++ b/luci-app-gecoosac/luasrc/model/cbi/gecoosac.lua @@ -0,0 +1,38 @@ +m = Map("gecoosac", translate("集客AC控制器"), translate("用于统一批量管理集客AP的程序。")) + +m:section(SimpleSection).template = "gecoosac/gecoosac_status" + +s = m:section(TypedSection, "gecoosac") +s.addremove = false +s.anonymous = true + +enable = s:option(Flag, "enabled", translate("启用")) +enable.rmempty = false + +o = s:option(Value, "program_path", translate("程序路径")) +o.placeholder = "/usr/bin/gecoosac" +o.default = "/usr/bin/gecoosac" +o.description = translate("可执行文件路径,权限为0755") +o.rmempty = false + +o = s:option(Value, "port", translate("监听端口")) +o.placeholder = 60650 +o.default = 60650 +o.datatype = "port" +o.rmempty = false + +o = s:option(Value, "upload_dir", translate("上传目录")) +o.placeholder = "/etc/gecoosac/upload/" +o.default = "/etc/gecoosac/upload/" +o.rmempty = false + +o = s:option(Value, "db_dir", translate("数据库目录")) +o.placeholder = "/etc/gecoosac/" +o.default = "/etc/gecoosac/" +o.rmempty = false + +o = s:option(Flag, "log", translate("启用日志")) +o.default = 1 +o.rmempty = false + +return m diff --git a/luci-app-gecoosac/luasrc/view/gecoosac/gecoosac_status.htm b/luci-app-gecoosac/luasrc/view/gecoosac/gecoosac_status.htm new file mode 100644 index 000000000..91d7242d6 --- /dev/null +++ b/luci-app-gecoosac/luasrc/view/gecoosac/gecoosac_status.htm @@ -0,0 +1,28 @@ + + +
+

+ <%:Collecting data...%> +

+
diff --git a/luci-app-gecoosac/root/etc/config/gecoosac b/luci-app-gecoosac/root/etc/config/gecoosac new file mode 100644 index 000000000..b3e985078 --- /dev/null +++ b/luci-app-gecoosac/root/etc/config/gecoosac @@ -0,0 +1,9 @@ + +config gecoosac 'config' + option enabled '0' + option program_path '/usr/bin/gecoosac' + option port '60650' + option upload_dir '/etc/gecoosac/upload/' + option db_dir '/etc/gecoosac/' + option log '0' + diff --git a/luci-app-gecoosac/root/etc/init.d/gecoosac b/luci-app-gecoosac/root/etc/init.d/gecoosac new file mode 100644 index 000000000..5e5af6e36 --- /dev/null +++ b/luci-app-gecoosac/root/etc/init.d/gecoosac @@ -0,0 +1,54 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2021 ImmortalWrt + +. /lib/functions.sh +. /lib/functions/procd.sh + +USE_PROCD=1 + +START=90 +STOP=10 + +init_conf() { + config_load "gecoosac" + config_get "program_path" "config" "program_path" "/usr/bin/gecoosac" + config_get "db_dir" "config" "db_dir" "/etc/gecoosac/" + config_get "upload_dir" "config" "upload_dir" "/etc/gecoosac/upload/" + config_get "enabled" "config" "enabled" "0" + config_get "port" "config" "port" "60650" + config_get "log" "config" "log" "0" +} + +start_service() { + init_conf + [ "${enabled}" == "1" ] || return 0 + procd_open_instance gecoosac + + procd_set_param command $program_path + procd_append_param command -f "${upload_dir}" + procd_append_param command -p "${port}" + procd_append_param command -debug "0" + procd_append_param command -dbpath "${db_dir}" + procd_append_param command -token "1" + procd_append_param command -lang "zh" + procd_set_param env GIN_MODE=release + procd_set_param pidfile /var/run/gecoosac.pid + procd_set_param stdout $log + procd_set_param stderr $log + procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5} + procd_close_instance +} + +stop_service(){ + init_conf +} + +reload_service() +{ + stop + start +} + +service_triggers() { + procd_add_reload_trigger "gecoosac" +} diff --git a/luci-app-gecoosac/root/etc/uci-defaults/luci-gecoosac b/luci-app-gecoosac/root/etc/uci-defaults/luci-gecoosac new file mode 100644 index 000000000..36029392d --- /dev/null +++ b/luci-app-gecoosac/root/etc/uci-defaults/luci-gecoosac @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@gecoosac[-1] + add ucitrack gecoosac + set ucitrack.@gecoosac[-1].init=gecoosac + commit ucitrack +EOF + +rm -rf /tmp/luci-* +exit 0 diff --git a/luci-app-gecoosac/root/usr/share/rpcd/acl.d/luci-app-gecoosac.json b/luci-app-gecoosac/root/usr/share/rpcd/acl.d/luci-app-gecoosac.json new file mode 100644 index 000000000..f75f5a887 --- /dev/null +++ b/luci-app-gecoosac/root/usr/share/rpcd/acl.d/luci-app-gecoosac.json @@ -0,0 +1,11 @@ +{ + "luci-app-gecoosac": { + "description": "Grant UCI access for luci-app-gecoosac", + "read": { + "uci": [ "gecoosac" ] + }, + "write": { + "uci": [ "gecoosac" ] + } + } +}