add linkease
This commit is contained in:
parent
5e149fd8f7
commit
6479fe6229
66
applications/linkease/Makefile
Executable file
66
applications/linkease/Makefile
Executable file
@ -0,0 +1,66 @@
|
||||
#
|
||||
# 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.5.2
|
||||
PKG_RELEASE:=2
|
||||
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://fw.koolcenter.com/binary/LinkEase/LinuxStorage/
|
||||
PKG_HASH:=e79e5717f250cc293026ca9d0b785663e5a2906a2c748e62ac985c4bd1a038b6
|
||||
|
||||
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) $(PKG_BUILD_DIR)/heif-converter.$(PKG_ARCH_LINKEASE) $(1)/usr/sbin/heif-converter
|
||||
$(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)))
|
134
applications/linkease/files/aria2.sh
Executable file
134
applications/linkease/files/aria2.sh
Executable 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
|
3
applications/linkease/files/linkease.config
Executable file
3
applications/linkease/files/linkease.config
Executable file
@ -0,0 +1,3 @@
|
||||
config linkease
|
||||
option 'port' '8897'
|
||||
option 'enabled' '1'
|
23
applications/linkease/files/linkease.init
Executable file
23
applications/linkease/files/linkease.init
Executable 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
|
||||
}
|
22
applications/linkease/files/linkease.uci-default
Executable file
22
applications/linkease/files/linkease.uci-default
Executable 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
|
Loading…
x
Reference in New Issue
Block a user