daed: add package

This commit is contained in:
coolsnowwolf 2024-10-19 18:41:33 +08:00
parent d1705362d3
commit fff92666f3
14 changed files with 747 additions and 0 deletions

131
net/dae/Makefile Normal file
View File

@ -0,0 +1,131 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=dae
PKG_VERSION:=0.6.0
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).zip
PKG_SOURCE_URL:=https://github.com/daeuniverse/dae/releases/download/v$(PKG_VERSION)/dae-full-src.zip?
PKG_HASH:=e4ab51493f7a65402b468c38647e79cfa669203b5295a616b7f8c1416d8f1bbe
PKG_LICENSE:=AGPL-3.0-only
PKG_LICENSE_FILE:=LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_BUILD_DEPENDS:=golang/host bpf-headers
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16
GO_PKG:=github.com/daeuniverse/dae
GO_PKG_LDFLAGS_X:= \
$(GO_PKG)/cmd.Version=$(PKG_VERSION) \
$(GO_PKG)/common/consts.MaxMatchSetLen_=64
GO_PKG_TAGS:=trace
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/bpf.mk
include ../../lang/golang/golang-package.mk
UNZIP_CMD:=unzip -q -d $(PKG_BUILD_DIR) $(DL_DIR)/$(PKG_SOURCE)
define Package/dae/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
URL:=https://github.com/daeuniverse/dae
endef
define Package/dae
$(call Package/dae/Default)
TITLE:=A lightweight and high-performance transparent proxy solution
# You need enable KERNEL_DEBUG_INFO_BTF and KERNEL_BPF_EVENTS
DEPENDS:=$(GO_ARCH_DEPENDS) $(BPF_DEPENDS) \
+ca-bundle +kmod-sched-core +kmod-sched-bpf +kmod-xdp-sockets-diag \
+kmod-veth
endef
define Package/dae-geoip
$(call Package/dae/Default)
TITLE:=geoip for dae
DEPENDS:=+dae +v2ray-geoip
PKGARCH:=all
endef
define Package/dae-geosite
$(call Package/dae/Default)
TITLE:=geosite for dae
DEPENDS:=+dae +v2ray-geosite
PKGARCH:=all
endef
define Package/dae/description
dae, means goose, is a lightweight and high-performance transparent
proxy solution.
In order to improve the traffic diversion performance as much as possible,
dae runs the transparent proxy and traffic diversion suite in the linux
kernel by eBPF. Therefore, we have the opportunity to make the direct
traffic bypass the forwarding by proxy application and achieve true direct
traffic through. Under such a magic trick, there is almost no performance
loss and additional resource consumption for direct traffic.
endef
define Package/dae/conffiles
/etc/dae/config.dae
/etc/config/dae
endef
DAE_CFLAGS:= \
-O2 -Wall -Werror \
-DMAX_MATCH_SET_LEN=64 \
-I$(BPF_HEADERS_DIR)/tools/lib \
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/asm/mach-generic
define Build/Compile
( \
export \
$(GO_GENERAL_BUILD_CONFIG_VARS) \
$(GO_PKG_BUILD_CONFIG_VARS) \
$(GO_PKG_BUILD_VARS) \
BPF_CLANG="$(CLANG)" \
BPF_STRIP_FLAG="-strip=$(LLVM_STRIP)" \
BPF_CFLAGS="$(DAE_CFLAGS)" \
BPF_TARGET="bpfel,bpfeb" \
BPF_TRACE_TARGET="$(GO_ARCH)" ; \
go generate $(PKG_BUILD_DIR)/control/control.go ; \
go generate $(PKG_BUILD_DIR)/trace/trace.go ; \
$(call GoPackage/Build/Compile) ; \
)
endef
define Package/dae/install
$(call GoPackage/Package/Install/Bin,$(1))
$(INSTALL_DIR) $(1)/etc/dae/
$(INSTALL_CONF) $(PKG_BUILD_DIR)/example.dae $(1)/etc/dae/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) $(CURDIR)/files/dae.config $(1)/etc/config/dae
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(CURDIR)/files/dae.init $(1)/etc/init.d/dae
endef
define Package/dae-geoip/install
$(INSTALL_DIR) $(1)/usr/share/dae
$(LN) ../v2ray/geoip.dat $(1)/usr/share/dae/geoip.dat
endef
define Package/dae-geosite/install
$(INSTALL_DIR) $(1)/usr/share/dae
$(LN) ../v2ray/geosite.dat $(1)/usr/share/dae/geosite.dat
endef
$(eval $(call GoBinPackage,dae))
$(eval $(call BuildPackage,dae))
$(eval $(call BuildPackage,dae-geoip))
$(eval $(call BuildPackage,dae-geosite))

