From e3e03876c22f1d54666e65f9e1948164bb718707 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Thu, 30 Apr 2020 10:14:30 +0800 Subject: [PATCH] add rclone package and luci-app-rclone --- package/lean/luci-app-rclone/Makefile | 37 ++++ .../luasrc/controller/rclone.lua | 7 + .../luasrc/model/cbi/rclone.lua | 138 +++++++++++++++ package/lean/luci-app-rclone/po/en/rclone.po | 110 ++++++++++++ .../po/templates/luci-app-rclone.pot | 134 ++++++++++++++ .../lean/luci-app-rclone/po/zh-cn/rclone.po | 1 + .../po/zh_Hans/luci-app-rclone.po | 167 ++++++++++++++++++ .../luci-app-rclone/root/etc/config/rclone | 17 ++ .../luci-app-rclone/root/etc/init.d/rclone | 100 +++++++++++ .../root/etc/uci-defaults/100_luci-rclone | 11 ++ .../usr/share/rpcd/acl.d/luci-app-rclone.json | 11 ++ package/lean/rclone-webui-react/Makefile | 58 ++++++ package/lean/rclone/Makefile | 77 ++++++++ .../rclone/patches/000-disable-plugins.patch | 22 +++ 14 files changed, 890 insertions(+) create mode 100644 package/lean/luci-app-rclone/Makefile create mode 100644 package/lean/luci-app-rclone/luasrc/controller/rclone.lua create mode 100644 package/lean/luci-app-rclone/luasrc/model/cbi/rclone.lua create mode 100644 package/lean/luci-app-rclone/po/en/rclone.po create mode 100644 package/lean/luci-app-rclone/po/templates/luci-app-rclone.pot create mode 120000 package/lean/luci-app-rclone/po/zh-cn/rclone.po create mode 100644 package/lean/luci-app-rclone/po/zh_Hans/luci-app-rclone.po create mode 100644 package/lean/luci-app-rclone/root/etc/config/rclone create mode 100755 package/lean/luci-app-rclone/root/etc/init.d/rclone create mode 100755 package/lean/luci-app-rclone/root/etc/uci-defaults/100_luci-rclone create mode 100644 package/lean/luci-app-rclone/root/usr/share/rpcd/acl.d/luci-app-rclone.json create mode 100644 package/lean/rclone-webui-react/Makefile create mode 100644 package/lean/rclone/Makefile create mode 100644 package/lean/rclone/patches/000-disable-plugins.patch diff --git a/package/lean/luci-app-rclone/Makefile b/package/lean/luci-app-rclone/Makefile new file mode 100644 index 000000000..0a10544d5 --- /dev/null +++ b/package/lean/luci-app-rclone/Makefile @@ -0,0 +1,37 @@ +#### + # File: /Makefile + # Project: luci-app-rclone + # File Created: Wednesday, 9th October 2019 1:39:36 pm + # Author: ElonH[EH](elonhhuang@gmail.com) + # License: GNU General Public License v3.0 or later(http://www.gnu.org/licenses/gpl-3.0-standalone.html) + # Copyright (C) 2019 [ElonH] +#### + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support for Rclone +LUCI_DEPENDS:=+rclone +rclone-webui-react +LUCI_PKGARCH:=all +PKG_NAME:=luci-app-rclone +PKG_VERSION:=1.3.21 +PKG_RELEASE:=1 +PKG_LICENSE:=GPLv3.0+ +PKG_MAINTAINER:=ElonH + +define Package/luci-app-rclone/description + LuCI support for Rclone. + Rclone ("rsync for cloud storage") is a command line program to sync root/usr/bin and directories to and from different cloud storage providers. + Cloud storage providers: + 1Fichier, Alibaba Cloud (Aliyun) Object Storage System (OSS), Amazon Drive, Amazon S3, + Backblaze B2, Box, Ceph, C14, DigitalOcean Spaces, Dreamhost, Dropbox, FTP, + Google Cloud Storage, Google Drive, Google Photos, HTTP, Hubic, Jottacloud, + IBM COS S3, Koofr, Memset Memstore, Mega, Microsoft Azure Blob Storage, + Microsoft OneDrive, Minio, Nextcloud, OVH, OpenDrive, Openstack Swift, + Oracle Cloud Storage, ownCloud, pCloud, premiumize.me, put.io, QingStor, + Rackspace Cloud root/usr/bin, rsync.net, Scaleway, SFTP, Wasabi, WebDAV, + Yandex Disk, The local root/usr/binystem. +endef + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/package/lean/luci-app-rclone/luasrc/controller/rclone.lua b/package/lean/luci-app-rclone/luasrc/controller/rclone.lua new file mode 100644 index 000000000..5b1028066 --- /dev/null +++ b/package/lean/luci-app-rclone/luasrc/controller/rclone.lua @@ -0,0 +1,7 @@ +module("luci.controller.rclone", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/rclone") then return end + entry({"admin", "nas"}, firstchild(), _("NAS") , 45).dependent = false + entry({"admin", "nas", "rclone"}, cbi("rclone"), _("Rclone"), 100 ).dependent = false +end diff --git a/package/lean/luci-app-rclone/luasrc/model/cbi/rclone.lua b/package/lean/luci-app-rclone/luasrc/model/cbi/rclone.lua new file mode 100644 index 000000000..aa9312aa0 --- /dev/null +++ b/package/lean/luci-app-rclone/luasrc/model/cbi/rclone.lua @@ -0,0 +1,138 @@ +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 rclone > /dev/null') == 0) + +local state_msg = '' +local trport = uci:get('rclone', 'config', 'port') + +local triptype = uci:get('rclone', 'config', 'addr_type') +local trip = '' + +if triptype == 'local' then + trip = uci:get('network', 'loopback', 'ipaddr') +elseif triptype == 'lan' then + trip = uci:get('network', 'lan', 'ipaddr') +else + trip = '[ip]' +end + +if running then + state_msg = '' .. translate('rclone running') .. '' + address_msg = translate('rclone address') .. ' : http://' .. trip .. ':' .. trport .. '

' +else + state_msg = '' .. translate('rclone not run') .. '' + address_msg = '' +end + +m = + Map( + 'rclone', + translate('Rclone'), + translate('Rclone ("rsync for cloud storage") is a command line program to sync root/usr/bin and directories to and from different cloud storage providers.') .. + '

' .. translate('rclone state') .. ' : ' .. state_msg .. '

' + .. address_msg .. + translate('Installed Web Interface') .. + '      

" +) + +s = m:section(TypedSection, 'global', translate('global')) +s.addremove = false +s.anonymous = true + +enable = s:option(Flag, 'enabled', translate('run Rclone as daemon')) +enable.rmempty = false + +s = m:section(TypedSection, 'conf', translate('configure')) +s.addremove = false +s.anonymous = true + +o = s:option(ListValue, 'addr_type', translate('listen address')) +o:value('local', translate('localhost address')) +o:value('lan', translate('local network address')) +o:value('all', translate('all address')) +o.default = 'lan' +o.rmempty = false + +o = s:option(Value, 'port', translate('listen port')) +o.placeholder = 5572 +o.default = 5572 +o.datatype = 'port' +o.rmempty = false + +o = s:option(Value, 'config_path', translate('rclone configuration file path')) +o.placeholder = '/etc/rclone/rclone.conf' +o.default = '/etc/rclone/rclone.conf' +o.rmempty = false +o.description = translate("Recommand: run ") .. + "rclone config --config rclone.conf" .. + translate(" to setup configuration on pc,") .. "
" .. translate("than updaload configuration to here.") + +o = s:option(Button,"config_download",translate("download configuration")) +o.inputtitle = translate("download") +o.inputstyle = "apply" +o.write = function() + Download() +end + +function Download() + local t,e + t=nixio.open(uci:get('rclone', 'config', 'config_path'),"r") + luci.http.header('Content-Disposition','attachment; filename="rclone.conf"') + luci.http.prepare_content("application/octet-stream") + while true do + e=t:read(nixio.const.buffersize) + if(not e)or(#e==0)then + break + else + luci.http.write(e) + end + end + t:close() + luci.http.close() +end + +o = s:option(Value, 'username', translate('username')) +o.placeholder = 'admin' +o.default = 'admin' +o.rmempty = false + +o = s:option(Value, 'password', translate('password')) +o.password = true +o.placeholder = 'admin' +o.default = 'admin' +o.rmempty = false + +s = m:section(TypedSection, 'proxy', translate('proxy')) +s.addremove = false +s.anonymous = true +s.description = "" + ..translate("FAQ").."" + +enable = s:option(Flag, 'enabled', translate('enable proxy')) +enable.rmempty = false + +o = s:option(Value, 'proxy_addr', translate('proxy address')) +o.placeholder = 'socks5://127.0.0.1:1080' +o.default = 'socks5://127.0.0.1:1080' +o.rmempty = false +o.description = translate("The content of the variable is protocol://server:port. The protocol value is commonly either http or socks5.") + +s = m:section(TypedSection, 'log', translate('log')) +s.addremove = false +s.anonymous = true + +o = s:option(Value, 'path', translate('path')) +o.placeholder = '/var/log/rclone/output' +o.default = '/var/log/rclone/output' +o.rmempty = false + +return m diff --git a/package/lean/luci-app-rclone/po/en/rclone.po b/package/lean/luci-app-rclone/po/en/rclone.po new file mode 100644 index 000000000..a71070ee0 --- /dev/null +++ b/package/lean/luci-app-rclone/po/en/rclone.po @@ -0,0 +1,110 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: PACKAGE VERSION\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:41 +msgid "Installed Web Interface" +msgstr "Installed Web Interface" + +#: luci-app-rclone/luasrc/controller/rclone.lua:7 +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:37 +msgid "Rclone" +msgstr "Rclone" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:38 +msgid "" +"Rclone (\"rsync for cloud storage\") is a command line program to sync root/" +"usr/bin and directories to and from different cloud storage providers." +msgstr "" +"Rclone (\"rsync for cloud storage\") is a command line program to sync root/" +"usr/bin and directories to and from different cloud storage providers." + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:43 +msgid "Webui React" +msgstr "Webui React" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:61 +msgid "all address" +msgstr "all address" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:54 +msgid "configure" +msgstr "configure" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:77 +msgid "download" +msgstr "download" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:76 +msgid "download configuration" +msgstr "download configuration" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:47 +msgid "global" +msgstr "global" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:58 +msgid "listen address" +msgstr "listen address" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:65 +msgid "listen port" +msgstr "listen port" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:60 +msgid "local network address" +msgstr "local network address" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:59 +msgid "localhost address" +msgstr "localhost address" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:111 +msgid "log" +msgstr "log" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:105 +msgid "password" +msgstr "password" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:115 +msgid "path" +msgstr "path" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:28 +msgid "rclone address" +msgstr "" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:71 +msgid "rclone configuration file path" +msgstr "rclone configuration file path" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:30 +msgid "rclone not run" +msgstr "rclone not run" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:27 +msgid "rclone running" +msgstr "rclone running" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:39 +msgid "rclone state" +msgstr "rclone state" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:51 +msgid "run Rclone as daemon" +msgstr "run Rclone as daemon" + +#: luci-app-rclone/luasrc/model/cbi/rclone.lua:100 +msgid "username" +msgstr "username" + +#~ msgid "run Rclone in daeman" +#~ msgstr "run Rclone in daeman" diff --git a/package/lean/luci-app-rclone/po/templates/luci-app-rclone.pot b/package/lean/luci-app-rclone/po/templates/luci-app-rclone.pot new file mode 100644 index 000000000..7df760f2b --- /dev/null +++ b/package/lean/luci-app-rclone/po/templates/luci-app-rclone.pot @@ -0,0 +1,134 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: luasrc/model/cbi/rclone.lua:118 +msgid "FAQ" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:41 +msgid "Installed Web Interface" +msgstr "" + +#: luasrc/controller/rclone.lua:5 +msgid "NAS" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:37 luasrc/controller/rclone.lua:6 +msgid "Rclone" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:38 +msgid "" +"Rclone (\"rsync for cloud storage\") is a command line program to sync root/" +"usr/bin and directories to and from different cloud storage providers." +msgstr "" + +#: luasrc/model/cbi/rclone.lua:75 +msgid "Recommand: run" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:127 +msgid "" +"The content of the variable is protocol://server:port. The protocol value is " +"commonly either http or socks5." +msgstr "" + +#: luasrc/model/cbi/rclone.lua:43 +msgid "Webui React" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:61 +msgid "all address" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:54 +msgid "configure" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:80 +msgid "download" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:79 +msgid "download configuration" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:120 +msgid "enable proxy" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:47 +msgid "global" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:58 +msgid "listen address" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:65 +msgid "listen port" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:60 +msgid "local network address" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:59 +msgid "localhost address" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:129 +msgid "log" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:108 +msgid "password" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:133 +msgid "path" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:114 +msgid "proxy" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:123 +msgid "proxy address" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:28 +msgid "rclone address" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:71 +msgid "rclone configuration file path" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:30 +msgid "rclone not run" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:27 +msgid "rclone running" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:39 +msgid "rclone state" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:51 +msgid "run Rclone as daemon" +msgstr "" + +#: luasrc/model/cbi/rclone.lua:77 +msgid "than updaload configuration to here." +msgstr "" + +#: luasrc/model/cbi/rclone.lua:77 +msgid "to setup configuration on pc," +msgstr "" + +#: luasrc/model/cbi/rclone.lua:103 +msgid "username" +msgstr "" diff --git a/package/lean/luci-app-rclone/po/zh-cn/rclone.po b/package/lean/luci-app-rclone/po/zh-cn/rclone.po new file mode 120000 index 000000000..b08e41a9d --- /dev/null +++ b/package/lean/luci-app-rclone/po/zh-cn/rclone.po @@ -0,0 +1 @@ +../zh_Hans/luci-app-rclone.po \ No newline at end of file diff --git a/package/lean/luci-app-rclone/po/zh_Hans/luci-app-rclone.po b/package/lean/luci-app-rclone/po/zh_Hans/luci-app-rclone.po new file mode 100644 index 000000000..3afed25cc --- /dev/null +++ b/package/lean/luci-app-rclone/po/zh_Hans/luci-app-rclone.po @@ -0,0 +1,167 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: \n" +"Last-Translator: ElonH \n" +"Language-Team: none\n" +"Language: zh-Hans\n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"X-Generator: Poedit 2.0.6\n" + +#: luasrc/model/cbi/rclone.lua:118 +msgid "FAQ" +msgstr "常见问题" + +#: luasrc/model/cbi/rclone.lua:41 +msgid "Installed Web Interface" +msgstr "已安装Web界面" + +#: luasrc/controller/rclone.lua:5 +msgid "NAS" +msgstr "存储" + +#: luasrc/model/cbi/rclone.lua:37 luasrc/controller/rclone.lua:6 +msgid "Rclone" +msgstr "Rclone" + +#: luasrc/model/cbi/rclone.lua:38 +msgid "" +"Rclone (\"rsync for cloud storage\") is a command line program to sync root/" +"usr/bin and directories to and from different cloud storage providers." +msgstr "" +"Rclone是一款的命令行工具,支持在不同对象存储、网盘间同步、上传、下载数据。" + +#: luasrc/model/cbi/rclone.lua:75 +msgid "Recommand: run" +msgstr "建议: 在 PC 上运行" + +#: luasrc/model/cbi/rclone.lua:127 +msgid "" +"The content of the variable is protocol://server:port. The protocol value is " +"commonly either http or socks5." +msgstr "" +"内容格式为: protocol://server:port\n" +"protocol 通常为 http 或者 socks5" + +#: luasrc/model/cbi/rclone.lua:43 +msgid "Webui React" +msgstr "Webui React" + +#: luasrc/model/cbi/rclone.lua:61 +msgid "all address" +msgstr "全部地址" + +#: luasrc/model/cbi/rclone.lua:54 +msgid "configure" +msgstr "配置" + +#: luasrc/model/cbi/rclone.lua:80 +msgid "download" +msgstr "下载" + +#: luasrc/model/cbi/rclone.lua:79 +msgid "download configuration" +msgstr "下载配置文件" + +#: luasrc/model/cbi/rclone.lua:120 +msgid "enable proxy" +msgstr "启用代理" + +#: luasrc/model/cbi/rclone.lua:47 +msgid "global" +msgstr "全局" + +#: luasrc/model/cbi/rclone.lua:58 +msgid "listen address" +msgstr "监听地址" + +#: luasrc/model/cbi/rclone.lua:65 +msgid "listen port" +msgstr "监听端口" + +#: luasrc/model/cbi/rclone.lua:60 +msgid "local network address" +msgstr "局域网地址" + +#: luasrc/model/cbi/rclone.lua:59 +msgid "localhost address" +msgstr "本机地址" + +#: luasrc/model/cbi/rclone.lua:129 +msgid "log" +msgstr "日志" + +#: luasrc/model/cbi/rclone.lua:108 +msgid "password" +msgstr "密码" + +#: luasrc/model/cbi/rclone.lua:133 +msgid "path" +msgstr "路径" + +#: luasrc/model/cbi/rclone.lua:114 +msgid "proxy" +msgstr "代理" + +#: luasrc/model/cbi/rclone.lua:123 +msgid "proxy address" +msgstr "代理地址" + +#: luasrc/model/cbi/rclone.lua:28 +msgid "rclone address" +msgstr "rclone 地址" + +#: luasrc/model/cbi/rclone.lua:71 +msgid "rclone configuration file path" +msgstr "rclone 配置文件地址" + +#: luasrc/model/cbi/rclone.lua:30 +msgid "rclone not run" +msgstr "rclone未运行" + +#: luasrc/model/cbi/rclone.lua:27 +msgid "rclone running" +msgstr "rclone 运行中" + +#: luasrc/model/cbi/rclone.lua:39 +msgid "rclone state" +msgstr "rclone 状态" + +#: luasrc/model/cbi/rclone.lua:51 +msgid "run Rclone as daemon" +msgstr "启动 rclone 后台服务" + +#: luasrc/model/cbi/rclone.lua:77 +msgid "than updaload configuration to here." +msgstr "然后上传配置文件到这里" + +#: luasrc/model/cbi/rclone.lua:77 +msgid "to setup configuration on pc," +msgstr "命令设置 rclone 配置文件," + +#: luasrc/model/cbi/rclone.lua:103 +msgid "username" +msgstr "用户名" + +#~ msgid "Hosts must be comma separated, and can contain domains or parts." +#~ msgstr "用逗号分隔地址,且地址必须包含(部分)域名" + +#~ msgid "This allows you to disable the proxy for specific hosts." +#~ msgstr "这允许不代理特定的地址." + +#~ msgid "How to proxy rclone" +#~ msgstr "如何代理rclone" + +#~ msgid "disable proxy for specific hosts" +#~ msgstr "针对特定主机禁用代理" + +#~ msgid "" +#~ "rclone will follow the standard environment variables for proxies, " +#~ "similar to cURL and other programs." +#~ msgstr "rclone 会使用代理的标准环境变量,类似于 cURL 及其他程序。" + +#~ msgid "run Rclone in daeman" +#~ msgstr "启动 rclone 后台服务" diff --git a/package/lean/luci-app-rclone/root/etc/config/rclone b/package/lean/luci-app-rclone/root/etc/config/rclone new file mode 100644 index 000000000..1440200ca --- /dev/null +++ b/package/lean/luci-app-rclone/root/etc/config/rclone @@ -0,0 +1,17 @@ + +config global 'global' + option enabled '0' + +config conf 'config' + option config_path '/etc/rclone/rclone.conf' + option port '5572' + option username 'admin' + option password 'admin' + option addr_type 'lan' + +config proxy 'proxy' + option enabled '0' + option proxy_addr 'socks5://127.0.0.1:1080' + +config log 'log' + option path '/var/log/rclone/output' diff --git a/package/lean/luci-app-rclone/root/etc/init.d/rclone b/package/lean/luci-app-rclone/root/etc/init.d/rclone new file mode 100755 index 000000000..15205215c --- /dev/null +++ b/package/lean/luci-app-rclone/root/etc/init.d/rclone @@ -0,0 +1,100 @@ +#!/bin/bash /etc/rc.common +# Copyright (C) 2019 ElonH + +USE_PROCD=1 +START=95 +STOP=10 + +APP=rclone +CONFIGURATION=rclone + +_info() { + logger -p daemon.info -t "$APP" "$*" +} + +_err() { + logger -p daemon.err -t "$APP" "$*" +} + +init_config() { + config_load "${CONFIGURATION}" + # Create rclone dirs + local config_path + local config_dir + local log_path + local log_dir + + config_get config_path config config_path + config_get log_path log path + + config_dir=${config_path%/*} + [ -d "$config_dir" ] || mkdir -p "$config_dir" 2>/dev/null + + [ -f "$config_path" ] || touch "$config_path" + + log_dir=${log_path%/*} + [ -d "$log_dir" ] || mkdir -p "$log_dir" 2>/dev/null && echo /dev/null > "$log_path" + + +} + +start_service() { + init_config + + local enabled + local config_path + local addr_type + local port + local username + local password + local proxy_enable + local proxy_addr + local log_path + + config_get enabled global enabled + + config_get config_path config config_path + config_get addr_type config addr_type + config_get port config port + config_get username config username + config_get password config password + + config_get proxy_enable proxy enabled + config_get proxy_addr proxy proxy_addr + + config_get log_path log path + + if [[ "${addr_type}" == "local" ]]; then + addr="$(uci get network.loopback.ipaddr)" + elif [[ "${addr_type}" == "lan" ]]; then + addr="$(uci get network.lan.ipaddr)" + elif [[ "${addr_type}" == "all" ]]; then + addr="" + fi + [ "$enabled" == "1" ] || { _info "Instance \"rclone\" disabled."; return 1; } + _info "Instance \"rclone\" start." + procd_open_instance + procd_set_param command /usr/bin/$APP rcd -vv + procd_append_param command "--rc-addr=$addr:$port" + procd_append_param command "--rc-user=$username" "--rc-pass=$password" + procd_append_param command "--config=$config_path" + procd_append_param command "--rc-allow-origin=*" + procd_append_param command "--log-file=${log_path}" + if [[ "${proxy_enable}" == "1" ]]; then + procd_set_param env all_proxy="$proxy_addr" https_proxy="$proxy_addr" http_proxy="$proxy_addr" + procd_set_param env ALL_PROXY="$proxy_addr" HTTPS_PROXY="$proxy_addr" HTTP_PROXY="$proxy_addr" + fi + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_set_param file /etc/config/rclone + # procd_set_param pidfile /var/run/rclone.pid + procd_set_param user rclone + procd_set_param group rclone + procd_set_param respawn retry=60 + procd_close_instance + +} + +service_triggers() { + procd_add_reload_trigger "rclone" +} diff --git a/package/lean/luci-app-rclone/root/etc/uci-defaults/100_luci-rclone b/package/lean/luci-app-rclone/root/etc/uci-defaults/100_luci-rclone new file mode 100755 index 000000000..3d7a46247 --- /dev/null +++ b/package/lean/luci-app-rclone/root/etc/uci-defaults/100_luci-rclone @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@rclone[-1] + add ucitrack rclone + set ucitrack.@rclone[-1].init=rclone + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/package/lean/luci-app-rclone/root/usr/share/rpcd/acl.d/luci-app-rclone.json b/package/lean/luci-app-rclone/root/usr/share/rpcd/acl.d/luci-app-rclone.json new file mode 100644 index 000000000..0a664ef43 --- /dev/null +++ b/package/lean/luci-app-rclone/root/usr/share/rpcd/acl.d/luci-app-rclone.json @@ -0,0 +1,11 @@ +{ + "luci-app-rclone": { + "description": "Grant UCI access for luci-app-rclone", + "read": { + "uci": ["rclone"] + }, + "write": { + "uci": ["rclone"] + } + } +} diff --git a/package/lean/rclone-webui-react/Makefile b/package/lean/rclone-webui-react/Makefile new file mode 100644 index 000000000..0e359d587 --- /dev/null +++ b/package/lean/rclone-webui-react/Makefile @@ -0,0 +1,58 @@ +#### + # File: /Makefile + # Project: rclone-webui-react + # File Created: Thursday, 10th October 2019 5:57:39 pm + # Author: ElonH[EH](elonhhuang@gmail.com) + # License: GNU General Public License v3.0 or later(http://www.gnu.org/licenses/gpl-3.0-standalone.html) + # Copyright (C) 2019 [ElonH] +#### + +include $(TOPDIR)/rules.mk + +PKG_NAME:=rclone-webui-react +PKG_VERSION:=0.1.0 +PKG_RELEASE:=1 + + +PKG_LICENSE:=GPLv3 +PKG_MAINTAINER:=ElonH + +include $(INCLUDE_DIR)/package.mk + +PKG_SOURCE:=currentbuild.zip +PKG_SOURCE_URL:=https://github.com/rclone/rclone-webui-react/releases/download/v$(PKG_VERSION)/ +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) +PKG_HASH:=06b9401779f82ef62fd22a9688549664228797d094b645a68a098c2310461fc5 + +define Package/$(PKG_NAME) + SECTION:=net + CATEGORY:=Network + SUBMENU:=File Transfer + SUBMENU:=Cloud Manager + TITLE:=A reactjs based web UI for rclone + URL:=https://github.com/rclone/rclone-webui-react + PKGARCH:=all +endef + +define Package/$(PKG_NAME)/description + A full fledged UI for the rclone cloud sync tool. +endef + +define Build/Prepare + mkdir -vp $(PKG_BUILD_DIR) + unzip -od $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE) +endef + +define Build/Configure +endef + +define Build/Compile + echo "$(PKG_NAME) Compile Skiped!" +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/www/rclone-webui-react + $(CP) $(PKG_BUILD_DIR)/build/* $(1)/www/rclone-webui-react +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/lean/rclone/Makefile b/package/lean/rclone/Makefile new file mode 100644 index 000000000..747a8f1b7 --- /dev/null +++ b/package/lean/rclone/Makefile @@ -0,0 +1,77 @@ +#### + # File: /Makefile + # Project: rclone + # File Created: Friday, 11th October 2019 4:50:49 pm + # Author: ElonH[EH](elonhhuang@gmail.com) + # License: GNU General Public License v3.0 or later(http://www.gnu.org/licenses/gpl-3.0-standalone.html) + # Copyright (C) 2019 [ElonH] +#### + +include $(TOPDIR)/rules.mk + +PKG_NAME:=rclone +PKG_VERSION:=1.51.0 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/rclone/rclone.git +PKG_SOURCE_DATE:=2020-02-01 +PKG_SOURCE_VERSION:=43daecd89b21292b112051340317927b42ccbdd3 +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz +PKG_MIRROR_HASH:=aca159c81971a9490a6a6c323b67879dccba3860955b66787d91590f4ba8ba29 + +PKG_LICENSE:=GPLv3 +PKG_MAINTAINER:=ElonH + +PKG_BUILD_DEPENDS:=golang/host +PKG_BUILD_PARALLEL:=1 +PKG_USE_MIPS16:=0 # https://github.com/openwrt/packages/issues/8498 +GO_PKG:=github.com/rclone/rclone +GO_PKG_EXCLUDES:=test + +include $(INCLUDE_DIR)/package.mk +include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk + +# GO_PKG_LDFLAGS:= +GO_PKG_LDFLAGS_X:=\ + github.com/rclone/rclone/fs.Version=v$(PKG_VERSION)_$(PKG_SOURCE_DATE)\ + main.Version=v$(PKG_VERSION) \ + main.BuildUser=openwrt \ + main.BuildHost=openwrt \ + main.BuildStamp=$(SOURCE_DATE_EPOCH) + +define Package/$(PKG_NAME) + SECTION:=utils + CATEGORY:=Utilities + TITLE:=rsync for cloud storage. + URL:=https://rclone.org + DEPENDS:=$(GO_ARCH_DEPENDS) +endef + +define Package/$(PKG_NAME)/description +Rclone ("rsync for cloud storage") is a command line program to sync root/usr/bin and directories to and from different cloud storage providers. +Cloud storage providers: + 1Fichier, Alibaba Cloud (Aliyun) Object Storage System (OSS), Amazon Drive, Amazon S3, + Backblaze B2, Box, Ceph, C14, DigitalOcean Spaces, Dreamhost, Dropbox, FTP, + Google Cloud Storage, Google Drive, Google Photos, HTTP, Hubic, Jottacloud, + IBM COS S3, Koofr, Memset Memstore, Mega, Microsoft Azure Blob Storage, + Microsoft OneDrive, Minio, Nextcloud, OVH, OpenDrive, Openstack Swift, + Oracle Cloud Storage, ownCloud, pCloud, premiumize.me, put.io, QingStor, + Rackspace Cloud root/usr/bin, rsync.net, Scaleway, SFTP, Wasabi, WebDAV, + Yandex Disk, The local root/usr/binystem. +endef + +define Package/$(PKG_NAME)/install + # echo "++++++++++++++++++" + # echo "$(PKG_INSTALL_DIR)" + # echo "$(1)" + # echo "$(GO_PKG_BUILD_BIN_DIR)" + # echo "++++++++++++++++++" + + $(INSTALL_DIR) $(1)/usr/bin/ + $(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/rclone $(1)/usr/bin/ +endef + +$(eval $(call GoBinPackage,$(PKG_NAME))) +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/package/lean/rclone/patches/000-disable-plugins.patch b/package/lean/rclone/patches/000-disable-plugins.patch new file mode 100644 index 000000000..34b648659 --- /dev/null +++ b/package/lean/rclone/patches/000-disable-plugins.patch @@ -0,0 +1,22 @@ +## +# File: /patches/000-disable-plugins.patch +# Project: rclone +# Created Date: Wednesday, January 1st 2020, 1:49:43 pm +# Author: ElonH[EH](elonhhuang@gmail.com) +# License: GNU General Public License v3.0 or later(http://www.gnu.org/licenses/gpl-3.0-standalone.html) +# Copyright (C) 2019 [ElonH] +## +# refs: https://github.com/openwrt/packages/issues/10864#issuecomment-569921457 +diff --git a/rclone.go b/rclone.go +index 74fde16ab..9a9ba9150 100644 +--- a/rclone.go ++++ b/rclone.go +@@ -7,7 +7,7 @@ import ( + _ "github.com/rclone/rclone/backend/all" // import all backends + "github.com/rclone/rclone/cmd" + _ "github.com/rclone/rclone/cmd/all" // import all commands +- _ "github.com/rclone/rclone/lib/plugin" // import plugins ++ // _ "github.com/rclone/rclone/lib/plugin" // import plugins + ) + + func main() {