add LuCI support for MentoHUST

This commit is contained in:
sbwml 2023-02-17 17:01:20 +08:00
parent 511de31f9d
commit 2d20a52bb1
9 changed files with 336 additions and 0 deletions

View File

@ -0,0 +1,20 @@
# 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-mentohust
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
LUCI_TITLE:=LuCI support for MentoHUST
LUCI_DEPENDS:=+mentohust
LUCI_PKGARCH:=all
PKG_MAINTAINER:=sbwml <admin@cooluc.com>
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,20 @@
module("luci.controller.mentohust", package.seeall)
function index()
if not nixio.fs.access("/etc/config/mentohust") then
return
end
local page = entry({"admin", "services", "mentohust"}, cbi("mentohust"), _("MentoHUST"))
page.dependent = true
page.acl_depends = { "luci-app-mentohust" }
entry({"admin", "services", "mentohust", "status"}, call("act_status")).leaf = true
end
function act_status()
local e = {}
e.running = luci.sys.call("pgrep mentohust >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -0,0 +1,91 @@
local i = require "luci.sys"
local m, e
m = Map("mentohust", translate("MentoHUST"))
m.description = translate("MentoHUST is a program that supports Ruijie authentication on Windows, Linux and Mac OS (with support for Searle authentication).")
m:section(SimpleSection).template = "mentohust/mentohust_status"
e = m:section(TypedSection, "mentohust")
e.addremove = false
e.anonymous = true
o = e:option(Flag, "enable", translate("Enable"))
o.rmempty = false
o = e:option(Value, "username", translate("Username"))
o.datatype = "string"
o.rmempty = true
o = e:option(Value, "password", translate("Password"))
o.datatype = "string"
o.password = true
o.rmempty = true
o = e:option(Value, "interface", translate("Network interface"))
for t, e in ipairs(i.net.devices()) do if e ~= "lo" then o:value(e) end end
o.rmempty = false
o = e:option(Value, "ipaddr", translate("IP address"))
o.description = translate("Leave blank or set 0.0.0.0 to use local IP (DHCP)")
o.default = "0.0.0.0"
o.rmempty = true
o = e:option(Value, "gateway", translate("Gateway"))
o.default = "0.0.0.0"
o.rmempty = false
o = e:option(Value, "mask", translate("Subnet Mask"))
o.default = "255.255.255.0"
o.rmempty = false
o = e:option(Value, "dns", translate("DNS"))
o.default = "0.0.0.0"
o.rmempty = true
o = e:option(Value, "ping", translate("Ping Host"))
o.description = translate("Ping host for drop detection, 0.0.0.0 to turn off this feature.")
o.default = "0.0.0.0"
o.rmempty = false
o = e:option(Value, "timeout", translate("Authentication Timeout (Seconds)"))
o.default = "8"
o.rmempty = false
o = e:option(Value, "interval", translate("Response Interval (Seconds)"))
o.default = "30"
o.rmempty = false
o = e:option(Value, "wait", translate("Await Failure(Seconds)"))
o.default = "15"
o.rmempty = false
o = e:option(Value, "fail_number", translate("Allow Failure Count"))
o.description = translate("Default 0, indicating no limit.")
o.default = "0"
o.rmempty = false
o = e:option(ListValue, "multicast_address", translate("Multicast Address"))
o.default = "1"
o:value("0", translate("Standard"))
o:value("1", translate("Ruijie"))
o:value("2", translate("Searle"))
o = e:option(ListValue, "dhcp_mode", translate("DHCP Mode"))
o.default = "1"
o:value("0", translate("None"))
o:value("1", translate("Two-factor authentication"))
o:value("2", translate("After authentication"))
o:value("3", translate("Before authentication"))
o = e:option(Value, "dhcp_script", translate("DHCP Script"))
o.description = translate("Default udhcpc -i")
o.default = "udhcpc -i"
o.rmempty = true
o = e:option(Value, "version", translate("Client Version Number"))
o.description = translate("Default 0.00indicating compatibility with xrgsu")
o.default = "0.00"
o.rmempty = false
return m

View File

@ -0,0 +1,23 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(1, '<%=url([[admin]], [[services]], [[mentohust]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('mentohust_status');
if (data && tb) {
if (data.running) {
var links = '<em style=\"color:green\"><b>MentoHUST <%:RUNNING%></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em style=\"color:red\"><b>MentoHUST <%:NOT RUNNING%></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="mentohust_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,101 @@
msgid "MentoHUST"
msgstr "锐捷认证"
msgid "MentoHUST is a program that supports Ruijie authentication on Windows, Linux and Mac OS (with support for Searle authentication)."
msgstr "MentoHUST 是一个支持Windows、Linux、Mac OS下锐捷认证的程序附带支持赛尔认证"
msgid "RUNNING"
msgstr "运行中"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "Collecting data..."
msgstr "获取数据中..."
msgid "Enable"
msgstr "启用"
msgid "Username"
msgstr "用户名"
msgid "Password"
msgstr "密码"
msgid "Network interface"
msgstr "网络接口"
msgid "IP address"
msgstr "IP 地址"
msgid "Leave blank or set 0.0.0.0 to use local IP (DHCP)"
msgstr "留空或设置 0.0.0.0 则使用本机 IPDHCP"
msgid "Gateway"
msgstr "网关"
msgid "Subnet Mask"
msgstr "子网掩码"
msgid "DNS"
msgstr "DNS"
msgid "Ping Host"
msgstr "Ping 主机"
msgid "Ping host for drop detection, 0.0.0.0 to turn off this feature."
msgstr "Ping 主机用于掉线检测0.0.0.0 表示禁用该功能"
msgid "Authentication Timeout (Seconds)"
msgstr "认证超时(秒)"
msgid "Response Interval (Seconds)"
msgstr "响应间隔(秒)"
msgid "Await Failure(Seconds)"
msgstr "失败等待(秒)"
msgid "Allow Failure Count"
msgstr "允许失败次数"
msgid "Default 0, indicating no limit."
msgstr "默认 0表示无限制"
msgid "Multicast Address"
msgstr "组播地址"
msgid "Standard"
msgstr "标准"
msgid "Ruijie"
msgstr "锐捷"
msgid "Searle"
msgstr "赛尔"
msgid "DHCP Mode"
msgstr "DHCP 方式"
msgid "None"
msgstr "不使用"
msgid "Two-factor authentication"
msgstr "二次认证"
msgid "After authentication"
msgstr "认证后"
msgid "Before authentication"
msgstr "认证前"
msgid "DHCP Script"
msgstr "DHCP 脚本"
msgid "Default udhcpc -i"
msgstr "默认 udhcpc -i"
msgid "Client Version Number"
msgstr "客户端版本号"
msgid "Default 0.00indicating compatibility with xrgsu"
msgstr "默认 0.00,表示兼容 xrgsu"

View File

@ -0,0 +1,4 @@
config mentohust 'config'
option enable '0'
option interface ''

View File

@ -0,0 +1,55 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/sbin/mentohust
get_config() {
config_load mentohust
config_get "enable" "config" "enable" "0"
config_get "username" "config" "username"
config_get "password" "config" "password"
config_get "interface" "config" "interface"
config_get "ipaddr" "config" "ipaddr"
config_get "gateway" "config" "gateway" "0.0.0.0"
config_get "mask" "config" "mask" "255.255.255.0"
config_get "dns" "config" "dns" "0.0.0.0"
config_get "ping" "config" "ping" "0.0.0.0"
config_get "timeout" "config" "timeout" "8"
config_get "interval" "config" "interval" "30"
config_get "wait" "config" "wait" "15"
config_get "fail_number" "config" "fail_number" "0"
config_get "multicast_address" "config" "multicast_address" "0"
config_get "dhcp_mode" "config" "dhcp_mode" "1"
config_get "dhcp_script" "config" "dhcp_script"
config_get "version" "config" "version" "0.00"
}
start_service() {
get_config
[ "$enable" -ne "1" ] && return 1
[ -n "$ipaddr" ] && IPADDR="-i$ipaddr" || IPADDR=""
[ -n "$dns" ] && DNS="-s$dns" || DNS=""
[ -n "$dhcp_script" ] && DHCP_SCRIPT="-c$dhcp_script" || DHCP_SCRIPT=""
procd_open_instance mentohust
procd_set_param command $PROG
procd_append_param command -u$username -p$password -n$interface $IPADDR -m$mask -g$gateway $DNS -o$ping -t$timeout -e$interval -r$wait -a$multicast_address -d$dhcp_mode -b0 -v$version $DHCP_SCRIPT
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance mentohust
}
service_triggers() {
procd_add_reload_trigger "mentohust"
}
reload_service() {
stop
sleep 1
start
}
stop_service() {
pgrep -f /usr/sbin/mentohust | xargs kill -9 >/dev/null 2>&1
}

View File

@ -0,0 +1,11 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@mentohust[-1]
add ucitrack mentohust
set ucitrack.@mentohust[-1].init=mentohust
commit ucitrack
EOF
rm -rf /tmp/luci-indexcache*
exit 0

View File

@ -0,0 +1,11 @@
{
"luci-app-mentohust": {
"description": "Grant UCI access for luci-app-mentohust",
"read": {
"uci": [ "mentohust" ]
},
"write": {
"uci": [ "mentohust" ]
}
}
}