🐶 Sync 2025-11-02 14:26:26

This commit is contained in:
actions-user
2025-11-02 14:26:26 +08:00
parent 64bcc56c2a
commit ac011db799
1557 changed files with 746465 additions and 0 deletions

27
luci-app-lucky/Makefile Normal file
View File

@@ -0,0 +1,27 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2022-2023 gdy
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-lucky
PKG_VERSION:=2.2.2
PKG_RELEASE:=1
LUCI_TITLE:=LuCI Support for lucky
LUCI_DEPENDS:=+lucky +luci-compat
LUCI_PKGARCH:=all
define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./root/usr/bin/luckyarch $(1)/usr/bin/luckyarch
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@@ -0,0 +1,147 @@
module("luci.controller.lucky", package.seeall)
function index()
if not nixio.fs.access("/etc/config/lucky") then
return
end
entry({"admin", "services", "lucky"}, alias("admin", "services", "lucky", "setting"),_("Lucky"), 57).dependent = true
entry({"admin", "services", "lucky", "setting"}, cbi("lucky/lucky"), _("Base Setting"), 20).leaf=true
entry({"admin", "services", "lucky_status"}, call("act_status"))
entry({"admin", "services", "lucky_info"}, call("lucky_info"))
entry({"admin", "services", "lucky_set_config"}, call("lucky_set_config"))
entry({"admin", "services", "lucky_service"}, call("lucky_service"))
end
function act_status()
local sys = require "luci.sys"
local e = { }
e.running = sys.call("pgrep -f 'lucky -c' >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function lucky_info()
local e = { }
local luckyInfo = luci.sys.exec("/usr/bin/lucky -info")
if (luckyInfo~=nil)
then
e.luckyInfo = luckyInfo
local configObj = GetLuckyConfigureObj()
if (configObj~=nil)
then
e.LuckyBaseConfigure = configObj["BaseConfigure"]
end
end
e.luckyArch = luci.sys.exec("/usr/bin/luckyarch")
--e.runStatus = luci.sys.call("pidof lucky >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function lucky_set_config()
local key = luci.http.formvalue("key")
local value = luci.http.formvalue("value")
local e = { }
e.ret = 1
if (key == "admin_http_port")
then
e.ret =setLuckyConf("AdminWebListenPort",value)
end
if(key=="admin_safe_url")
then
e.ret =setLuckyConf("SetSafeURL",value)
end
if(key=="reset_auth_info")
then
setLuckyConf("AdminAccount","666")
setLuckyConf("AdminPassword","666")
luci.sys.exec("/etc/init.d/lucky restart")
e.ret=0
end
if(key=="switch_Internetaccess")
then
e.ret =setLuckyConf("AllowInternetaccess",value)
end
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function lucky_service()
local action = luci.http.formvalue("action")
if (action=="restart")
then
luci.sys.exec("uci set lucky.@lucky[0].enabled=1")
luci.sys.exec("uci commit")
luci.sys.exec("/etc/init.d/lucky restart")
end
if (action=="start")
then
luci.sys.exec("uci set lucky.@lucky[0].enabled=1")
luci.sys.exec("uci commit")
luci.sys.exec("/etc/init.d/lucky start")
end
if (action=="stop")
then
luci.sys.exec("uci set lucky.@lucky[0].enabled=0")
luci.sys.exec("uci commit")
luci.sys.exec("/etc/init.d/lucky stop")
end
end
function trim(s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
function GetLuckyConfigureObj()
configPath = trim(luci.sys.exec("uci get lucky.@lucky[0].configdir"))
local configContent = luci.sys.exec("lucky -baseConfInfo -cd "..configPath)
configObj = luci.jsonc.parse(trim(configContent))
return configObj
end
function setLuckyConf(key,value)
configPath = trim(luci.sys.exec("uci get lucky.@lucky[0].configdir"))
cmd = "/usr/bin/lucky ".." -setconf ".."-key "..key.." -value "..value.." -cd "..configPath
if (value=="")
then
cmd = "/usr/bin/lucky ".." -setconf ".."-key "..key.." -cd "..configPath
end
luci.sys.exec(cmd)
return 0
end

View File

@@ -0,0 +1,25 @@
--
local m, s ,o
local m = Map("lucky", translate("Lucky"), translate("ipv4/ipv6 portforward,ddns,reverseproxy proxy,wake on lan,IOT and more...") )
m:section(SimpleSection).template = "lucky/lucky_status"
s = m:section(TypedSection, "lucky", translate("Basic Settings"))
s.addremove=false
s.anonymous=true
--o=s:option(Flag,"enabled",translate("Enable"))
--o.default=0
o = s:option( Value, "configdir", translate("Config dir path"),
translate("The path to store the config file"))
o.placeholder = "/etc/config/lucky.daji"
m.apply_on_parse = true
m.on_after_apply = function(self,map)
luci.sys.exec("/etc/init.d/lucky restart")
end
return m

View File

@@ -0,0 +1,355 @@
<style>
.mar-10 {
margin-left: 50px;
margin-right: 10px;
}
#_luckyAdminLink,#_luckyAdminOpen{
font-weight: bold;
}
</style>
<fieldset class="cbi-section">
<p id="_luckyAdminLink"></p>
</fieldset>
<style>
.cbi-section {
border: 1px solid #ccc;
padding: 10px;
}
.cbi-section td:first-child {
font-weight: bold;
}
</style>
<fieldset class="cbi-section">
<legend><%:Main Program Information%></legend>
<table>
<tr>
<td><%:Installation Status%></td>
<td id="_luckyInstallStatus"><%:Collecting data...%></td>
</tr>
<tr>
<td><%:Lucky Status%></td>
<td id="_luckyStatus"><%:Collecting data...%></td>
</tr>
<tr>
<td><%:Lucky Arch%></td>
<td id="_luckyArch"><%:Collecting data...%></td>
</tr>
<tr>
<td><%:Compilation Time%></td>
<td id="_luckyCompilationTime"><%:Collecting data...%></td>
</tr>
<tr>
<td><%:Lucky Version%></td>
<td id="_luckyVersion"><%:Collecting data...%></td>
</tr>
</table>
</fieldset>
<fieldset class="cbi-section">
<legend><%:Admin Panel Information%></legend>
<table>
<tr>
<td><%:Admin Panel%></td>
<td id="_luckyAdminOpen"><%:Collecting data...%></td>
</tr>
<tr>
<td><%:Admin Panel Login Info%></td>
<td id="_luckyLoginInfo"><%:Collecting data...%></td>
</tr>
</table>
</fieldset>
<script type="text/javascript">
var daip = document.getElementById('_daip');
var luckyInstallStatus = document.getElementById('_luckyInstallStatus')
//var luckyAdminPanelURL = document.getElementById('_luckyAdminPanelURL')
var luckyArch = document.getElementById('_luckyArch')
var luckyStatus = document.getElementById('_luckyStatus')
var luckyCompilationTime = document.getElementById('_luckyCompilationTime')
var luckyVersion = document.getElementById('_luckyVersion')
var luckyLoginInfo = document.getElementById('_luckyLoginInfo')
var luckyAdminOpen = document.getElementById('_luckyAdminOpen')
var luckyHttpPort = document.getElementById('_luckyHttpPort')
var luckyAllowInternetaccess = document.getElementById('_luckyAllowInternetaccess')
var luckySafeURL = document.getElementById('_luckySafeURL')
var luckyAdminLink = document.getElementById('_luckyAdminLink')
var luckyInstalled = false
var adminHttpURL = ""
FlushLuckyInfo()
MotitorLuckyState()
function flushLuckyStatus(status) {
if (status) {
luckyStatus.innerHTML = '<b style=color:green><%:The Lucky service is running.%></b>'
luckyStatus.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyStatus.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Stop%>" onclick="return StopService()"/>'
//luckyAdminOpen.innerHTML = '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Open AdminURL%>" onclick="return OpenAdminURL(this,adminHttpURL)"/>'
luckyAdminOpen.innerHTML = '<a href="' + adminHttpURL + '"' + ' target="_blank">' + adminHttpURL + '</a> '
luckyAdminLink.innerHTML = '<b><a href="' + adminHttpURL + '"' + ' target="_blank">' + adminHttpURL + '</a></b> '
} else {
if (luckyInstalled) {
luckyStatus.innerHTML = '<b style=color:red><%:The Lucky service is not running.%></b>'
luckyStatus.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyStatus.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Start%>" onclick="return StartService()"/>'
} else {
luckyStatus.innerHTML = '<b style=color:red><%:Not installed%></b>'
}
luckyAdminOpen.innerHTML = ''
luckyAdminLink.innerHTML = ''
}
}
function FlushLuckyInfo() {
XHR.get('<%=url([[admin]], [[services]], [[lucky_info]])%>', null,
function (x, info) {
if (info) {
luckyArch.innerHTML = '<b style=color:blue>' + info.luckyArch + '</b>'
if (info.luckyInfo == "") {
luckyInstalled = false
//console.log("没有安装")
luckyStatus.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyInstallStatus.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyHttpPort.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyCompilationTime.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyLoginInfo.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyAdminOpen.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyAllowInternetaccess.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckySafeURL.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyVersion.innerHTML = '<b style=color:red><%:Not installed%></b>'
luckyVersion.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyVersion.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:get latest version%>" onclick="return OpenGithub()"/>'
luckyAdminLink.innerHTML = ''
return
}
luckyInstalled = true
luckyInstallStatus.innerHTML = '<b style=color:green><%:Installed%></b>'
console.log("已经安装")
var luckyInfo = JSON.parse(info.luckyInfo)
luckyCompilationTime.innerHTML = "<b style=color:green>" + luckyInfo.Date + "</b>"
luckyVersion.innerHTML = "<b style=color:green>" + luckyInfo.Version + "</b>"
luckyVersion.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyVersion.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:get latest version%>" onclick="return OpenGithub()"/>'
adminHttpURL = "http://" + window.location.hostname + ":" + info.LuckyBaseConfigure.AdminWebListenPort
if (info.LuckyBaseConfigure.SafeURL != undefined) {
adminHttpURL += info.LuckyBaseConfigure.SafeURL
}
luckyLoginInfo.innerHTML =
"<b style=color:green><%:DefaultAuth%>:666" + "</b>"
luckyLoginInfo.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyLoginInfo.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Reset%>" onclick="return ResetAuthInfo(this)"/>'
luckyHttpPort.innerHTML = '<input disabled id="_luckyHttpPortInput" type="text" class="cbi-input-text"data-type="uinteger" style="width:30%" value="' + info.LuckyBaseConfigure.AdminWebListenPort + '"/>'
luckyHttpPort.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyHttpPort.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Change%>" onclick="return SetNewHttpPort(this)"/>'
luckySafeURL.innerHTML = '<input disabled id="_luckySafeURLInput" type="text" class="cbi-input-text"data-type="uinteger" style="width:30%" value="' + info.LuckyBaseConfigure.SafeURL + '"/>'
luckySafeURL.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckySafeURL.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Change%>" onclick="return SetNewSafeURL(this)"/>'
if (info.LuckyBaseConfigure.AllowInternetaccess) {
luckyAllowInternetaccess.innerHTML = '<b style=color:green><%:allow%></b>'
luckyAllowInternetaccess.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyAllowInternetaccess.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Disable%>" onclick="return SwitchAllowInternetaccess(false)"/>'
} else {
luckyAllowInternetaccess.innerHTML = '<b style=color:red><%:not allow%></b>'
luckyAllowInternetaccess.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
luckyAllowInternetaccess.innerHTML += '<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Enable%>" onclick="return SwitchAllowInternetaccess(true)"/>'
}
}
}
);
}
function SwitchAllowInternetaccess(b) {
console.log("切换:" + b)
if (b) {
if (confirm("<%:Are you sure Enalbe Internetaccess?%>")) {
SetLuckyConfig("switch_Internetaccess", "true")
}
return
}
if (confirm("<%:Are you sure Disable Internetaccess?%>")) {
SetLuckyConfig("switch_Internetaccess", "false")
}
}
var luckyPreState = false
function MotitorLuckyState() {
XHR.poll(3, '<%=url([[admin]], [[services]], [[lucky_status]])%>', null,
function (x, data) {
if (data) {
if (luckyPreState != data.running) {
FlushLuckyInfo()
console.log("服务状态发生变化")
}
luckyPreState = data.running
flushLuckyStatus(data.running)
}
}
);
}
function OpenAdminURL(btn, url) {
winOpen(url)
}
function SetNewHttpPort(btn) {
var luckyHttpPortInput = document.getElementById('_luckyHttpPortInput')
console.log(luckyHttpPortInput.value)
var newPort = prompt("<%:NewHttpPort%>");
if (newPort == null) {
return
}
if (luckyHttpPortInput.value == newPort) {
return
}
if (!isNumber(newPort)) {
alert("<%:portValueError%>");
return
}
var newPortValue = parseInt(newPort)
if (newPortValue <= 0 || newPortValue > 65535) {
alert("<%:portValueError%>");
return
}
console.log("新端口:" + newPortValue)
SetLuckyConfig("admin_http_port", newPort)
}
function SetNewSafeURL(btn) {
var luckySafeURLInput = document.getElementById('_luckySafeURLInput')
console.log("fuckURL:" + luckySafeURLInput.value)
var newSafeURL = prompt("<%:NewHttpPort%>");
if (newSafeURL == null) {
return
}
if (newSafeURL == luckySafeURLInput.value) {
return
}
SetLuckyConfig("admin_safe_url", newSafeURL)
}
function ResetAuthInfo(btn) {
if (confirm("<%:Reset 666 as admin account and password?%>")) {
SetLuckyConfig("reset_auth_info", "")
}
}
function SetLuckyConfig(key, value) {
XHR.get('<%=url([[admin]], [[services]], [[lucky_set_config]])%>', { key: key, value: value },
function (x, res) {
if (res) {
//console.log(res)
if (res.ret != undefined && res.ret == 0) {
FlushLuckyInfo()
alert("<%:update success%>")
ControllLuckyService("restart")
setTimeout('document.location.reload()',2000)
} else {
alert("<%:update failed%>")
}
}
});
}
function ControllLuckyService(action) {
console.log("ControllLuckyService:" + action)
XHR.get('<%=url([[admin]], [[services]], [[lucky_service]])%>', { action: action },
function (x) {
});
}
function StopService() {
if (confirm("<%:are you sure stop lucky service?%>")) {
ControllLuckyService("stop")
}
}
function StartService() {
if (confirm("<%:are you sure start lucky service?%>")) {
ControllLuckyService("start")
}
}
function OpenGithub() {
winOpen("https://url21.ctfile.com/d/44547821-55537427-a5525e?p=16601")
}
function winOpen(url) {
var winOpen = window.open(url);
if (winOpen == null || typeof (winOpen) == 'undefined') {
window.location.href = url;
}
};
function isNumber(val) {
// negative or positive
return /^[-]?[\.\d]+$/.test(val);
}
</script>

1
luci-app-lucky/po/zh-cn Symbolic link
View File

@@ -0,0 +1 @@
zh_Hans

View File

@@ -0,0 +1,146 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Main Program"
msgstr "主程序"
msgid "Main Program Information"
msgstr "主程序信息"
msgid "Installation Status"
msgstr "安装状态"
msgid "Compilation Time"
msgstr "编译时间"
msgid "Admin Panel Information"
msgstr "管理面板信息"
msgid "Config dir path"
msgstr "配置文件夹位置"
msgid "Lucky"
msgstr "Lucky"
msgid "ipv4/ipv6 portforward,ddns,reverseproxy proxy,wake on lan,IOT and more..."
msgstr "IPv4/IPv6端口转发,动态域名服务,http/https反向代理网络唤醒(可通过第三方物联网平台接入各大语音助手实现语音控制开关电脑)"
msgid "Running state"
msgstr "运行状态"
msgid "The Lucky service is running."
msgstr "已启动"
msgid "The Lucky service is not running."
msgstr "未启动"
msgid "Lucky Status"
msgstr "Lucky服务状态"
msgid "Collecting data..."
msgstr "收集数据..."
msgid "Set the Lucky access port"
msgstr "设置访问端口"
msgid "</br>For specific usage, see:"
msgstr "</br>具体使用方法参见:"
msgid "Base Setting"
msgstr "基本设置"
msgid "Not installed"
msgstr "没有安装"
msgid "Installed"
msgstr "已安装"
msgid "Admin Panel Login HTTP URL"
msgstr "管理后台登录地址(http)"
msgid "Lucky Arch"
msgstr "当前环境CPU架构"
msgid "Lucky Status"
msgstr "Lucky运行状态"
msgid "Lucky Compilation time"
msgstr "编译时间"
msgid "Lucky Version"
msgstr "版本"
msgid "Admin Panel Login Info"
msgstr "管理后台登录信息"
msgid "Account"
msgstr "账号"
msgid "Password"
msgstr "密码"
msgid "Admin Panel"
msgstr "Lucky 后台管理"
msgid "Open AdminURL"
msgstr "打开后台管理"
msgid "Lucky Admin Http Port"
msgstr "Lucky 后台HTTP端口"
msgid "Change"
msgstr "更改"
msgid "portValueError"
msgstr "端口值有误"
msgid "Get Lucky Latest Version"
msgstr "获取Lucky最新版本"
msgid "get latest version"
msgstr "查询最新"
msgid "Admin Safe URL"
msgstr "安全入口"
msgid "DefaultAuth"
msgstr "默认登录账号密码"
msgid "Reset 666 as admin account and password?"
msgstr "重置账号密码为666?"
msgid "update success"
msgstr "修改成功"
msgid "update failed"
msgstr "修改失败"
msgid "Allow Internet access"
msgstr "外网登录后台"
msgid "Are you sure Enalbe Internetaccess?"
msgstr "确定要启用外网访问?"
msgid "Are you sure Disable Internetaccess?"
msgstr "确定要禁用外网访问?"
msgid "are you sure stop lucky service?"
msgstr "确定要停止Lucky服务?"
msgid "are you sure start lucky service?"
msgstr "确定要启动Lucky服务?"
msgid "Config file path"
msgstr "配置文件存放位置"
msgid "The path to store the config file"
msgstr "存放配置文件的位置"
msgid "allow"
msgstr "允许"
msgid "not allow"
msgstr "禁止"
msgid "Basic Settings"
msgstr "基础设置"

View File

@@ -0,0 +1,14 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@lucky[-1]
add ucitrack lucky
set ucitrack.@lucky[-1].init=lucky
commit ucitrack
EOF
chmod +x /usr/bin/luckyarch
rm -f /tmp/luci-indexcache* 2>/dev/null
rm -f /tmp/luci-modulecache/* 2>/dev/null # 针对OpenWrt 21.02+
rm -f /tmp/luci-indexcache
return 0

View File

@@ -0,0 +1,14 @@
#!/bin/sh
cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
[ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armv5"
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/clash ] && cpucore="armv7"
[ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="arm64"
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="i386"
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="x86_64"
if [ -n "$(echo $cputype | grep -E "linux.*mips.*")" ];then
mipstype=$(echo -n I | hexdump -o 2>/dev/null | awk '{ print substr($2,6,1); exit}') #通过判断大小端判断mips或mipsle
[ "$mipstype" = "0" ] && cpucore="mips_softfloat" || cpucore="mipsle_softfloat"
fi
echo $cpucore

View File

@@ -0,0 +1,14 @@
{
"admin/services/lucky": {
"title": "Lucky",
"order": 60,
"action": {
"type": "firstchild",
"preferred": "setting"
},
"depends": {
"acl": ["luci-app-lucky"],
"uci": {"lucky": true}
}
}
}

View File

@@ -0,0 +1,14 @@
{
"luci-app-lucky": {
"description": "Grant UCI access for luci-app-lucky",
"read": {
"ubus": {
"service": [ "list" ]
},
"uci": [ "lucky" ]
},
"write": {
"uci": [ "lucky" ]
}
}
}