7
net/dae/files/dae.config Normal file
View File

@ -0,0 +1,7 @@
config dae 'config'
option enabled '0'
option config_file '/etc/dae/config.dae'
option log_maxbackups '1'
option log_maxsize '1'

56
net/dae/files/dae.init Normal file
View File

@ -0,0 +1,56 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2023 Tianling Shen <cnsztl@immortalwrt.org>
USE_PROCD=1
START=99
extra_command "hot_reload" "Hot-reload service"
CONF="dae"
PROG="/usr/bin/dae"
LOG_DIR="/var/log/dae"
start_service() {
config_load "$CONF"
local enabled
config_get_bool enabled "config" "enabled" "0"
[ "$enabled" -eq "1" ] || return 1
local config_file
config_get config_file "config" "config_file" "/etc/dae/config.dae"
"$PROG" validate -c "$config_file" || return 1
local log_maxbackups log_maxsize
config_get log_maxbackups "config" "log_maxbackups" "1"
config_get log_maxsize "config" "log_maxsize" "1"
procd_open_instance "$CONF"
procd_set_param command "$PROG" run
procd_append_param command --config "$config_file"
procd_append_param command --disable-timestamp
procd_append_param command --logfile "$LOG_DIR/dae.log"
procd_append_param command --logfile-maxbackups "$log_maxbackups"
procd_append_param command --logfile-maxsize "$log_maxsize"
procd_set_param limits core="unlimited"
procd_set_param limits nofile="1000000 1000000"
procd_set_param respawn
# procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
stop_service() {
rm -rf "$LOG_DIR"
}
service_triggers() {
procd_add_reload_trigger "$CONF"
}
hot_reload() {
/etc/init.d/dae running && "$PROG" reload "$(cat /var/run/dae.pid)"
}

7
net/dae/test.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
case "$1" in
"dae")
dae --version | grep "$PKG_VERSION"
;;
esac

162
net/daed/Makefile Normal file
View File

