mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-07 03:17:03 +08:00
add luci-app-switch-lan-play0.0.3
This commit is contained in:
parent
ad7eac97dc
commit
01973530ee
@ -12,9 +12,12 @@ PKG_RELEASE:=20210401
|
|||||||
PKG_LICENSE:=GPLv2
|
PKG_LICENSE:=GPLv2
|
||||||
PKG_MAINTAINER:=sirpdboy
|
PKG_MAINTAINER:=sirpdboy
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
LUA_LIBRARYDIR = /usr/lib/lua
|
||||||
|
LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci
|
||||||
define Package/$(PKG_NAME)
|
define Package/$(PKG_NAME)
|
||||||
SECTION:=LuCI
|
SECTION:=LuCI
|
||||||
CATEGORY:=LuCI
|
CATEGORY:=LuCI
|
||||||
@ -28,39 +31,26 @@ define Package/$(PKG_NAME)/description
|
|||||||
Luci Support for netspeedtest.
|
Luci Support for netspeedtest.
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
define Build/Prepare
|
define Build/Prepare
|
||||||
chmod +x root/etc/init.d/netspeedtest root/usr/bin/speedtest >/dev/null 2>&1
|
mkdir -p $(PKG_BUILD_DIR)
|
||||||
$(foreach po,$(wildcard ${CURDIR}/po/zh-cn/*.po), \
|
$(CP) ./* $(PKG_BUILD_DIR)/
|
||||||
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/conffiles
|
|
||||||
/etc/config/netspeedtest
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Configure
|
define Build/Configure
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/postinst
|
|
||||||
endef
|
|
||||||
|
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/install
|
define Package/$(PKG_NAME)/install
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
|
$(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR)
|
||||||
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
|
cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/
|
$(INSTALL_DIR) $(1)/
|
||||||
cp -pR ./root/* $(1)/
|
cp -pR ./root/* $(1)/
|
||||||
$(INSTALL_DIR) $(1)/usr/bin/
|
$(INSTALL_DIR) $(1)/usr/bin/
|
||||||
|
|
||||||
$(INSTALL_BIN) ./files/speedtest $(1)/usr/bin/
|
$(INSTALL_BIN) ./files/speedtest $(1)/usr/bin/
|
||||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
|
||||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/netspeedtest.lmo $(1)/usr/lib/lua/luci/i18n/
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
include $(TOPDIR)/feeds/luci/luci.mk
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
# call BuildPackage - OpenWrt buildroot signature
|
|
||||||
|
|
||||||
|
56
luci-app-switch-lan-play/Makefile
Normal file
56
luci-app-switch-lan-play/Makefile
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2008-2015 The LuCI Team <luci@lists.subsignal.org>
|
||||||
|
# Copyright (C) 2018 @skylovebeauty <skylove@qq.com>
|
||||||
|
# Copyright (C) 2020 Kenneth Kasilag <kenneth@kasilag.me>
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=luci-app-switch-lan-play
|
||||||
|
PKG_VERSION:=0.0.3
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
LUA_LIBRARYDIR = /usr/lib/lua
|
||||||
|
LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci
|
||||||
|
|
||||||
|
define Package/luci-app-switch-lan-play
|
||||||
|
SECTION:=luci
|
||||||
|
CATEGORY:=LuCI
|
||||||
|
SUBMENU:=3. Applications
|
||||||
|
DEPENDS:= +switch-lan-play
|
||||||
|
TITLE:=luci-app-switch-lan-play
|
||||||
|
PKGARCH:=all
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/luci-app-switch-lan-play/description
|
||||||
|
LuCI web-interface for Switch Lan Play Client
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Prepare
|
||||||
|
mkdir -p $(PKG_BUILD_DIR)
|
||||||
|
$(CP) ./* $(PKG_BUILD_DIR)/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Build/Compile
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR)
|
||||||
|
cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/postinst
|
||||||
|
[ -n "$${IPKG_INSTROOT}" ] || {$(foreach script,$(LUCI_DEFAULTS),
|
||||||
|
(. /etc/uci-defaults/$(script)) && rm -f /etc/uci-defaults/$(script))
|
||||||
|
rm -f /tmp/luci-indexcache
|
||||||
|
rm -rf /tmp/luci-modulecache/
|
||||||
|
killall -HUP rpcd 2>/dev/null
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,luci-app-switch-lan-play))
|
16
luci-app-switch-lan-play/luasrc/controller/switchlanplay.lua
Normal file
16
luci-app-switch-lan-play/luasrc/controller/switchlanplay.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
||||||
|
-- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
||||||
|
-- Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
|
module("luci.controller.switchlanplay", package.seeall)
|
||||||
|
|
||||||
|
function index()
|
||||||
|
if not nixio.fs.access("/etc/config/switchlanplay") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local page
|
||||||
|
|
||||||
|
page = entry({"admin", "services", "switchlanplay"}, cbi("switchlanplay"), _("Switch-Lan-Play"))
|
||||||
|
page.dependent = true
|
||||||
|
end
|
63
luci-app-switch-lan-play/luasrc/model/cbi/switchlanplay.lua
Normal file
63
luci-app-switch-lan-play/luasrc/model/cbi/switchlanplay.lua
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
-- Copyright 2008 Steven Barth <steven@midlink.org>
|
||||||
|
-- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
||||||
|
-- Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
|
local fs = require "nixio.fs"
|
||||||
|
local sys = require "luci.sys"
|
||||||
|
local m, s, p
|
||||||
|
|
||||||
|
local play_on = (luci.sys.call("pidof lan-play > /dev/null"))==0
|
||||||
|
|
||||||
|
local state_msg = " "
|
||||||
|
|
||||||
|
if play_on then
|
||||||
|
local now_server = io.popen("ps | grep lan-play | grep -v 'grep' | cut -d ' ' -f 14")
|
||||||
|
local server_info = now_server:read("*all")
|
||||||
|
now_server:close()
|
||||||
|
state_msg="<span style=\"color:green;font-weight:bold\">" .. translate("运行中") .. "</span>" .. "<br /><br />当前服务器地址 " .. server_info
|
||||||
|
else
|
||||||
|
state_msg="<span style=\"color:red;font-weight:bold\">" .. translate("未运行") .. "</span>"
|
||||||
|
end
|
||||||
|
|
||||||
|
m = Map("switchlanplay", translate("切换LAN播放"),
|
||||||
|
translatef("在互联网上玩本地无线交换机游戏。") .. "<br /><br />" ..translate("服务状态:") .. " - " .. state_msg)
|
||||||
|
|
||||||
|
s = m:section(TypedSection, "switch-lan-play", translate("Settings"))
|
||||||
|
s.addremove = false
|
||||||
|
s.anonymous = true
|
||||||
|
|
||||||
|
e = s:option(Flag, "enable", translate("Enabled"), translate("启用或禁用交换机lan播放守护程序。"))
|
||||||
|
e.rmempty = false
|
||||||
|
function e.write(self, section, value)
|
||||||
|
if value == "1" then
|
||||||
|
luci.sys.call("/etc/init.d/switchlanplay start >/dev/null")
|
||||||
|
else
|
||||||
|
luci.sys.call("/etc/init.d/switchlanplay stop >/dev/null")
|
||||||
|
end
|
||||||
|
luci.http.write("<script>location.href='./switchlanplay';</script>")
|
||||||
|
return Flag.write(self, section, value)
|
||||||
|
end
|
||||||
|
|
||||||
|
ifname = s:option(ListValue, "ifname", translate("Interfaces"), translate("指定要侦听的接口。"))
|
||||||
|
|
||||||
|
for k, v in ipairs(luci.sys.net.devices()) do
|
||||||
|
if v ~= "lo" then
|
||||||
|
ifname:value(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
relay_server_host = s:option(Value, "relay_server_host", translate("中继服务器主机"), translate("中继主机-IP地址或域名(必需)"))
|
||||||
|
relay_server_host.datatype="host"
|
||||||
|
relay_server_host.default="127.0.0.1"
|
||||||
|
relay_server_host.rmempty="false"
|
||||||
|
|
||||||
|
relay_server_port = s:option(Value, "relay_server_port", translate("中继服务器端口"),translate("服务器端口(必需)"))
|
||||||
|
relay_server_port.datatype="port"
|
||||||
|
relay_server_port.default="11451"
|
||||||
|
relay_server_port.rmempty="false"
|
||||||
|
|
||||||
|
p = s:option(Value, "pmtu", translate("PMTU"), translate("有些游戏需要定制一个PMTU。默认设置为0。"))
|
||||||
|
p.datatype="uinteger"
|
||||||
|
p.default="0"
|
||||||
|
|
||||||
|
return m
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
PKG_ARCH:=x86_64
|
PKG_ARCH:=x86_64
|
||||||
PKG_NAME:=speedtest
|
PKG_NAME:=speedtest
|
||||||
PKG_VERSION:=1.0.0
|
PKG_VERSION:=1.0.0
|
||||||
PKG_RELEASE:=6
|
PKG_RELEASE:=7
|
||||||
|
|
||||||
#PKG_SOURCE_URL:=https://ookla.bintray.com/download
|
#PKG_SOURCE_URL:=https://ookla.bintray.com/download
|
||||||
#PKG_SOURCE:=ookla-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_ARCH)-linux.tgz
|
#PKG_SOURCE:=ookla-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_ARCH)-linux.tgz
|
||||||
@ -25,9 +25,9 @@ include $(INCLUDE_DIR)/package.mk
|
|||||||
define Package/$(PKG_NAME)
|
define Package/$(PKG_NAME)
|
||||||
SECTION:=net
|
SECTION:=net
|
||||||
CATEGORY:=Network
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=speedtest-openwrt
|
||||||
TITLE:=A Speedtest application
|
TITLE:=A Speedtest application
|
||||||
DEPENDS:=+kmod-tun +wget +curl +python3
|
DEPENDS:=+kmod-tun +wget +curl +python3
|
||||||
URL:=https://github.com/sirpdboy/NetSpeedTest
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
@ -36,24 +36,17 @@ define Package/$(PKG_NAME)/description
|
|||||||
ookla speedtest by sirpdboy
|
ookla speedtest by sirpdboy
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Prepare
|
#define Build/Prepare
|
||||||
mkdir -p $(PKG_BUILD_DIR)/$(PKG_NAME)
|
# mkdir -p $(PKG_BUILD_DIR)
|
||||||
$(CP) ./file/speedtest $(PKG_BUILD_DIR)/$(PKG_NAME)
|
# $(CP) ./$(PKG_NAME)/* $(PKG_BUILD_DIR)/
|
||||||
endef
|
#endef
|
||||||
|
|
||||||
define Build/Configure
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/install
|
define Package/$(PKG_NAME)/install
|
||||||
$(INSTALL_DIR) $(1)/usr/bin
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME)/speedtest $(1)/usr/bin
|
$(INSTALL_BIN) ./files/speedtest $(1)/usr/bin
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/postinst
|
|
||||||
endef
|
|
||||||
|
|
||||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||||
|
58
switch-lan-play/Makefile
Normal file
58
switch-lan-play/Makefile
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2009-2014 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
PKG_NAME:=switch-lan-play
|
||||||
|
PKG_VERSION:=0.2.3
|
||||||
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
|
PKG_SOURCE_PROTO:=git
|
||||||
|
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
|
||||||
|
PKG_SOURCE_URL:=https://github.com/spacemeowx2/switch-lan-play.git
|
||||||
|
PKG_MIRROR_HASH:=c0c663e3fdc95d6d6e8ab401caa2bfb5b5872e00
|
||||||
|
#PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||||
|
|
||||||
|
PKG_LICENSE:=GPLv3
|
||||||
|
PKG_LICENSE_FILES:=LICENSE.TXT
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
include $(INCLUDE_DIR)/cmake.mk
|
||||||
|
|
||||||
|
CMAKE_BINARY_SUBDIR := build-openwrt
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)
|
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
SUBMENU:=Lan-play
|
||||||
|
DEPENDS:=+libpcap +libpthread +libstdcpp +libatomic @!USE_UCLIBC
|
||||||
|
TITLE:=Switch Lan Play Client
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/switch-lan-play/conffiles
|
||||||
|
/etc/config/switchlanplay
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/description
|
||||||
|
Make you and your friends play games like in a LAN.
|
||||||
|
endef
|
||||||
|
|
||||||
|
#define Build/Prepare
|
||||||
|
# mkdir -p $(PKG_BUILD_DIR)
|
||||||
|
# $(CP) ./$(PKG_NAME)/* $(PKG_BUILD_DIR)/
|
||||||
|
#endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
|
$(INSTALL_DIR) $(1)/usr/bin
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build-openwrt/src/lan-play $(1)/usr/bin/
|
||||||
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
|
$(INSTALL_CONF) ./files/switchlanplay.config $(1)/etc/config/switchlanplay
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
|
$(INSTALL_BIN) ./files/switchlanplay.init $(1)/etc/init.d/switchlanplay
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
6
switch-lan-play/files/switchlanplay.config
Normal file
6
switch-lan-play/files/switchlanplay.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
config switch-lan-play
|
||||||
|
option enable '0'
|
||||||
|
option ifname 'br-lan'
|
||||||
|
option relay_server_host '127.0.0.1'
|
||||||
|
option relay_server_port '11451'
|
||||||
|
option pmtu '0'
|
58
switch-lan-play/files/switchlanplay.init
Normal file
58
switch-lan-play/files/switchlanplay.init
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
START=99
|
||||||
|
SERVICE=switchlanplay
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
|
run_switch_lan_play()
|
||||||
|
{
|
||||||
|
config_get_bool enable $1 enable
|
||||||
|
if [ "$enable" -gt 0 ]; then
|
||||||
|
local ifname
|
||||||
|
config_get ifname $1 ifname
|
||||||
|
local relay_server_host
|
||||||
|
local relay_server_port
|
||||||
|
config_get relay_server_host $1 relay_server_host
|
||||||
|
config_get relay_server_port $1 relay_server_port
|
||||||
|
config_get pmtu $1 pmtu
|
||||||
|
if [ "$pmtu" -gt 0 ]; then
|
||||||
|
PROG="lan-play --relay-server-addr $relay_server_host:$relay_server_port --netif $ifname --pmtu $pmtu"
|
||||||
|
else
|
||||||
|
PROG="lan-play --relay-server-addr $relay_server_host:$relay_server_port --netif $ifname"
|
||||||
|
fi
|
||||||
|
echo "switch-lan-play client started."
|
||||||
|
else
|
||||||
|
PROG="lan-play --version"
|
||||||
|
echo "switch-lan-play is disabled. check configuration?"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service()
|
||||||
|
{
|
||||||
|
config_load switchlanplay
|
||||||
|
config_foreach run_switch_lan_play switch-lan-play
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command $PROG
|
||||||
|
procd_close_instance
|
||||||
|
|
||||||
|
echo $PROG
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_service()
|
||||||
|
{
|
||||||
|
pgrep lan-play | xargs -r kill -9
|
||||||
|
echo "switch-lan-play client stopped."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
reload_service()
|
||||||
|
{
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
service_triggers()
|
||||||
|
{
|
||||||
|
procd_add_reload_trigger "/etc/config/switchlanplay" "switchlanplay"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user