add ddnsto and linkease

This commit is contained in:
YGAS 2021-09-29 21:52:27 +08:00
parent b0bc15077d
commit d0fd007ea9
24 changed files with 598 additions and 1 deletions

64
applications/ddnsto/Makefile Executable file
View File

@ -0,0 +1,64 @@
#
# Copyright (C) 2015-2016 OpenWrt.org
# Copyright (C) 2020 jjm2473@gmail.com
#
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
PKG_ARCH_DDNSTO:=$(ARCH)
PKG_NAME:=ddnsto
PKG_VERSION:=0.3.0
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://firmware.koolshare.cn/binary/ddnsto/
PKG_HASH:=cefd2494cb1c21e2c1616290f715dd6415cd460aafc107c38bb9910c13f42448
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=DDNS.to - the reverse proxy
DEPENDS:=
URL:=https://www.ddnsto.com/
endef
define Package/$(PKG_NAME)/description
DDNS.to is a reverse proxy
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/ddnsto
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
[ -f /etc/uci-defaults/ddnsto ] && /etc/uci-defaults/ddnsto && rm -f /etc/uci-defaults/ddnsto
fi
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/uci-defaults
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ddnsto.$(PKG_ARCH_DDNSTO) $(1)/usr/sbin/ddnsto
$(INSTALL_CONF) ./files/ddnsto.config $(1)/etc/config/ddnsto
$(INSTALL_BIN) ./files/ddnsto.init $(1)/etc/init.d/ddnsto
$(INSTALL_BIN) ./files/ddnsto.uci-default $(1)/etc/uci-defaults/ddnsto
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -0,0 +1,3 @@
config ddnsto
option 'token' ''
option 'enabled' '0'

View File

@ -0,0 +1,26 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
get_config() {
config_get_bool enabled $1 enabled 1
config_get_bool logger $1 logger 0
config_get token $1 token
}
start_service() {
config_load ddnsto
config_foreach get_config ddnsto
[ $enabled != 1 ] && return 1
if [ -z "$token" ]; then
logger -t ddnsto -p warn "token not set"
return 1
fi
procd_open_instance
procd_set_param command /usr/sbin/ddnsto -u "$token"
[ "$logger" == 1 ] && procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}

View File

@ -0,0 +1,12 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@ddnsto[-1]
add ucitrack ddnsto
set ucitrack.@ddnsto[-1].init=ddnsto
commit ucitrack
EOF
/etc/init.d/ddnsto enable
exit 0

65
applications/linkease/Makefile Executable file
View File

