luci-app-qbittorrent: almost rewrite
This commit is contained in:
parent
310253dd5a
commit
4706032340
@ -10,7 +10,7 @@ LUCI_DEPENDS:=+qBittorrent-Enhanced-Edition
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-qbittorrent
|
||||
PKG_VERSION=1.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
@ -5,28 +5,32 @@ local a=(luci.sys.call("pidof qbittorrent-nox > /dev/null")==0)
|
||||
|
||||
local t=""
|
||||
if a then
|
||||
t="<br /><br /><input class=\"cbi-button cbi-button-apply\" type=\"submit\" value=\" "..translate("Open Web Interface").." \" onclick=\"window.open('http://'+window.location.hostname+':"..o.."')\"/>"
|
||||
t="<br/><br/><input type=\"button\" value=\" " .. translate("Open Web Interface") .. " \" onclick=\"window.open('http://'+window.location.hostname+':" .. o .. "')\"/>"
|
||||
end
|
||||
|
||||
m = Map("qbittorrent", translate("qBittorrent"), translate("qBittorrent is a cross-platform free and open-source BitTorrent client")..t)
|
||||
m = Map("qbittorrent", translate("qBittorrent"), translate("qBittorrent is a cross-platform free and open-source BitTorrent client.").."<br/>"..translate("Default login username: admin, password: adminadmin.")..t)
|
||||
|
||||
m:section(SimpleSection).template="qbittorrent/qbittorrent_status"
|
||||
|
||||
s_basic = m:section(TypedSection, "basic", translate("Basic Settings"))
|
||||
s_basic.anonymous = true
|
||||
s = m:section(TypedSection, "qbittorrent")
|
||||
s.anonymous=true
|
||||
|
||||
enable = s_basic:option(Flag, "enable", translate("Enable"))
|
||||
profile_dir = s_basic:option(Value,"profile_dir",translate("profile_dir"),translate("Store configuration files in the Path"))
|
||||
profile_dir.default = "/root"
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.rmempty = false
|
||||
|
||||
s_download = m:section(TypedSection, "Preferences", translate("Download Settings"))
|
||||
s_download.anonymous = true
|
||||
download_dir = s_download:option(Value,"download_dir",translate("download_dir"),translate("Store download files in the Path"))
|
||||
download_dir.default = "/root/download"
|
||||
|
||||
s_webui = m:section(TypedSection, "Preferences", translate("WEBUI Settings"))
|
||||
s_webui.anonymous = true
|
||||
port = s_webui:option(Value,"port",translate("port"),translate("WEBUI listening port"))
|
||||
port = s:option(Value,"port",translate("Port"),translate("WebUI listening port"))
|
||||
port.default = "8080"
|
||||
port.placeholder = "8080"
|
||||
port.rmempty = false
|
||||
|
||||
profile_dir = s:option(Value,"profile_dir",translate("Profile Dir"),translate("Store configuration files in the Path"))
|
||||
profile_dir.default = "/root"
|
||||
profile_dir.placeholder = "/root"
|
||||
profile_dir.rmempty = false
|
||||
|
||||
download_dir = s:option(Value,"download_dir",translate("Download Dir"),translate("Store download files in the Path"))
|
||||
download_dir.default = "/mnt/download"
|
||||
download_dir.placeholder = "/mnt/download"
|
||||
download_dir.rmempty = false
|
||||
|
||||
return m
|
||||
@ -1,44 +1,41 @@
|
||||
msgid "qbittorrent"
|
||||
msgstr "qbittorrent"
|
||||
|
||||
msgid "Running"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Not running"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "qbittorrent Run Status"
|
||||
msgstr "qbittorrent运行状态"
|
||||
|
||||
msgid "Basic Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "qBittorrent is a cross-platform free and open-source BitTorrent client"
|
||||
msgstr "qBittorrent是一个基于 QT 的跨平台的开源 BitTorrent 客户端"
|
||||
|
||||
msgid "profile_dir"
|
||||
msgstr "配置文件目录"
|
||||
|
||||
msgid "Store configuration files in the Path"
|
||||
msgstr "配置文件存放路径"
|
||||
|
||||
msgid "Download Settings"
|
||||
msgstr "下载设置"
|
||||
|
||||
msgid "download_dir"
|
||||
msgstr "下载目录"
|
||||
|
||||
msgid "Store download files in the Path"
|
||||
msgstr "下载文件存放目录"
|
||||
|
||||
msgid "WEBUI Settings"
|
||||
msgstr "WEBUI设置"
|
||||
|
||||
msgid "WEBUI listening port"
|
||||
msgstr "WEBUI监听端口"
|
||||
|
||||
msgid "Open Web Interface"
|
||||
msgstr "打开Web界面"
|
||||
msgid "qbittorrent"
|
||||
msgstr "qbittorrent"
|
||||
|
||||
msgid "qBittorrent is a cross-platform free and open-source BitTorrent client."
|
||||
msgstr "qBittorrent是一个基于 QT 的跨平台的开源 BitTorrent 客户端。"
|
||||
|
||||
msgid "Default login username: admin, password: adminadmin."
|
||||
msgstr "默认登录用户名:admin,密码:adminadmin。"
|
||||
|
||||
msgid "Open Web Interface"
|
||||
msgstr "打开Web界面"
|
||||
|
||||
msgid "qbittorrent Run Status"
|
||||
msgstr "qbittorrent运行状态"
|
||||
|
||||
msgid "Running"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Not running"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Port"
|
||||
msgstr "端口"
|
||||
|
||||
msgid "WebUI listening port"
|
||||
msgstr "WebUI监听端口"
|
||||
|
||||
msgid "Profile Dir"
|
||||
msgstr "配置文件目录"
|
||||
|
||||
msgid "Store configuration files in the Path"
|
||||
msgstr "配置文件存放路径"
|
||||
|
||||
msgid "Download Dir"
|
||||
msgstr "下载目录"
|
||||
|
||||
msgid "Store download files in the Path"
|
||||
msgstr "下载文件存放目录"
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
|
||||
config basic
|
||||
option profile_dir '/root'
|
||||
config qbittorrent
|
||||
option enable '0'
|
||||
|
||||
config Preferences
|
||||
option download_dir '/mnt/download'
|
||||
option port '8080'
|
||||
|
||||
option profile_dir '/root'
|
||||
option download_dir '/mnt/download'
|
||||
|
||||
@ -3,24 +3,24 @@ START=99
|
||||
|
||||
get_config()
|
||||
{
|
||||
config_get_bool enable $1 enable 0
|
||||
config_get_bool enable "$1" enable 0
|
||||
}
|
||||
|
||||
config_qbittorrent()
|
||||
{
|
||||
local download_dir
|
||||
local port
|
||||
config_get download_dir $1 download_dir
|
||||
config_get port $1 port
|
||||
mkdir -p $download_dir
|
||||
mkdir -p $2
|
||||
ln -sf /etc/qBittorrent/ipfilter.dat $2/qBittorrent/ipfilter.dat
|
||||
if [ -f $2/qBittorrent/config/qBittorrent.conf ]; then
|
||||
sed -i 's/WebUI\\Port=[0-9]*/WebUI\\Port='"$port"'/g' $2/qBittorrent/config/qBittorrent.conf
|
||||
sed -i 's/Downloads\\SavePath=[a-z,/]*//g' $2/qBittorrent/config/qBittorrent.conf
|
||||
echo "Downloads\SavePath=$download_dir" >> $2/qBittorrent/config/qBittorrent.conf
|
||||
config_get download_dir "$1" "download_dir"
|
||||
config_get port "$1" "port"
|
||||
mkdir -p "$download_dir"
|
||||
mkdir -p "$2" "$2/qBittorrent" "$2/qBittorrent/config"
|
||||
ln -sf "/etc/qBittorrent/ipfilter.dat" "$2/qBittorrent/ipfilter.dat"
|
||||
if [ -f "$2/qBittorrent/config/qBittorrent.conf" ]; then
|
||||
sed -i 's/WebUI\\Port=[0-9]*/WebUI\\Port='"$port"'/g' "$2/qBittorrent/config/qBittorrent.conf"
|
||||
sed -i 's/Downloads\\SavePath=[a-z,/]*//g' "$2/qBittorrent/config/qBittorrent.conf"
|
||||
echo "Downloads\SavePath=$download_dir" >> "$2/qBittorrent/config/qBittorrent.conf"
|
||||
else
|
||||
cat >$2/qBittorrent/config/qBittorrent.conf<<EOF
|
||||
cat >"$2/qBittorrent/config/qBittorrent.conf"<<EOF
|
||||
[AutoRun]
|
||||
enabled=false
|
||||
program=
|
||||
@ -30,13 +30,18 @@ Accepted=true
|
||||
|
||||
[Network]
|
||||
Cookies=@Invalid()
|
||||
Downloads\SavePath=${download_dir}
|
||||
|
||||
[Preferences]
|
||||
Advanced\AutoBanUnknownPeer=true
|
||||
Bittorrent\AutoUpdateTrackers=true
|
||||
Bittorrent\CustomizeTrackersListUrl=https://cdn.jsdelivr.net/gh/ngosang/trackerslist/trackers_best.txt
|
||||
General\Locale=zh
|
||||
Downloads\SavePath=$download_dir
|
||||
General\Locale=zh
|
||||
WebUI\Port=$port
|
||||
IPFilter\Enabled=true
|
||||
IPFilter\File=$2/qBittorrent/ipfilter.dat
|
||||
IPFilter\FilterTracker=false
|
||||
WebUI\CSRFProtection=false
|
||||
WebUI\Port=${port}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
@ -44,16 +49,16 @@ EOF
|
||||
run_qbittorrent()
|
||||
{
|
||||
local enable
|
||||
config_get_bool enable $1 enable
|
||||
config_get_bool enable "$1" enable
|
||||
|
||||
if [ $enable ]; then
|
||||
local profile_dir
|
||||
config_get profile_dir $1 profile_dir
|
||||
config_foreach config_qbittorrent 'Preferences' $profile_dir
|
||||
config_get profile_dir "$1" profile_dir
|
||||
config_foreach config_qbittorrent "qbittorrent" "$profile_dir"
|
||||
if [ "$profile_dir" != "" ]; then
|
||||
qbittorrent-nox -d --profile=$profile_dir
|
||||
qbittorrent-nox -d --profile="$profile_dir"
|
||||
else
|
||||
echo "no profile_dir,stop!"
|
||||
echo "No profile_dir found, stop!"
|
||||
fi
|
||||
|
||||
fi
|
||||
@ -63,14 +68,13 @@ start()
|
||||
{
|
||||
stop
|
||||
local profile_path
|
||||
config_load 'qbittorrent'
|
||||
config_foreach get_config basic
|
||||
config_load "qbittorrent"
|
||||
config_foreach get_config "qbittorrent"
|
||||
[ $enable -eq 0 ] && exit 0
|
||||
config_foreach run_qbittorrent 'basic'
|
||||
config_foreach run_qbittorrent "qbittorrent"
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
killall qbittorrent-nox >/dev/null 2>&1
|
||||
return 0
|
||||
killall "qbittorrent-nox" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user