luci-app-baidupcs-web: add packege

This commit is contained in:
LEAN-ESX 2019-10-17 02:14:00 -07:00
parent 41d66b3864
commit b2d1e25edb
7 changed files with 188 additions and 0 deletions

View File

@ -0,0 +1,77 @@
#
# Copyright (C) 2019 OpenWrt.org
#
# 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_VERSION:=3.6.8
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
TITLE:=BaiduPCS-Web is a web controller for BaiduPCS-Go
URL:=https://github.com/liuzhuoling2011/baidupcs-web
endef
define Package/$(PKG_NAME)/description
BaiduPCS-Web is a web controller for BaiduPCS-Go
endef
STRIP:=true
ifeq ($(ARCH),x86_64)
PKG_ARCH_BAIDUPCS-WEB:=amd64
endif
ifeq ($(ARCH),mipsel)
PKG_ARCH_BAIDUPCS-WEB:=mipsle
endif
ifeq ($(ARCH),i386)
PKG_ARCH_BAIDUPCS-WEB:=86
endif
ifeq ($(ARCH),arm)
PKG_ARCH_BAIDUPCS-WEB:=arm
endif
ifeq ($(ARCH),arm64)
PKG_ARCH_BAIDUPCS-WEB:=arm64
endif
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_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)
PKG_HASH:=skip
define Build/Prepare
mkdir -vp $(UNZIP_DIR)
unzip -od $(UNZIP_DIR) $(DL_DIR)/$(BAIDUPCS-WEB_ZIP_NAME).zip
endef
define Build/Configure
endef
define Build/Compile
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)
chmod 755 $(1)/usr/bin/$(PKG_NAME)
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

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 BaiduPCS-Web
LUCI_DEPENDS:=+BaiduPCS-Web +wget +openssl-util
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,10 @@
module("luci.controller.baidupcs-web", package.seeall)
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
end

View File

@ -0,0 +1,46 @@
require("luci.sys")
require("luci.util")
local fs = require "nixio.fs"
local uci = require "luci.model.uci".cursor()
local m, s
local running=(luci.sys.call("pidof BaiduPCS-Web > /dev/null") == 0)
local button = ""
local state_msg = ""
local trport = uci:get("baidupcs-web", "config", "port")
if running then
button = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\" " .. translate("打开BaiduPCS-Web管理界面") .. " \" onclick=\"window.open('http://'+window.location.hostname+':" .. trport .. "')\"/>"
end
if running then
state_msg = "<b><font color=\"green\">" .. translate("BaiduPCS-Web 运行中") .. "</font></b>"
else
state_msg = "<b><font color=\"red\">" .. translate("BaiduPCS-Web 未运行") .. "</font></b>"
end
m = Map("baidupcs-web", translate("百度网盘管理"), translate("基于BaiduPCS-Web让你高效的使用百度云。") .. button
.. "<br/><br/>" .. translate("BaiduPCS-Web运行状态").. " : " .. state_msg .. "<br/>")
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, "dl_dir", translate("下载目录"))
o.placeholder = "/opt/baidupcsweb-download"
o.default = "/opt/baidupcsweb-download"
o.rmempty = false
return m

View File

@ -0,0 +1,6 @@
config baidupcs-web 'config'
option port '5299'
option enabled '0'
option dl_dir '/opt/baidupcsweb-download'

View File

@ -0,0 +1,21 @@
#!/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)"
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 &
}
stop() {
killall BaiduPCS-Web >/dev/null 2>&1
}

View File

@ -0,0 +1,11 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@baidupcs-web[-1]
add ucitrack baidupcs-web
set ucitrack.@baidupcs-web[-1].init=baidupcs-web
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0