luci-app-go-aliyundrive-webdav: add package (#8112)

Signed-off-by: Beginner-Go <70857188+Beginner-Go@users.noreply.github.com>
This commit is contained in:
Beginner 2021-10-31 17:04:10 +08:00 committed by GitHub
parent 67d86bf3cf
commit eff943777d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 386 additions and 0 deletions

View File

@ -0,0 +1,81 @@
# SPDX-Identifier-License: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=go-aliyundrive-webdav
PKG_VERSION:=1.0.12
PKG_RELEASE:=$(AUTORELEASE)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/LinkLeong/go-aliyundrive-webdav/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=eb60256131240adaa34e2039114237f8cdd9016233da1a417dace6b10bda4d61
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILE:=LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_CONFIG_DEPENDS:= \
CONFIG_GO_ALIYUNDRIVE_WEBDAV_COMPRESS_GOPROXY \
CONFIG_GO_ALIYUNDRIVE_WEBDAV_COMPRESS_UPX
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
GO_PKG:=go-aliyun-webdav
GO_PKG_LDFLAGS:=-s -w
GO_PKG_LDFLAGS_X:=main.Version=v$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/go-aliyundrive-webdav
SECTION:=net
CATEGORY:=Network
SUBMENU:=File Transfer
TITLE:=A WebDav server for AliyunDrive
URL:=https://github.com/LinkLeong/go-aliyundrive-webdav
DEPENDS:=$(GO_ARCH_DEPENDS)
endef
define Package/go-aliyundrive-webdav/config
config GO_ALIYUNDRIVE_WEBDAV_COMPRESS_GOPROXY
bool "Compiling with GOPROXY proxy"
default n
config GO_ALIYUNDRIVE_WEBDAV_COMPRESS_UPX
bool "Compress executable files with UPX"
default y
endef
ifeq ($(CONFIG_GO_ALIYUNDRIVE_WEBDAV_COMPRESS_GOPROXY),y)
export GO111MODULE=on
export GOPROXY=https://goproxy.baidu.com
endif
define Package/go-aliyundrive-webdav/conffiles
/etc/config/go-aliyundrive-webdav
endef
define Build/Compile
$(call GoPackage/Build/Compile)
ifeq ($(CONFIG_GO_ALIYUNDRIVE_WEBDAV_COMPRESS_UPX),y)
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/go-aliyun-webdav
endif
endef
define Package/go-aliyundrive-webdav/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/go-aliyun-webdav $(1)/usr/bin/go-aliyundrive-webdav
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) $(CURDIR)/files/go-aliyundrive-webdav.config $(1)/etc/config/go-aliyundrive-webdav
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) $(CURDIR)/files/go-aliyundrive-webdav.init $(1)/etc/init.d/go-aliyundrive-webdav
endef
$(eval $(call GoBinPackage,go-aliyundrive-webdav))
$(eval $(call BuildPackage,go-aliyundrive-webdav))

View File

@ -0,0 +1,23 @@
config go-aliyundrive-webdav 'config'
option enabled '0'
# Listening port
option port '8085'
# Refresh token
option rt ''
# Mounting directory
option path '/'
# Webdav auth username, default: admin
option user 'admin'
# Webdav auth password, default: 123456
option pwd '123456'
# Enable detailed logging
option verbose '0'

View File

