mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 05:25:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -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 ''
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
#!/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 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_triggers() {
|
||||
procd_add_reload_trigger "$CONF"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -i "s,option hidden ,list hidden ,g" "/etc/config/dufs"
|
||||
exit 0
|
||||
Reference in new issue
Block a user