@ -0,0 +1,65 @@
#
# Copyright (C) 2015-2016 OpenWrt.org
# Copyright (C) 2020 jjm2473@gmail.com
#
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
PKG_ARCH_LINKEASE:=$(ARCH)
PKG_NAME:=linkease
PKG_VERSION:=0.3.66
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://firmware.koolshare.cn/binary/LinkEase/LinuxStorage/
PKG_HASH:=162046d8a31e175b74ca326d32d648240893fb712b4098f889a8cde43704c78f
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=LinkEase - the file cloud
DEPENDS:=
URL:=https://www.ddnsto.com/linkease/
endef
define Package/$(PKG_NAME)/description
LinkEase is a file cloud
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/linkease
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
[ -f /etc/uci-defaults/linkease ] && /etc/uci-defaults/linkease && rm -f /etc/uci-defaults/linkease
fi
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin/linkease-plugins $(1)/etc/config $(1)/etc/init.d $(1)/etc/uci-defaults
$(INSTALL_BIN) $(PKG_BUILD_DIR)/linkease.$(PKG_ARCH_LINKEASE) $(1)/usr/sbin/linkease
$(INSTALL_BIN) ./files/aria2.sh $(1)/usr/sbin/linkease-plugins/aria2.sh
$(INSTALL_CONF) ./files/linkease.config $(1)/etc/config/linkease
$(INSTALL_BIN) ./files/linkease.init $(1)/etc/init.d/linkease
$(INSTALL_BIN) ./files/linkease.uci-default $(1)/etc/uci-defaults/linkease
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -0,0 +1,134 @@
#!/bin/bash
sh_ver="1.0.0"
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/sbin:/bin
aria2_conf_dir=/var/etc/aria2/
#替换成你设备aria2.conf路径
aria2_conf=${aria2_conf_dir}/aria2.conf.main
#替换成你设备的aria2c路径
aria2c=/usr/bin/aria2c
Green_font_prefix="\033[32m"
Red_font_prefix="\033[31m"
Green_background_prefix="\033[42;37m"
Red_background_prefix="\033[41;37m"
Font_color_suffix="\033[0m"
Info="[${Green_font_prefix}信息${Font_color_suffix}]"
Error="[${Red_font_prefix}错误${Font_color_suffix}]"
Tip="[${Green_font_prefix}注意${Font_color_suffix}]"
error_code=11
success_code=0
return_error(){
echo 'Content-Type:application/json;charset=utf-8'
echo
echo "{
"\"success\"":$error_code,
"\"error\"":"\"$1\"",
"\"result"\":null
}"
exit 1
}
return_ok(){
echo 'Content-Type:application/json;charset=utf-8'
echo
echo "{
"\"success\"":$success_code,
"\"error\"":"\"$1\"",
"\"result"\":null
}"
exit 0
}
return_result(){
echo 'Content-Type:application/json;charset=utf-8'
echo
echo "{
"\"success\"":$success_code,
"\"error\"":"\"\"",
"\"result"\":$1
}"
exit 0
}
#进程中是否运行aria2
check_pid() {
PID=$(ps -ef | grep "aria2c" | grep -v grep | grep -v "aria2.sh" | grep -v "init.d" | grep -v "service" | awk '{print $2}')
}
#aria2是否正在运行
aria2_work_status(){
check_pid
# [[ ! -z ${PID} ]] && echo -e "${Error} Aria2 正在运行,请检查 !" && exit 1
[[ ! -z ${PID} ]] && return_ok "Aria2正在运行"
return_error "Aria2未运行"
}
#检测设备是否安装aria2
check_installed_status() {
[[ ! -e ${aria2c} ]] && return_error "Aria2 没有安装,请检查 !"
[[ ! -e ${aria2_conf} ]] && return_error "Aria2 配置文件不存在,请检查 !"
# return_ok "Aria2已安装"
}
#读取aria2配置信息
read_config() {
check_installed_status
if [[ ! -e ${aria2_conf} ]]; then
return_error "Aria2 配置文件不存在,请检查 !"
else
conf_text=$(cat ${aria2_conf} | grep -v '#')
aria2_dir=$(echo -e "${conf_text}" | grep "^dir=" | awk -F "=" '{print $NF}')
aria2_port=$(echo -e "${conf_text}" | grep "^rpc-listen-port=" | awk -F "=" '{print $NF}')
aria2_passwd=$(echo -e "${conf_text}" | grep "^rpc-secret=" | awk -F "=" '{print $NF}')
aria2_bt_port=$(echo -e "${conf_text}" | grep "^listen-port=" | awk -F "=" '{print $NF}')
aria2_dht_port=$(echo -e "${conf_text}" | grep "^dht-listen-port=" | awk -F "=" '{print $NF}')
return_result "{
"\"dir"\":"\"$aria2_dir"\",
"\"rpc-listen-port"\":"\"$aria2_port"\",
"\"rpc-secret"\":"\"$aria2_passwd"\",
"\"listen-port"\":"\"$aria2_bt_port"\",
"\"dht-listen-port"\":"\"$aria2_dht_port"\"}"
fi
}
#"Content-Type:text/html;charset=utf-8"
#echo
#SERVER_SOFTWARE = $SERVER_SOFTWARE #服务器软件
#SERVER_NAME = $SERVER_NAME #服务器主机名
#GATEWAY_INTERFACE = $GATEWAY_INTERFACE #CGI版本
#SERVER_PROTOCOL = $SERVER_PROTOCOL #通信使用的协议
#SERVER_PORT = $SERVER_PORT #服务器的端口号
#REQUEST_METHOD = $REQUEST_METHOD #请求方法(GET/POST/PUT/DELETE..)
#HTTP_ACCEPT = $HTTP_ACCEPT #HTTP定义的浏览器能够接受的数据类型
#SCRIPT_NAME = $SCRIPT_NAME #当前运行的脚本名称(包含路径)
#QUERY_STRING = $QUERY_STRING #地址栏中传的数据get方式
#REMOTE_ADDR = $REMOTE_ADDR #客户端的ip
#根据url QUERY调不同方法
query(){
aria2Query=${QUERY_STRING}
parse(){
echo $1 | sed 's/.*'$2'=\([[:alnum:]]*\).*/\1/'
}
value=$(parse $aria2Query "action")
if [ ! -z = "$value" ]
then
if [ "$value" = "status" ]
then
check_installed_status
elif [ "$value" = "readConfig" ]
then
read_config
elif [ "$value" = "workStatus" ]
then
aria2_work_status
else
echo
fi
else
return_error "action不能为空"
fi
}
query

