diff --git a/package/lean/BaiduPCS-Web/Makefile b/package/lean/baidupcs-web/Makefile similarity index 76% rename from package/lean/BaiduPCS-Web/Makefile rename to package/lean/baidupcs-web/Makefile index 577fd1b7e..e938bcc68 100644 --- a/package/lean/BaiduPCS-Web/Makefile +++ b/package/lean/baidupcs-web/Makefile @@ -1,13 +1,14 @@ # # Copyright (C) 2019 OpenWrt.org # +# KFERMercer +# # This is free software, licensed under the GNU General Public License v3. # -# By https://github.com/KFERMercer/openwrt-baidupcs-web include $(TOPDIR)/rules.mk -PKG_NAME:=BaiduPCS-Web +PKG_NAME:=baidupcs-web PKG_VERSION:=3.7.0 PKG_RELEASE:=1 @@ -25,8 +26,13 @@ define Package/$(PKG_NAME)/description BaiduPCS-Web is a web controller for BaiduPCS-Go endef +# 禁止OpenWrt对二进制文件进行strip STRIP:=true +ifeq ($(ARCH),i386) + PKG_ARCH_BAIDUPCS-WEB:=86 +endif + ifeq ($(ARCH),x86_64) PKG_ARCH_BAIDUPCS-WEB:=amd64 endif @@ -35,8 +41,8 @@ ifeq ($(ARCH),mipsel) PKG_ARCH_BAIDUPCS-WEB:=mipsle endif -ifeq ($(ARCH),i386) - PKG_ARCH_BAIDUPCS-WEB:=86 +ifeq ($(ARCH),mips) + PKG_ARCH_BAIDUPCS-WEB:=mipsle endif ifeq ($(ARCH),arm) @@ -47,15 +53,18 @@ ifeq ($(ARCH),aarch64) PKG_ARCH_BAIDUPCS-WEB:=arm64 endif -BAIDUPCS-WEB_ZIP_NAME:=BaiduPCS-Go-$(PKG_VERSION)-linux-$(PKG_ARCH_BAIDUPCS-WEB) -PKG_SOURCE:=$(BAIDUPCS-WEB_ZIP_NAME).zip + +PKG_SOURCE:=BaiduPCS-Go-$(PKG_VERSION)-linux-$(PKG_ARCH_BAIDUPCS-WEB).zip + PKG_SOURCE_URL:=https://github.com/liuzhuoling2011/baidupcs-web/releases/download/$(PKG_VERSION)/ -UNZIP_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/$(PKG_NAME)-unzip/$(PKG_ARCH_BAIDUPCS-WEB) + +UNZIP_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/$(PKG_NAME)-unzip + PKG_HASH:=skip define Build/Prepare mkdir -vp $(UNZIP_DIR) - unzip -od $(UNZIP_DIR) $(DL_DIR)/$(BAIDUPCS-WEB_ZIP_NAME).zip + unzip -od $(UNZIP_DIR) $(DL_DIR)/$(PKG_SOURCE) endef define Build/Configure @@ -66,7 +75,7 @@ endef define Package/$(PKG_NAME)/install $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(UNZIP_DIR)/$(BAIDUPCS-WEB_ZIP_NAME)/BaiduPCS-Go $(1)/usr/bin/$(PKG_NAME) + $(INSTALL_BIN) $(UNZIP_DIR)/*/BaiduPCS-Go $(1)/usr/bin/$(PKG_NAME) chmod 755 $(1)/usr/bin/$(PKG_NAME) endef diff --git a/package/lean/luci-app-baidupcs-web/Makefile b/package/lean/luci-app-baidupcs-web/Makefile index 94a90f661..45339b46f 100644 --- a/package/lean/luci-app-baidupcs-web/Makefile +++ b/package/lean/luci-app-baidupcs-web/Makefile @@ -1,17 +1,22 @@ -# Copyright (C) 2016 Openwrt.org # -# This is free software, licensed under the Apache License, Version 2.0 . +# +# +# Copyright (C) 2020 KFERMercer +# Copyright (C) 2020 [CTCGFW] Project OpenWRT +# +# THIS IS FREE SOFTWARE, LICENSED UNDER GPLv3. # include $(TOPDIR)/rules.mk -LUCI_TITLE:=LuCI Support for BaiduPCS-Web -LUCI_DEPENDS:=+BaiduPCS-Web +wget +openssl-util +PKG_NAME:=luci-app-baidupcs-web +LUCI_TITLE:=LuCI support for BaiduPCS-Go +LUCI_DEPENDS:=+baidupcs-web +wget +openssl-util LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=1 +PKG_RELEASE:=4 +PKG_MAINTAINER:= include $(TOPDIR)/feeds/luci/luci.mk # call BuildPackage - OpenWrt buildroot signature - diff --git a/package/lean/luci-app-baidupcs-web/luasrc/controller/baidupcs-web.lua b/package/lean/luci-app-baidupcs-web/luasrc/controller/baidupcs-web.lua index 0851eba52..805269dd1 100644 --- a/package/lean/luci-app-baidupcs-web/luasrc/controller/baidupcs-web.lua +++ b/package/lean/luci-app-baidupcs-web/luasrc/controller/baidupcs-web.lua @@ -4,7 +4,14 @@ function index() if not nixio.fs.access("/etc/config/baidupcs-web") then return end - local page - page = entry({"admin", "nas", "baidupcs-web"}, cbi("baidupcs-web"), _("BaiduPCS Web"), 300) - page.dependent = true + entry({"admin", "nas", "baidupcs-web"}, cbi("baidupcs-web"), _("BaiduPCS Web"), 300).dependent = true + entry({"admin","nas","baidupcs-web","status"},call("act_status")).leaf=true +end + +function act_status() + local e={} + e.running=luci.sys.call("pgrep baidupcs-web >/dev/null")==0 + -- e.port=luci.sys.exec("uci get baidupcs-web.config.port") + luci.http.prepare_content("application/json") + luci.http.write_json(e) end diff --git a/package/lean/luci-app-baidupcs-web/luasrc/model/cbi/baidupcs-web.lua b/package/lean/luci-app-baidupcs-web/luasrc/model/cbi/baidupcs-web.lua index ca2aa3d4f..c693aad02 100644 --- a/package/lean/luci-app-baidupcs-web/luasrc/model/cbi/baidupcs-web.lua +++ b/package/lean/luci-app-baidupcs-web/luasrc/model/cbi/baidupcs-web.lua @@ -1,46 +1,48 @@ -require("luci.sys") -require("luci.util") +--[[ -local fs = require "nixio.fs" +Copyright (C) 2020 KFERMercer +Copyright (C) 2020 [CTCGFW] Project OpenWRT -local uci = require "luci.model.uci".cursor() +THIS IS FREE SOFTWARE, LICENSED UNDER GPLv3 -local m, s +]]-- -local running=(luci.sys.call("pidof BaiduPCS-Web > /dev/null") == 0) +m = Map("baidupcs-web") +m.title = translate("BaiduPCS-Web") +m.description = translate("基于BaiduPCS-Go, 可以让你高效的使用百度云") -local button = "" -local state_msg = "" -local trport = uci:get("baidupcs-web", "config", "port") -if running then - button = "      " -end +m:section(SimpleSection).template = "baidupcs-web/baidupcs-web_status" -if running then - state_msg = "" .. translate("BaiduPCS-Web 运行中") .. "" -else - state_msg = "" .. translate("BaiduPCS-Web 未运行") .. "" -end - -m = Map("baidupcs-web", translate("百度网盘管理"), translate("基于BaiduPCS-Web,让你高效的使用百度云。") .. button - .. "