@ -0,0 +1,162 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=daed
PKG_VERSION=0.6.0
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/daeuniverse/daed.git
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
PKG_MIRROR_HASH:=0063975b373c0375bf44c8d28818f861127a97917e4e5ff416b59590ce7cffde
PKG_LICENSE:=AGPL-3.0-only MIT
PKG_LICENSE_FILES:=LICENSE wing/LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/wing
PKG_BUILD_DEPENDS:=golang/host bpf-headers
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16
GO_PKG:=github.com/daeuniverse/dae-wing
GO_PKG_LDFLAGS:= \
-X '$(GO_PKG)/db.AppDescription=$(PKG_NAME) is a integration solution of dae, API and UI.'
GO_PKG_LDFLAGS_X= \
$(GO_PKG)/db.AppName=$(PKG_NAME) \
$(GO_PKG)/db.AppVersion=$(PKG_VERSION)
GO_PKG_TAGS:=embedallowed,trace
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/bpf.mk
include ../../lang/golang/golang-package.mk
TAR_CMD=$(HOST_TAR) -C $(BUILD_DIR)/ $(TAR_OPTIONS)
define Package/daed/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
URL:=https://github.com/daeuniverse/daed
endef
define Package/daed
$(call Package/daed/Default)
TITLE:=A Modern Dashboard For dae
# You need enable KERNEL_DEBUG_INFO_BTF and KERNEL_BPF_EVENTS
DEPENDS:=$(GO_ARCH_DEPENDS) $(BPF_DEPENDS) \
+ca-bundle +kmod-sched-core +kmod-sched-bpf +kmod-xdp-sockets-diag \
+kmod-veth
endef
define Package/daed-geoip
$(call Package/daed/Default)
TITLE:=geoip for daed
DEPENDS:=+daed +v2ray-geoip
PKGARCH:=all
endef
define Package/daed-geosite
$(call Package/daed/Default)
TITLE:=geosite for daed
DEPENDS:=+daed +v2ray-geosite
PKGARCH:=all
endef
define Package/daed/description
daed is a backend of dae, provides a method to bundle arbitrary
frontend, dae and geodata into one binary.
endef
define Package/daed/conffiles
/etc/daed/wing.db
/etc/config/daed
endef
WEB_FILE:=$(PKG_NAME)-web-$(PKG_VERSION).zip
define Download/daed-web
URL:=https://github.com/daeuniverse/daed/releases/download/v$(PKG_VERSION)
URL_FILE:=web.zip
FILE:=$(WEB_FILE)
HASH:=f8a5f28643c990408f7b6d324b4cc8b5e7445e6255689a5f10f5545be033c1ad
endef
define Build/Prepare
$(call Build/Prepare/Default)
( \
mkdir -p $(PKG_BUILD_DIR)/webrender ; \
unzip -q -d $(PKG_BUILD_DIR)/webrender/ $(DL_DIR)/$(WEB_FILE) ; \
find $(PKG_BUILD_DIR)/webrender/web -type f -size +4k ! -name "*.gz" ! -name "*.woff" ! -name "*.woff2" -exec sh -c '\
gzip -9 -k "{}"; \
if [ "$$$$(stat -c %s "{}")" -lt "$$$$(stat -c %s "{}.gz")" ]; then \
rm "{}.gz"; \
else \
rm "{}"; \
fi' \
";" ; \
)
endef
DAE_CFLAGS:= \
-O2 -Wall -Werror \
-DMAX_MATCH_SET_LEN=64 \
-I$(BPF_HEADERS_DIR)/tools/lib \
-I$(BPF_HEADERS_DIR)/arch/$(BPF_KARCH)/include/asm/mach-generic
ifneq ($(CONFIG_USE_MUSL),)
TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
endif
define Build/Compile
( \
pushd $(PKG_BUILD_DIR) ; \
export \
$(GO_GENERAL_BUILD_CONFIG_VARS) \
$(GO_PKG_BUILD_CONFIG_VARS) \
$(GO_PKG_BUILD_VARS); \
go generate ./... ; \
cd dae-core ; \
export \
BPF_CLANG="$(CLANG)" \
BPF_STRIP_FLAG="-strip=$(LLVM_STRIP)" \
BPF_CFLAGS="$(DAE_CFLAGS)" \
BPF_TARGET="bpfel,bpfeb" \
BPF_TRACE_TARGET="$(GO_ARCH)" ; \
go generate control/control.go ; \
go generate trace/trace.go ; \
popd ; \
$(call GoPackage/Build/Compile) ; \
)
endef
define Package/daed/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dae-wing $(1)/usr/bin/daed
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) $(CURDIR)/files/daed.config $(1)/etc/config/daed
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(CURDIR)/files/daed.init $(1)/etc/init.d/daed
endef
define Package/daed-geoip/install
$(INSTALL_DIR) $(1)/usr/share/daed
$(LN) ../v2ray/geoip.dat $(1)/usr/share/daed/geoip.dat
endef
define Package/daed-geosite/install
$(INSTALL_DIR) $(1)/usr/share/daed
$(LN) ../v2ray/geosite.dat $(1)/usr/share/daed/geosite.dat
endef
$(eval $(call Download,daed-web))
$(eval $(call GoBinPackage,daed))
$(eval $(call BuildPackage,daed))
$(eval $(call BuildPackage,daed-geoip))
$(eval $(call BuildPackage,daed-geosite))

View File

@ -0,0 +1,7 @@
config daed 'config'
option enabled '0'
option listen_addr '0.0.0.0:2023'
option log_maxbackups '1'
option log_maxsize '5'

46
net/daed/files/daed.init Normal file
View File