View File

@ -0,0 +1,3 @@
config linkease
option 'port' '8897'
option 'enabled' '1'

View File

@ -0,0 +1,23 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
get_config() {
config_get_bool enabled $1 enabled 1
config_get_bool logger $1 logger
config_get port $1 port 8897
}
start_service() {
config_load linkease
config_foreach get_config linkease
[ $enabled != 1 ] && return 1
procd_open_instance
procd_set_param command /usr/sbin/linkease
[ -n "$port" ] && procd_append_param command --deviceAddr ":$port"
[ "$logger" == 1 ] && procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}

View File

@ -0,0 +1,22 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@linkease[-1]
add ucitrack linkease
set ucitrack.@linkease[-1].init=linkease
commit ucitrack
delete firewall.linkease
set firewall.linkease=rule
set firewall.linkease.name="linkease"
set firewall.linkease.target="ACCEPT"
set firewall.linkease.src="wan"
set firewall.linkease.proto="tcp"
set firewall.linkease.dest_port="8897"
commit firewall
EOF
/etc/init.d/linkease enable
/etc/init.d/linkease start
exit 0

View File

@ -0,0 +1,17 @@
# Copyright (C) 2016 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for ddnsto
LUCI_DEPENDS:=+ddnsto
LUCI_PKGARCH:=all
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,22 @@
module("luci.controller.ddnsto", package.seeall)
function index()
if not nixio.fs.access("/etc/config/ddnsto") then
return
end
entry({"admin", "services", "ddnsto"}, cbi("ddnsto"), _("DDNS.to"), 20).dependent = true
entry({"admin", "services", "ddnsto_status"}, call("ddnsto_status"))
end
function ddnsto_status()
local sys = require "luci.sys"
local status = {
running = (sys.call("pidof ddnsto >/dev/null") == 0)
}
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@ -0,0 +1,23 @@
--wulishui <wulishui@gmail.com> ,20200911
--jjm2473 <jjm2473@gmail.com> ,20210127
local m, s
m = Map("ddnsto", translate("DDNS.to"), translate("DDNS.to is a reverse proxy.")
.. " <a href=\"https://www.ddnsto.com/\" onclick=\"void(0)\" target=\"_blank\">"
.. translate("Official Website")
.. "</a>")
m:section(SimpleSection).template = "ddnsto_status"
s=m:section(TypedSection, "ddnsto", translate("Global settings"))
s.addremove=false
s.anonymous=true
s:option(Flag, "enabled", translate("Enable")).rmempty=false
s:option(Value, "token", translate("Token")).rmempty=false
return m

View File

@ -0,0 +1 @@
<%+ddnsto_status%>

View File

@ -0,0 +1,26 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/services/ddnsto_status")%>', null,
function(x, st)
{
var tb = document.getElementById('ddnsto_status');
if (st && tb)
{
if (st.running)
{
tb.innerHTML = '<br/><%:The DDNS.to service is running.%>';
}
else
{
tb.innerHTML = '<br/><em><%:The DDNS.to service is not running.%></em>';
}
}
}
);
//]]></script>
<fieldset class="cbi-section">
<legend><%:DDNS.to Status%></legend>
<p id="ddnsto_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,32 @@
msgid "DDNS.to"
msgstr "DDNS.to内网穿透"
msgid "Running state"
msgstr "运行状态"
msgid "Click to open DDNS.to"
msgstr "点击打开DDNS.to"
msgid "DDNS.to is a reverse proxy."
msgstr "DDNS.to是一个内网穿透工具。"
msgid "Official Website"
msgstr "官网"
msgid "Token"
msgstr "令牌"
msgid "The DDNS.to service is running."
msgstr "DDNS.to服务已启动"
msgid "The DDNS.to service is not running."
msgstr "DDNS.to服务未启动"
msgid "DDNS.to Status"
msgstr "DDNS.to服务状态"
msgid "Collecting data..."
msgstr "收集数据..."
msgid "Global settings"
msgstr "全局设置"