" .. translate("BaiduPCS-Web运行状态").. " : " .. state_msg .. "
") - -s = m:section(TypedSection, "baidupcs-web", "") +s = m:section(TypedSection, "baidupcs-web") s.addremove = false s.anonymous = true enable = s:option(Flag, "enabled", translate("启用")) enable.rmempty = false -o = s:option(Value, "port", translate("监听端口")) -o.placeholder = 5299 -o.default = 5299 -o.datatype = "port" -o.rmempty = false +o = s:option(Value, "port", translate("网页端口")) +o.datatype = "port" +o.placeholder = "5299" +o.default = "5299" +o.rmempty = false -o = s:option(Value, "dl_dir", translate("下载目录")) +o = s:option(Value, "download_dir", translate("下载目录")) o.placeholder = "/opt/baidupcsweb-download" -o.default = "/opt/baidupcsweb-download" -o.rmempty = false +o.default = "/opt/baidupcsweb-download" +o.rmempty = false + +o = s:option(Value, "max_download_rate", translate("最大下载速度")) +o.placeholder = "0" + +o = s:option(Value, "max_upload_rate", translate("最大上传速度")) +o.placeholder = "0" +o.description = translate("0代表不限制, 单位为每秒的传输速率, 后缀'/s' 可省略, 如 2MB/s, 2MB, 2m, 2mb 均为一个意思") + +o = s:option(Value, "max_download_load", translate("同时进行下载文件的最大数量")) +o.placeholder = "1" +o.description = translate("不要太贪心, 当心被封号") + +o = s:option(Value, "max_parallel", translate("最大并发连接数")) +o.placeholder = "8" return m diff --git a/package/lean/luci-app-baidupcs-web/luasrc/view/baidupcs-web/baidupcs-web_status.htm b/package/lean/luci-app-baidupcs-web/luasrc/view/baidupcs-web/baidupcs-web_status.htm new file mode 100644 index 000000000..4edb7e0b7 --- /dev/null +++ b/package/lean/luci-app-baidupcs-web/luasrc/view/baidupcs-web/baidupcs-web_status.htm @@ -0,0 +1,38 @@ + + + + +
+