@ -0,0 +1,46 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2023 Tianling Shen <cnsztl@immortalwrt.org>
USE_PROCD=1
START=99
CONF="daed"
PROG="/usr/bin/daed"
LOG="/var/log/daed/daed.log"
start_service() {
config_load "$CONF"
local enabled
config_get_bool enabled "config" "enabled" "0"
[ "$enabled" -eq "1" ] || return 1
local listen_addr log_maxbackups log_maxsize
config_get listen_addr "config" "listen_addr" "0.0.0.0:2023"
config_get log_maxbackups "config" "log_maxbackups" "1"
config_get log_maxsize "config" "log_maxsize" "5"
procd_open_instance "$CONF"
procd_set_param command "$PROG" run
procd_append_param command --config "/etc/daed/"
procd_append_param command --listen "$listen_addr"
procd_append_param command --logfile "$LOG"
procd_append_param command --logfile-maxbackups "$log_maxbackups"
procd_append_param command --logfile-maxsize "$log_maxsize"
procd_set_param limits core="unlimited"
procd_set_param limits nofile="1000000 1000000"
procd_set_param respawn
# procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
stop_service() {
rm -f "$LOG"
}
service_triggers() {
procd_add_reload_trigger "$CONF"
}

7
net/daed/test.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/sh
case "$1" in
"daed")
daed --version | grep "$PKG_VERSION"
;;
esac

54
net/dufs/Makefile Normal file
View File

@ -0,0 +1,54 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2024 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=dufs
PKG_VERSION:=0.42.0
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/sigoden/dufs/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=76439a01c142d6a378912930de4b74821aa2fef54ccfb7dbb00d6ea3b1a0ab4c
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))

View File

@ -0,0 +1,40 @@
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
option hidden ''
# 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 ''

106
net/dufs/files/dufs.init Normal file
View File

@ -0,0 +1,106 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2024 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
config_get auth_roles "config" "auth"
[ -z "$auth_roles" ] || config_list_foreach "config" "auth" "append_param '--auth'"
append_param_arg "config" "hidden"
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"
append_param "--render-index"
append_param "--render-try-index"
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
local internet
config_get_bool internet "config" "internet" "0"
if [ "$internet" -eq "1" ]; 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"
}

View File

@ -0,0 +1,71 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=filebrowser
PKG_VERSION:=2.28.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/filebrowser/filebrowser/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=5e8c5b57783976f454ee7f23df9c36b9566648b7b443287a7f2089771628695d
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_BUILD_DEPENDS:=golang/host node/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16
GO_PKG:=github.com/filebrowser/filebrowser/v2
GO_PKG_LDFLAGS_X:= \
$(GO_PKG)/version.CommitSHA=$(PKG_VERSION) \
$(GO_PKG)/version.Version=v$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include ../../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 Package/filebrowser/conffiles
/etc/filebrowser/
/etc/config/filebrowser
endef
define Build/Compile
( \
pushd "$(PKG_BUILD_DIR)/frontend" ; \
npm ci; \
NODE_OPTIONS=--openssl-legacy-provider 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))

View File

@ -0,0 +1,7 @@
config filebrowser 'config'
option enabled '0'
option listen_port '8989'
option root_path '/'
option base_url ''
option disable_exec '1'

View File

@ -0,0 +1,46 @@
#!/bin/sh /etc/rc.common
USE_PROCD=1
START=99
CONF="filebrowser"
PROG="/usr/bin/filebrowser"
DB_PATH="/etc/filebrowser/database.db"
start_service() {
config_load "$CONF"
local enabled
config_get_bool enabled "config" "enabled" "0"
[ "$enabled" -eq "1" ] || return 1
mkdir -p "${DB_PATH%/*}"
local listen_port root_path base_url disable_exec
config_get listen_port "config" "listen_port" "8989"
config_get root_path "config" "root_path" "/mnt/"
config_get base_url "config" "base_url"
config_get_bool disable_exec "config" "disable_exec" "1"
procd_open_instance
procd_set_param command "$PROG"
procd_append_param command --database "$DB_PATH"
procd_append_param command --address "[::]"
procd_append_param command --port "$listen_port"
procd_append_param command --root "$root_path"
[ -z "$base_url" ] || procd_append_param command --baseurl "$base_url"
[ "$disable_exec" = "0" ] || procd_append_param command --disable-exec
procd_set_param limits core="unlimited"
procd_set_param limits nofile="1000000 1000000"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger "$CONF"
}