View File

@ -0,0 +1,4 @@
#!/bin/sh
rm -f /tmp/luci-indexcache
exit 0

View File

@ -0,0 +1,17 @@
# Copyright (C) 2016 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for linkease
LUCI_DEPENDS:=+linkease
LUCI_PKGARCH:=all
PKG_VERSION:=2.1.0
PKG_RELEASE:=2
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,25 @@
module("luci.controller.linkease", package.seeall)
function index()
if not nixio.fs.access("/etc/config/linkease") then
return
end
entry({"admin", "services", "linkease"}, cbi("linkease"), _("LinkEase"), 20).dependent = true
entry({"admin", "services", "linkease_status"}, call("linkease_status"))
end
function linkease_status()
local sys = require "luci.sys"
local uci = require "luci.model.uci".cursor()
local port = tonumber(uci:get_first("linkease", "linkease", "port"))
local status = {
running = (sys.call("pidof linkease >/dev/null") == 0),
port = (port or 8897)
}
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@ -0,0 +1,20 @@
--wulishui <wulishui@gmail.com> ,20200911
--jjm2473 <jjm2473@gmail.com> ,20210127
local m, s
m = Map("linkease", translate("LinkEase"), translate("LinkEase is an efficient data transfer tool."))
m:section(SimpleSection).template = "linkease_status"
s=m:section(TypedSection, "linkease", translate("Global settings"))
s.addremove=false
s.anonymous=true
s:option(Flag, "enabled", translate("Enable")).rmempty=false
s:option(Value, "port", translate("Port")).rmempty=false
return m

View File

@ -0,0 +1 @@
<%+linkease_status%>

View File

@ -0,0 +1,27 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/services/linkease_status")%>', null,
function(x, st)
{
var tb = document.getElementById('linkease_status');
if (st && tb)
{
if (st.running)
{
tb.innerHTML = '<br/><%:The LinkEase service is running.%>'
+ "<br/><br/><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:Click to open LinkEase%> \" onclick=\"window.open('http://" + window.location.hostname + ":" + st.port + "/')\"/>";
}
else
{
tb.innerHTML = '<br/><em><%:The LinkEase service is not running.%></em>';
}
}
}
);
//]]></script>
<fieldset class="cbi-section">
<legend><%:LinkEase Status%></legend>
<p id="linkease_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,27 @@
msgid "LinkEase"
msgstr "易有云文件管理器"
msgid "Running state"
msgstr "运行状态"
msgid "Click to open LinkEase"
msgstr "点击打开易有云"
msgid "LinkEase is an efficient data transfer tool."
msgstr "易有云是一个微型家庭数据服务中心,主要用于文件的集中存放、读取、备份及日常管理。释放用户终端设备空间,实现个人、家庭文件长久留存;支持家庭相册、视频文件随时随地多终端查看、播放,满足家庭文件的日常管理。"
msgid "Port"
msgstr "端口"
msgid "The LinkEase service is running."
msgstr "易有云服务已启动"
msgid "The LinkEase service is not running."
msgstr "易有云服务未启动"
msgid "LinkEase Status"
msgstr "易有云服务状态"
msgid "Collecting data..."
msgstr "收集数据..."

View File

@ -0,0 +1,4 @@
#!/bin/sh
rm -f /tmp/luci-indexcache
exit 0

View File

@ -63,7 +63,6 @@ function uninstall_container()
local status = container_status() local status = container_status()
local container_id = status.container_id local container_id = status.container_id
util.exec("docker container rm '"..container_id.."'") util.exec("docker container rm '"..container_id.."'")
util.exec("rm -rf /root/usr/share/nextcloud")
end end
-- 总结: -- 总结: