mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-08 11:57:57 +08:00
增加 filebrowser文件管理器NAS菜单中
This commit is contained in:
parent
c070ba9d3e
commit
2407c45bb8
68
filebrowser/Makefile
Normal file
68
filebrowser/Makefile
Normal file
@ -0,0 +1,68 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=filebrowser
|
||||
PKG_VERSION:=2.21.1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=b73d278
|
||||
PKG_SOURCE_URL:=https://github.com/filebrowser/filebrowser
|
||||
PKG_MIRROR_HASH:=66b9df31f98bec22715a7fe9ca73962c1e5a5c1b3bcfb99fd0ac1703118ee4c8
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=CN_SZTL <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host node/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
GO_PKG:=github.com/filebrowser/filebrowser
|
||||
GO_PKG_LDFLAGS_X:= \
|
||||
$(GO_PKG)/v2/version.CommitSHA=$(PKG_SOURCE_VERSION) \
|
||||
$(GO_PKG)/v2/version.Version=v$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/filebrowser
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Web File Browser
|
||||
URL:=https://github.com/filebrowser/filebrowser
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS)
|
||||
endef
|
||||
|
||||
define Package/filebrowser/description
|
||||
filebrowser provides a file managing interface within a specified directory
|
||||
and it can be used to upload, delete, preview, rename and edit your files.
|
||||
It allows the creation of multiple users and each user can have its own directory.
|
||||
It can be used as a standalone app or as a middleware.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
( \
|
||||
pushd "$(PKG_BUILD_DIR)/frontend" ; \
|
||||
npm ci; \
|
||||
npm run lint ; \
|
||||
npm run build ; \
|
||||
popd ; \
|
||||
$(call GoPackage/Build/Compile) ; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Package/filebrowser/install
|
||||
$(call GoPackage/Package/Install/Bin,$(1))
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(CURDIR)/files/filebrowser.config $(1)/etc/config/filebrowser
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(CURDIR)/files/filebrowser.init $(1)/etc/init.d/filebrowser
|
||||
endef
|
||||
|
||||
$(eval $(call GoBinPackage,filebrowser))
|
||||
$(eval $(call BuildPackage,filebrowser))
|
9
filebrowser/files/filebrowser.config
Normal file
9
filebrowser/files/filebrowser.config
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
config filebrowser 'config'
|
||||
option addr_type 'lan'
|
||||
option db_dir '/etc'
|
||||
option db_name 'filebrowser.db'
|
||||
option enabled '0'
|
||||
option port '8989'
|
||||
option root_dir '/'
|
||||
|
34
filebrowser/files/filebrowser.init
Normal file
34
filebrowser/files/filebrowser.init
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2021 ImmortalWrt
|
||||
|
||||
START=90
|
||||
STOP=10
|
||||
|
||||
addr_type="$(uci get filebrowser.config.addr_type)"
|
||||
db_dir="$(uci get filebrowser.config.db_dir)"
|
||||
[ "${db_dir}" == "/" ] || db_dir="${db_dir%*/}"
|
||||
db_name="$(uci get filebrowser.config.db_name| sed 's#/##g')"
|
||||
enabled="$(uci get filebrowser.config.enabled)"
|
||||
port="$(uci get filebrowser.config.port)"
|
||||
root_dir="$(uci get filebrowser.config.root_dir)"
|
||||
|
||||
if [ "${addr_type}" == "local" ];then
|
||||
addr="127.0.0.1"
|
||||
elif [ "${addr_type}" == "lan" ];then
|
||||
addr="$(uci get network.lan.ipaddr)"
|
||||
elif [ "${addr_type}" == "wan" ];then
|
||||
addr="0.0.0.0"
|
||||
fi
|
||||
|
||||
start() {
|
||||
stop
|
||||
[ "$enabled" == "1" ] || exit 0
|
||||
mkdir -p "${root_dir}"
|
||||
mkdir -p "${db_dir}"
|
||||
filebrowser -a "${addr}" -d "${db_dir}/${db_name}" -p "${port}" -r "${root_dir}" >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "${db_dir}/${db_name}" > "/lib/upgrade/keep.d/filebrowser"
|
||||
killall -9 filebrowser >/dev/null 2>&1
|
||||
}
|
22
luci-app-filebrowser/Makefile
Normal file
22
luci-app-filebrowser/Makefile
Normal file
@ -0,0 +1,22 @@
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt
|
||||
# <https://immortalwrt.org>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI Support for FileBrowser
|
||||
LUCI_DEPENDS:=+filebrowser
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_NAME:=luci-app-filebrowser
|
||||
PKG_VERSION:=snapshot
|
||||
PKG_RELEASE:=118071b
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
22
luci-app-filebrowser/luasrc/controller/filebrowser.lua
Normal file
22
luci-app-filebrowser/luasrc/controller/filebrowser.lua
Normal file
@ -0,0 +1,22 @@
|
||||
module("luci.controller.filebrowser", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/filebrowser") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "nas"}, firstchild(), _("NAS"), 45).dependent = false
|
||||
|
||||
local page = entry({"admin", "nas", "filebrowser"}, cbi("filebrowser"), _("文件管理器"), 100)
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-filebrowser" }
|
||||
|
||||
entry({"admin", "nas", "filebrowser", "status"}, call("act_status")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("pgrep filebrowser >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
42
luci-app-filebrowser/luasrc/model/cbi/filebrowser.lua
Normal file
42
luci-app-filebrowser/luasrc/model/cbi/filebrowser.lua
Normal file
@ -0,0 +1,42 @@
|
||||
m = Map("filebrowser", translate("文件管理器"), translate("FileBrowser是一个基于Go的在线文件管理器,助您方便的管理设备上的文件。"))
|
||||
|
||||
m:section(SimpleSection).template = "filebrowser/filebrowser_status"
|
||||
|
||||
s = m:section(TypedSection, "filebrowser")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "enabled", translate("启用"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "addr_type", translate("监听地址"))
|
||||
o:value("local", translate("监听本机地址"))
|
||||
o:value("lan", translate("监听局域网地址"))
|
||||
o:value("wan", translate("监听全部地址"))
|
||||
o.default = "lan"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "port", translate("监听端口"))
|
||||
o.placeholder = 8989
|
||||
o.default = 8989
|
||||
o.datatype = "port"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "root_dir", translate("开放目录"))
|
||||
o.placeholder = "/"
|
||||
o.default = "/"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "db_dir", translate("数据库目录"))
|
||||
o.description = translate("普通用户请勿随意更改")
|
||||
o.placeholder = "/etc"
|
||||
o.default = "/etc"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "db_name", translate("数据库名"))
|
||||
o.description = translate("普通用户请勿随意更改")
|
||||
o.placeholder = "filebrowser.db"
|
||||
o.default = "filebrowser.db"
|
||||
o.rmempty = false
|
||||
|
||||
return m
|
@ -0,0 +1,27 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(1, '<%=url([[admin]], [[nas]], [[filebrowser]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('filebrowser_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<font color=green>Filebrowser <%:运行中%></font><input class="cbi-button mar-10" type="button" value="<%:打开管理界面%>" onclick="openwebui();" />';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<font color=red>Filebrowser <%:未运行%></font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function openwebui(){
|
||||
var url = window.location.host+":<%=luci.sys.exec("uci -q get filebrowser.config.port"):gsub("^%s*(.-)%s*$", "%1")%>";
|
||||
window.open('http://'+url,'target','');
|
||||
};
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="filebrowser_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
11
luci-app-filebrowser/root/etc/uci-defaults/luci-filebrowser
Normal file
11
luci-app-filebrowser/root/etc/uci-defaults/luci-filebrowser
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@filebrowser[-1]
|
||||
add ucitrack filebrowser
|
||||
set ucitrack.@filebrowser[-1].init=filebrowser
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-filebrowser": {
|
||||
"description": "Grant UCI access for luci-app-filebrowser",
|
||||
"read": {
|
||||
"uci": [ "filebrowser" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "filebrowser" ]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user