@ -0,0 +1,50 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
USE_PROCD=1
START=99
CONF="go-aliyundrive-webdav"
PROG="/usr/bin/go-aliyundrive-webdav"
start_service() {
config_load "$CONF"
local enabled
config_get_bool enabled "config" "enabled"
[ "$enabled" -eq "1" ] || return 1
local port rt path user pwd verbose
config_get port "config" "port"
config_get rt "config" "rt"
config_get path "config" "path"
config_get user "config" "user"
config_get pwd "config" "pwd"
config_get_bool verbose "config" "verbose"
procd_open_instance "$CONF"
procd_set_param command "$PROG"
procd_append_param command "-rt" "$rt"
procd_append_param command "-port" "$port"
procd_append_param command "-path" "$path"
procd_append_param command "-user" "$user"
procd_append_param command "-pwd" "$pwd"
[ "$verbose" -eq "0" ] || procd_append_param command "-v"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
reload_service() {
stop
start
}
service_triggers() {
procd_add_reload_trigger "go-aliyundrive-webdav"
}

View File

@ -0,0 +1,30 @@
From a427929b0267a85ef6924aa3449077420beb23e0 Mon Sep 17 00:00:00 2001
From: Tianling Shen <i@cnsztl.eu.org>
Date: Sun, 24 Oct 2021 17:11:10 +0800
Subject: [PATCH] fix: read version from `Version` variable
Signed-off-by: Tianling Shen <i@cnsztl.eu.org>
---
main.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/main.go
+++ b/main.go
@@ -22,7 +22,7 @@ func init() {
cache.Init()
}
-var Version = "v1.0.3"
+var Version = "v1.0.12"
type Task struct {
Id string `json:"id"`
@@ -49,7 +49,7 @@ func main() {
flag.Parse()
if *versin {
- fmt.Println("v1.0.9")
+ fmt.Println(Version)
return
}
if len(*refreshToken) == 0 || len(os.Args) < 3 || os.Args[1] != "-rt" {

View File

@ -0,0 +1,15 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-go-aliyundrive-webdav
PKG_VERSION:=1.0.2
PKG_RELEASE:=20211031
PKG_MAINTAINER:=jerrykuku <jerrykuku@qq.com>
LUCI_TITLE:=Luci for go-aliyundrive-webdav
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+lua +libuci-lua +go-aliyundrive-webdav
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,23 @@
-- Copyright (C) 2021 jerryk <jerrykuku@qq.com>
-- This is free software, licensed under the APACHE LICENSE, VERSION 2.0.
module("luci.controller.go-aliyundrive-webdav", package.seeall)
function index()
if not nixio.fs.access("/etc/config/go-aliyundrive-webdav") then
return
end
entry({"admin", "services", "go-aliyundrive-webdav"}, alias("admin", "services", "go-aliyundrive-webdav", "client"),_("Go AliyunDrive WebDAV"), 10).dependent = true -- 首页
entry({"admin", "services", "go-aliyundrive-webdav", "client"}, cbi("go-aliyundrive-webdav/client"),_("Settings"), 1).leaf = true -- 客户端配置
entry({"admin", "services", "go-aliyundrive-webdav", "log"}, cbi("go-aliyundrive-webdav/log"),_("Log"), 2).leaf = true -- 日志页面
entry({"admin", "services", "go-aliyundrive-webdav", "status"}, call("action_status")).leaf = true
end
function action_status()
local e = {}
e.running = luci.sys.call("pidof go-aliyundrive-webdav >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -0,0 +1,49 @@
-- Copyright (C) 2021 jerryk <jerrykuku@qq.com>
-- This is free software, licensed under the APACHE LICENSE, VERSION 2.0.
local uci = luci.model.uci.cursor()
local m, e
m = Map("go-aliyundrive-webdav")
m.title = translate("Go AliyunDrive WebDAV")
m.description = translate("<a href=\"https://github.com/LinkLeong/go-aliyun-webdav\" target=\"_blank\">Project GitHub URL</a>")
m:section(SimpleSection).template = "go-aliyundrive-webdav/go-aliyundrive-webdav_status"
e = m:section(TypedSection, "go-aliyundrive-webdav")
e.anonymous = true
enable = e:option(Flag, "enabled", translate("Enabled"))
enable.rmempty = false
rt_token = e:option(Value, "rt", translate("Refresh Token"))
rt_token.description = translate("<a href=\"https://github.com/LinkLeong/go-aliyun-webdav#%E6%B5%8F%E8%A7%88%E5%99%A8%E8%8E%B7%E5%8F%96refreshtoken%E6%96%B9%E5%BC%8F\" target=\"_blank\">How to get refresh token</a>")
port = e:option(Value, "port", translate("Port"))
port.default = "8085"
port.datatype = "port"
path = e:option(Value, "path", translate("Mounting directory"))
path.description = translate("Access aliyundrive directory, defaults /.")
path.default = "/"
user = e:option(Value, "user", translate("Username"))
user.default = "admin"
pwd = e:option(Value, "pwd", translate("Password"))
pwd.password = true
pwd.default = "123456"
verbose = e:option(Flag, "verbose", translate("Enable detailed logging"))
verbose.default = "0"
verbose.rmempty = false
verbose.optional = false
local e = luci.http.formvalue("cbi.apply")
if e then
io.popen("/etc/init.d/go-aliyundrive-webdav restart")
end
return m

View File

@ -0,0 +1,4 @@
m = Map("log")
m.title = translate("Detailed Log (In Development)")
return m

View File

@ -0,0 +1,30 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[services]], [[go-aliyundrive-webdav]], [[status]])%>', null,
function (x, data) {
var tb = document.getElementById('go-aliyundrive-webdav_status');
if (data && tb) {
if (data.running) {
tb.innerHTML = '<em><b><font color=green> go-aliyundrive-webdav <%:RUNNING%></font></b></em>';
} else {
tb.innerHTML = '<em><b><font color=red> go-aliyundrive-webdav <%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>
.mar-10 {
margin-left: 50px;
margin-right: 10px;
}
</style>
<fieldset class="cbi-section">
<p id="go-aliyundrive-webdav_status">
<em>
<%:Collecting data...%>
</em>
</p>
</fieldset>

View File

@ -0,0 +1,58 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "Go AliyunDrive"
msgstr "Go 阿里云盘"
msgid "Go AliyunDrive WebDAV"
msgstr "Go 阿里云盘 WebDAV"
msgid "Enabled"
msgstr "启用"
msgid "Refresh Token"
msgstr "Refresh Token"
msgid "Port"
msgstr "监听端口"
msgid "Mounting directory"
msgstr "挂载目录"
msgid "Access aliyundrive directory, defaults /."
msgstr "访问 aliyundrive 目录,默认为 / 。"
msgid "Username"
msgstr "用户名"
msgid "Password"
msgstr "密码"
msgid "Collecting data..."
msgstr "获取数据中..."
msgid "RUNNING"
msgstr "运行中"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "Settings"
msgstr "设置"
msgid "Log"
msgstr "日志"
msgid "Detailed Log (In Development)"
msgstr "详细日志(开发中)"
msgid "Enable detailed logging"
msgstr "启用详细日志记录"
msgid "<a href=\"https://github.com/LinkLeong/go-aliyun-webdav\" target=\"_blank\">Project GitHub URL</a>"
msgstr "<a href=\"https://github.com/LinkLeong/go-aliyun-webdav\" target=\"_blank\">GitHub 项目地址</a>"
msgid "<a href=\"https://github.com/LinkLeong/go-aliyun-webdav#%E6%B5%8F%E8%A7%88%E5%99%A8%E8%8E%B7%E5%8F%96refreshtoken%E6%96%B9%E5%BC%8F\" target=\"_blank\">How to get refresh token</a>"
msgstr "<a href=\"https://github.com/LinkLeong/go-aliyun-webdav#%E6%B5%8F%E8%A7%88%E5%99%A8%E8%8E%B7%E5%8F%96refreshtoken%E6%96%B9%E5%BC%8F\" target=\"_blank\">查看获取 refresh token 的方法</a>"

View File

@ -0,0 +1 @@
zh-cn

View File

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

View File

@ -0,0 +1,11 @@
{
"luci-app-go-aliyundrive-webdav": {
"description": "Grant UCI access for luci-app-go-aliyundrive-webdav",
"read": {
"uci": [ "go-aliyundrive-webdav" ]
},
"write": {
"uci": [ "go-aliyundrive-webdav" ]
}
}
}