mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
dufs: add new package
Dufs is a distinctive utility file server that supports static serving, uploading, searching, accessing control, webdav... Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
committed by
Tianling Shen
parent
7222ac88f0
commit
2c8a641e0a
54
net/dufs/Makefile
Normal file
54
net/dufs/Makefile
Normal file
@@ -0,0 +1,54 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Copyright (C) 2024-2025 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dufs
|
||||
PKG_VERSION:=0.43.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/sigoden/dufs/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=4ba3b90486336efc4e592bcf15f14d4e3b6ac7b3b1bf8770815b8c43975d8b01
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=Apache-2.0 MIT
|
||||
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT
|
||||
|
||||
PKG_BUILD_DEPENDS:=rust/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include ../../lang/rust/rust-package.mk
|
||||
|
||||
define Package/dufs
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=A distinctive utility file server
|
||||
URL:=https://github.com/sigoden/dufs
|
||||
DEPENDS:=$(RUST_ARCH_DEPENDS) @!(i386||mips64) +liblzma
|
||||
endef
|
||||
|
||||
define Package/dufs/description
|
||||
Dufs is a distinctive utility file server that supports static
|
||||
serving, uploading, searching, accessing control, webdav...
|
||||
endef
|
||||
|
||||
define Package/dufs/conffiles
|
||||
/etc/config/dufs
|
||||
endef
|
||||
|
||||
define Package/dufs/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/dufs $(1)/usr/bin/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(CURDIR)/files/dufs.config $(1)/etc/config/dufs
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(CURDIR)/files/dufs.init $(1)/etc/init.d/dufs
|
||||
endef
|
||||
|
||||
$(eval $(call RustBinPackage,dufs))
|
||||
$(eval $(call BuildPackage,dufs))
|
||||
46
net/dufs/files/dufs.config
Normal file
46
net/dufs/files/dufs.config
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
config dufs 'config'
|
||||
option enabled '0'
|
||||
|
||||
# Specify bind address or unix socket
|
||||
option bind ''
|
||||
# Specify port to listen on
|
||||
option port '5000'
|
||||
# Specify a (URL) path prefix
|
||||
option path_prefix ''
|
||||
# Path to an SSL/TLS certificate to serve with HTTPS
|
||||
option tls_cert ''
|
||||
# Path to the SSL/TLS certificate's private key
|
||||
option tls_key ''
|
||||
# Enable CORS, sets `Access-Control-Allow-Origin: *`
|
||||
option enable_cors '0'
|
||||
# Allow access from Internet
|
||||
option internet '0'
|
||||
|
||||
# Specific path to serve
|
||||
option serve_path '/mnt'
|
||||
# Add auth roles, e.g. user:pass@/dir1:rw,/dir2
|
||||
list auth ''
|
||||
# Hide paths from directory listings, e.g. tmp,*.log,*.lock
|
||||
list hidden ''
|
||||
|
||||
# Serve index.html when requesting a directory, returns 404 if not found index.html
|
||||
option render_index '0'
|
||||
# Serve index.html when requesting a directory, returns directory listing if not found index.html (enabled by default)
|
||||
option render_try_index '1'
|
||||
|
||||
# Allow all operations
|
||||
option allow_all '0'
|
||||
# Allow upload files/folders
|
||||
option allow_upload '0'
|
||||
# Allow delete files/folders
|
||||
option allow_delete '0'
|
||||
# Allow search files/folders
|
||||
option allow_search '0'
|
||||
# Allow symlink to files/folders outside root directory
|
||||
option allow_symlink '0'
|
||||
# Allow zip archive generation
|
||||
option allow_archive '0'
|
||||
# Set zip compress level [possible values: none, low, medium, high]
|
||||
option compress ''
|
||||
|
||||
105
net/dufs/files/dufs.init
Normal file
105
net/dufs/files/dufs.init
Normal file
@@ -0,0 +1,105 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2024-2025 Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
CONF="dufs"
|
||||
PROG="/usr/bin/dufs"
|
||||
|
||||
is_enabled() {
|
||||
local enabled
|
||||
config_get_bool enabled "$1" "$2" "${3:-0}"
|
||||
if [ "$enabled" -eq "1" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
append_param() {
|
||||
procd_append_param command "$1" $2
|
||||
}
|
||||
|
||||
append_param_arg() {
|
||||
local value
|
||||
config_get value "$1" "$2" $3
|
||||
[ -n "$value" ] && append_param "--${2//_/-}" "$value"
|
||||
}
|
||||
|
||||
append_param_bool() {
|
||||
is_enabled "$1" "$2" && append_param "--${2//_/-}"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load "$CONF"
|
||||
|
||||
is_enabled "config" "enabled" || return 1
|
||||
|
||||
procd_open_instance "$CONF"
|
||||
procd_set_param command "$PROG"
|
||||
|
||||
append_param_arg "config" "bind"
|
||||
append_param_arg "config" "port" "5000"
|
||||
append_param_arg "config" "path_prefix"
|
||||
append_param_arg "config" "tls_cert"
|
||||
append_param_arg "config" "tls_key"
|
||||
append_param_bool "config" "enable_cors"
|
||||
|
||||
local auth_roles hidden
|
||||
config_get auth_roles "config" "auth"
|
||||
config_get hidden "config" "hidden"
|
||||
[ -z "$auth_roles" ] || config_list_foreach "config" "auth" "append_param '--auth'"
|
||||
[ -z "$hidden" ] || config_list_foreach "config" "hidden" "append_param '--hidden'"
|
||||
|
||||
append_param_bool "config" "render_index"
|
||||
append_param_bool "config" "render_try_index" "1"
|
||||
|
||||
append_param_bool "config" "allow_all"
|
||||
append_param_bool "config" "allow_upload"
|
||||
append_param_bool "config" "allow_delete"
|
||||
append_param_bool "config" "allow_search"
|
||||
append_param_bool "config" "allow_symlink"
|
||||
append_param_bool "config" "allow_archive"
|
||||
append_param_arg "config" "compress"
|
||||
|
||||
local serve_path
|
||||
config_get serve_path "config" "serve_path" "/mnt"
|
||||
append_param "$serve_path"
|
||||
|
||||
procd_set_param limits core="unlimited"
|
||||
procd_set_param limits nofile="1000000 1000000"
|
||||
procd_set_param respawn
|
||||
procd_set_param stderr 1
|
||||
|
||||
if is_enabled "config" "internet"; then
|
||||
local listen_port
|
||||
config_get listen_port "config" "port" "5000"
|
||||
procd_open_data
|
||||
json_add_array firewall
|
||||
json_add_object ""
|
||||
json_add_string type rule
|
||||
json_add_string name "Allow-access-dufs-at-$listen_port"
|
||||
json_add_string src "*"
|
||||
json_add_string dest_port "$listen_port"
|
||||
json_add_string proto tcp
|
||||
json_add_string target ACCEPT
|
||||
json_close_object
|
||||
json_close_array
|
||||
procd_close_data
|
||||
fi
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_started() {
|
||||
procd_set_config_changed firewall
|
||||
}
|
||||
|
||||
service_stopped() {
|
||||
procd_set_config_changed firewall
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONF"
|
||||
}
|
||||
Reference in New Issue
Block a user