+ <%:Collecting data...%> +

+
diff --git a/package/lean/luci-app-baidupcs-web/root/etc/config/baidupcs-web b/package/lean/luci-app-baidupcs-web/root/etc/config/baidupcs-web index ef19f7ed2..fd78131ef 100644 --- a/package/lean/luci-app-baidupcs-web/root/etc/config/baidupcs-web +++ b/package/lean/luci-app-baidupcs-web/root/etc/config/baidupcs-web @@ -1,6 +1,2 @@ config baidupcs-web 'config' - option port '5299' - option enabled '0' - option dl_dir '/opt/baidupcsweb-download' - diff --git a/package/lean/luci-app-baidupcs-web/root/etc/init.d/baidupcs-web b/package/lean/luci-app-baidupcs-web/root/etc/init.d/baidupcs-web index ff7c72f2a..7ab7340ee 100755 --- a/package/lean/luci-app-baidupcs-web/root/etc/init.d/baidupcs-web +++ b/package/lean/luci-app-baidupcs-web/root/etc/init.d/baidupcs-web @@ -1,21 +1,32 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2019 By [CTCGFW] Project OpenWRT START=90 STOP=10 enabled="$(uci get baidupcs-web.config.enabled)" port="$(uci get baidupcs-web.config.port)" -dl_dir="$(uci get baidupcs-web.config.dl_dir)" +download_dir="$(uci get baidupcs-web.config.download_dir)" +max_download_rate="$(uci get baidupcs-web.config.max_download_rate)" +max_upload_rate="$(uci get baidupcs-web.config.max_upload_rate)" +max_download_load="$(uci get baidupcs-web.config.max_download_load)" +max_parallel="$(uci get baidupcs-web.config.max_parallel)" start() { stop [ "$enabled" == "1" ] || exit 0 - mkdir -p "${dl_dir}" - BaiduPCS-Web config set -savedir="${dl_dir}" >/dev/null 2>&1 - BaiduPCS-Web web --port "${port}" --access >/dev/null 2>&1 & + mkdir -p "${download_dir}" + baidupcs-web config set \ + --savedir "${download_dir}" \ + --max_download_rate "${max_download_rate}" \ + --max_upload_rate "${max_upload_rate}" \ + --max_download_load "${max_download_load}" \ + --max_parallel "${max_parallel}" \ + --max_upload_parallel "${max_parallel}" \ + >/dev/null 2>&1 + + baidupcs-web web --port "${port}" --access >/dev/null 2>&1 & } stop() { - killall BaiduPCS-Web >/dev/null 2>&1 + killall baidupcs-web >/dev/null 2>&1 }