diff --git a/luci-app-uugamebooster/Makefile b/luci-app-uugamebooster/Makefile index 7e7a3524..e6db4e99 100644 --- a/luci-app-uugamebooster/Makefile +++ b/luci-app-uugamebooster/Makefile @@ -1,18 +1,14 @@ -# Copyright (C) 2021 Openwrt.org -# -# This is free software, licensed under the Apache License, Version 2.0 . +# SPDX-License-Identifier: Apache-2.0 # include $(TOPDIR)/rules.mk +PKG_LICENSE:=Apache-2.0 + LUCI_TITLE:=LuCI support for UUgamebooster LUCI_DEPENDS:=+uugamebooster LUCI_PKGARCH:=all -PKG_NAME:=luci-app-uugamebooster -PKG_VERSION:=2.0 -PKG_RELEASE:=2 - include $(TOPDIR)/feeds/luci/luci.mk # call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js b/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js new file mode 100644 index 00000000..de7e6be6 --- /dev/null +++ b/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: Apache-2.0 + +'use strict'; +'require form'; +'require poll'; +'require rpc'; +'require uci'; +'require view'; + +const callServiceList = rpc.declare({ + object: 'service', + method: 'list', + params: ['name'], + expect: { '': {} } +}); + +function getServiceStatus() { + return L.resolveDefault(callServiceList('uugamebooster'), {}).then(function (res) { + var isRunning = false; + try { + isRunning = res['uugamebooster']['instances']['uugamebooster']['running']; + } catch (e) { } + return isRunning; + }); +} + +function renderStatus(isRunning) { + var spanTemp = '%s %s'; + var renderHTML; + if (isRunning) { + renderHTML = spanTemp.format('green', _('UU GameAcc'), _('RUNNING')) + } else { + renderHTML = spanTemp.format('red', _('UU GameAcc'), _('NOT RUNNING')); + } + + return renderHTML; +} + +return view.extend({ + load: function() { + return Promise.all([ + uci.load('uugamebooster') + ]); + }, + + render: function() { + let m, s, o; + + m = new form.Map('uugamebooster', _('UU Game Accelerator'), + _('A Paid Game Acceleration service')); + + s = m.section(form.TypedSection); + s.anonymous = true; + s.render = function () { + poll.add(function () { + return L.resolveDefault(getServiceStatus()).then(function (res) { + var view = document.getElementById('service_status'); + view.innerHTML = renderStatus(res); + }); + }); + + return E('div', { class: 'cbi-section', id: 'status_bar' }, [ + E('p', { id: 'service_status' }, _('Collecting data...')) + ]); + } + + s = m.section(form.NamedSection, 'config', 'uugamebooster'); + + o = s.option(form.Flag, 'enabled', _('Enable')); + o.default = o.disabled; + o.rmempty = false; + + s = m.section(form.TypedSection); + s.anonymous = true; + s.render = function () { + return E('div', {class: 'cbi-section'}, [ + E('p', [ + E('img', {src: '/uugamebooster/uuios.png', height: '300'}), + E('img', {src: '/uugamebooster/uuandroid.png', height: '300'}) + ]) + ]) + } + + return m.render(); + } + +}); diff --git a/luci-app-uugamebooster/luasrc/controller/uugamebooster.lua b/luci-app-uugamebooster/luasrc/controller/uugamebooster.lua deleted file mode 100644 index d427f275..00000000 --- a/luci-app-uugamebooster/luasrc/controller/uugamebooster.lua +++ /dev/null @@ -1,17 +0,0 @@ -module("luci.controller.uugamebooster", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/uugamebooster") then - return - end - - entry({"admin", "services", "uugamebooster"}, cbi("uugamebooster"), ("UU GameAcc"), 99).dependent = true - entry({"admin", "services", "uugamebooster", "status"}, call("act_status")).leaf = true -end - -function act_status() - local e = {} - e.running = luci.sys.call("pgrep -f uugamebooster >/dev/null") == 0 - luci.http.prepare_content("application/json") - luci.http.write_json(e) -end diff --git a/luci-app-uugamebooster/luasrc/model/cbi/uugamebooster.lua b/luci-app-uugamebooster/luasrc/model/cbi/uugamebooster.lua deleted file mode 100644 index 812c4068..00000000 --- a/luci-app-uugamebooster/luasrc/model/cbi/uugamebooster.lua +++ /dev/null @@ -1,19 +0,0 @@ -require("luci.util") - -mp = Map("uugamebooster") -mp.title = translate("UU Game Accelerator") -mp.description = translate("A Paid Game Acceleration service") - -mp:section(SimpleSection).template = "uugamebooster/uugamebooster_status" - -s = mp:section(TypedSection, "uugamebooster") -s.anonymous = true -s.addremove = false - -o = s:option(Flag, "enabled", translate("Enable")) -o.default = 0 -o.optional = false - -mp:section(SimpleSection).template = "uugamebooster/uugamebooster_qcode" - -return mp diff --git a/luci-app-uugamebooster/luasrc/view/uugamebooster/uugamebooster_qcode.htm b/luci-app-uugamebooster/luasrc/view/uugamebooster/uugamebooster_qcode.htm deleted file mode 100644 index 12cb2e97..00000000 --- a/luci-app-uugamebooster/luasrc/view/uugamebooster/uugamebooster_qcode.htm +++ /dev/null @@ -1,6 +0,0 @@ - -
-

