51 lines
1.2 KiB
Bash
Executable File
51 lines
1.2 KiB
Bash
Executable File
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2019 [CTCGFW] Project OpenWRT
|
|
|
|
. /lib/functions.sh
|
|
. /lib/functions/procd.sh
|
|
|
|
USE_PROCD=1
|
|
|
|
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_service() {
|
|
[ "${enabled}" == "1" ] || exit 0
|
|
procd_open_instance filebrowser
|
|
mkdir -p "${root_dir}"
|
|
mkdir -p "${db_dir}"
|
|
procd_set_param command filebrowser
|
|
procd_append_param command -a "${addr}"
|
|
procd_append_param command -d "${db_dir}/${db_name}"
|
|
procd_append_param command -p "${port}"
|
|
procd_append_param command -r "${root_dir}"
|
|
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
|
procd_close_instance
|
|
}
|
|
|
|
reload_service()
|
|
{
|
|
stop
|
|
start
|
|
}
|
|
|
|
service_triggers() {
|
|
procd_add_reload_trigger "filebrowser"
|
|
}
|