From b2d1e25edb6bd76a229cbe11a657e5aae6929989 Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Thu, 17 Oct 2019 02:14:00 -0700 Subject: [PATCH] luci-app-baidupcs-web: add packege --- package/lean/BaiduPCS-Web/Makefile | 77 +++++++++++++++++++ package/lean/luci-app-baidupcs-web/Makefile | 17 ++++ .../luasrc/controller/baidupcs-web.lua | 10 +++ .../luasrc/model/cbi/baidupcs-web.lua | 46 +++++++++++ .../root/etc/config/baidupcs-web | 6 ++ .../root/etc/init.d/baidupcs-web | 21 +++++ .../root/etc/uci-defaults/luci-baidupcs-web | 11 +++ 7 files changed, 188 insertions(+) create mode 100644 package/lean/BaiduPCS-Web/Makefile create mode 100644 package/lean/luci-app-baidupcs-web/Makefile create mode 100644 package/lean/luci-app-baidupcs-web/luasrc/controller/baidupcs-web.lua create mode 100644 package/lean/luci-app-baidupcs-web/luasrc/model/cbi/baidupcs-web.lua create mode 100644 package/lean/luci-app-baidupcs-web/root/etc/config/baidupcs-web create mode 100755 package/lean/luci-app-baidupcs-web/root/etc/init.d/baidupcs-web create mode 100755 package/lean/luci-app-baidupcs-web/root/etc/uci-defaults/luci-baidupcs-web diff --git a/package/lean/BaiduPCS-Web/Makefile b/package/lean/BaiduPCS-Web/Makefile new file mode 100644 index 000000000..447238c69 --- /dev/null +++ b/package/lean/BaiduPCS-Web/Makefile @@ -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))) diff --git a/package/lean/luci-app-baidupcs-web/Makefile b/package/lean/luci-app-baidupcs-web/Makefile new file mode 100644 index 000000000..94a90f661 --- /dev/null +++ b/package/lean/luci-app-baidupcs-web/Makefile @@ -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 + 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 new file mode 100644 index 000000000..0851eba52 --- /dev/null +++ b/package/lean/luci-app-baidupcs-web/luasrc/controller/baidupcs-web.lua @@ -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 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 new file mode 100644 index 000000000..ca2aa3d4f --- /dev/null +++ b/package/lean/luci-app-baidupcs-web/luasrc/model/cbi/baidupcs-web.lua @@ -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 = "      " +end + +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.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 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 new file mode 100644 index 000000000..ef19f7ed2 --- /dev/null +++ b/package/lean/luci-app-baidupcs-web/root/etc/config/baidupcs-web @@ -0,0 +1,6 @@ + +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 new file mode 100755 index 000000000..ff7c72f2a --- /dev/null +++ b/package/lean/luci-app-baidupcs-web/root/etc/init.d/baidupcs-web @@ -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 +} diff --git a/package/lean/luci-app-baidupcs-web/root/etc/uci-defaults/luci-baidupcs-web b/package/lean/luci-app-baidupcs-web/root/etc/uci-defaults/luci-baidupcs-web new file mode 100755 index 000000000..e72523b79 --- /dev/null +++ b/package/lean/luci-app-baidupcs-web/root/etc/uci-defaults/luci-baidupcs-web @@ -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