- -

-
diff --git a/luci-app-uugamebooster/luasrc/view/uugamebooster/uugamebooster_status.htm b/luci-app-uugamebooster/luasrc/view/uugamebooster/uugamebooster_status.htm deleted file mode 100644 index c8abb464..00000000 --- a/luci-app-uugamebooster/luasrc/view/uugamebooster/uugamebooster_status.htm +++ /dev/null @@ -1,21 +0,0 @@ - - -
-

- <%:Collecting data...%> -

-
diff --git a/luci-app-uugamebooster/po/templates/uugamebooster.pot b/luci-app-uugamebooster/po/templates/uugamebooster.pot new file mode 100644 index 00000000..e328b81e --- /dev/null +++ b/luci-app-uugamebooster/po/templates/uugamebooster.pot @@ -0,0 +1,23 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:70 +msgid "Enable" +msgstr "" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:32 +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:34 +msgid "UU GameAcc" +msgstr "" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:50 +msgid "UU Game Accelerator" +msgstr "" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:51 +msgid "A Paid Game Acceleration service" +msgstr "" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:64 +msgid "Collecting data..." +msgstr "" diff --git a/luci-app-uugamebooster/po/zh-cn b/luci-app-uugamebooster/po/zh-cn new file mode 120000 index 00000000..8d69574d --- /dev/null +++ b/luci-app-uugamebooster/po/zh-cn @@ -0,0 +1 @@ +zh_Hans \ No newline at end of file diff --git a/luci-app-uugamebooster/po/zh-cn/uuplugin.po b/luci-app-uugamebooster/po/zh-cn/uuplugin.po deleted file mode 100644 index d2a3ddbb..00000000 --- a/luci-app-uugamebooster/po/zh-cn/uuplugin.po +++ /dev/null @@ -1,12 +0,0 @@ - -msgid "Enable" -msgstr "启用" - -msgid "UU GameAcc" -msgstr "UU游戏加速器" - -msgid "UU Game Accelerator" -msgstr "UU游戏加速器" - -msgid "A Paid Game Acceleration service" -msgstr "一个富家子弟用的主机游戏加速器 (开启服务后,使用手机APP绑定路由器并指定加速主机)" diff --git a/luci-app-uugamebooster/po/zh_Hans b/luci-app-uugamebooster/po/zh_Hans deleted file mode 120000 index 41451e4a..00000000 --- a/luci-app-uugamebooster/po/zh_Hans +++ /dev/null @@ -1 +0,0 @@ -zh-cn \ No newline at end of file diff --git a/luci-app-uugamebooster/po/zh_Hans/uugamebooster.po b/luci-app-uugamebooster/po/zh_Hans/uugamebooster.po new file mode 100644 index 00000000..f0df78aa --- /dev/null +++ b/luci-app-uugamebooster/po/zh_Hans/uugamebooster.po @@ -0,0 +1,23 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:70 +msgid "Enable" +msgstr "启用" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:32 +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:34 +msgid "UU GameAcc" +msgstr "UU游戏加速器" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:50 +msgid "UU Game Accelerator" +msgstr "UU游戏加速器" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:51 +msgid "A Paid Game Acceleration service" +msgstr "一个付费主机游戏加速器 (开启服务后,使用手机APP绑定路由器并指定加速主机)" + +#: applications/luci-app-uugamebooster/htdocs/luci-static/resources/view/uugamebooster.js:64 +msgid "Collecting data..." +msgstr "正在收集数据中..." diff --git a/luci-app-uugamebooster/root/etc/config/uuplugin b/luci-app-uugamebooster/root/etc/config/uuplugin deleted file mode 100644 index 3df31274..00000000 --- a/luci-app-uugamebooster/root/etc/config/uuplugin +++ /dev/null @@ -1,4 +0,0 @@ - -config uuplugin 'uuplugin' - option enabled '0' - diff --git a/luci-app-uugamebooster/root/etc/init.d/uugamebooster b/luci-app-uugamebooster/root/etc/init.d/uugamebooster deleted file mode 100755 index ed517955..00000000 --- a/luci-app-uugamebooster/root/etc/init.d/uugamebooster +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2021 Tianling Shen - -USE_PROCD=1 -START=99 - -CONF="uugamebooster" -PROG="/usr/bin/uugamebooster" - -UU_CONF="/usr/share/uugamebooster/uu.conf" - -start_service() { - config_load "$CONF" - local enabled - config_get_bool enabled "config" "enabled" "0" - [ "$enabled" -eq "1" ] || return 1 - - procd_open_instance "$CONF" - - procd_set_param command "$PROG" "$UU_CONF" - - procd_set_param limits core="unlimited" - procd_set_param respawn - procd_set_param stdout 1 - procd_set_param stderr 1 - - procd_close_instance -} - -reload_service() { - stop - start -} - -service_triggers() { - procd_add_reload_trigger "$CONF" -} diff --git a/luci-app-uugamebooster/root/etc/uci-defaults/45_luci-uugamebooster b/luci-app-uugamebooster/root/etc/uci-defaults/45_luci-uugamebooster deleted file mode 100644 index b8689ef2..00000000 --- a/luci-app-uugamebooster/root/etc/uci-defaults/45_luci-uugamebooster +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -[ ! -f "/usr/share/ucitrack/luci-app-uugamebooster.json" ] && { - cat > /usr/share/ucitrack/luci-app-uugamebooster.json << EEOF -{ - "config": "uugamebooster", - "init": "uugamebooster" -} -EEOF -} - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@uugamebooster[-1] - add ucitrack uugamebooster - set ucitrack.@uugamebooster[-1].init=uugamebooster - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/luci-app-uugamebooster/root/usr/share/luci/menu.d/luci-app-uugamebooster.json b/luci-app-uugamebooster/root/usr/share/luci/menu.d/luci-app-uugamebooster.json new file mode 100644 index 00000000..e66370b9 --- /dev/null +++ b/luci-app-uugamebooster/root/usr/share/luci/menu.d/luci-app-uugamebooster.json @@ -0,0 +1,13 @@ +{ + "admin/services/uugamebooster": { + "title": "UU GameAcc", + "action": { + "type": "view", + "path": "uugamebooster" + }, + "depends": { + "acl": [ "luci-app-uugamebooster" ], + "uci": { "uugamebooster": true } + } + } +} diff --git a/luci-app-uugamebooster/root/usr/share/rpcd/acl.d/luci-app-uugamebooster.json b/luci-app-uugamebooster/root/usr/share/rpcd/acl.d/luci-app-uugamebooster.json index a99fc152..11cbb55f 100644 --- a/luci-app-uugamebooster/root/usr/share/rpcd/acl.d/luci-app-uugamebooster.json +++ b/luci-app-uugamebooster/root/usr/share/rpcd/acl.d/luci-app-uugamebooster.json @@ -2,10 +2,13 @@ "luci-app-uugamebooster": { "description": "Grant UCI access for luci-app-uugamebooster", "read": { - "uci": [ "uuplugin" ] + "ubus": { + "service": [ "list" ] + }, + "uci": [ "uugamebooster" ] }, "write": { - "uci": [ "uuplugin" ] + "uci": [ "uugamebooster" ] } } } diff --git a/luci-app-uugamebooster/root/www/uuandriod.png b/luci-app-uugamebooster/root/www/uuandriod.png deleted file mode 100644 index edf7e8f5..00000000 Binary files a/luci-app-uugamebooster/root/www/uuandriod.png and /dev/null differ diff --git a/luci-app-uugamebooster/root/www/uugamebooster/uuandroid.png b/luci-app-uugamebooster/root/www/uugamebooster/uuandroid.png new file mode 100644 index 00000000..279b9f70 Binary files /dev/null and b/luci-app-uugamebooster/root/www/uugamebooster/uuandroid.png differ diff --git a/luci-app-uugamebooster/root/www/uugamebooster/uuios.png b/luci-app-uugamebooster/root/www/uugamebooster/uuios.png new file mode 100644 index 00000000..bce47ab9 Binary files /dev/null and b/luci-app-uugamebooster/root/www/uugamebooster/uuios.png differ diff --git a/luci-app-uugamebooster/root/www/uuios.png b/luci-app-uugamebooster/root/www/uuios.png deleted file mode 100644 index f76dc74e..00000000 Binary files a/luci-app-uugamebooster/root/www/uuios.png and /dev/null differ