luci-app-qbittorrent-simple: add luci for qbittorrent simple UI

This commit is contained in:
lean 2022-07-18 14:04:35 +08:00
parent c5f12bf7aa
commit 2347b04b60
10 changed files with 257 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# Copyright (C) 2019 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-qbittorrent-simple
PKG_VERSION:=1.0.0
PKG_RELEASE:=3
LUCI_TITLE:=LuCI support for qBittorrent
LUCI_PKGARCH:=all
LUCI_DEPENDS:= \
+PACKAGE_luci-app-qbittorrent-simple_static:qBittorrent-static \
+PACKAGE_luci-app-qbittorrent-simple_dynamic:qbittorrent
define Package/$(PKG_NAME)/config
choice
prompt "Build Version Selection"
default PACKAGE_luci-app-qbittorrent-simple_dynamic
config PACKAGE_luci-app-qbittorrent-simple_static
bool "Static Build"
depends on arm||aarch64||x86_64
config PACKAGE_luci-app-qbittorrent-simple_dynamic
bool "Dynamic Build"
endchoice
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,24 @@
module("luci.controller.qbittorrent", package.seeall)
function index()
if not nixio.fs.access("/etc/config/qbittorrent") then
return
end
entry({"admin", "nas", "qbittorrent"}, cbi("qbittorrent"), _("qBittorrent"), 20).dependent = true
entry({"admin", "nas", "qbittorrent_status"}, call("qbittorrent_status"))
end
function qbittorrent_status()
local sys = require "luci.sys"
local uci = require "luci.model.uci".cursor()
local port = tonumber(uci:get_first("qbittorrent", "qbittorrent", "port"))
local status = {
running = (sys.call("pidof qbittorrent-nox >/dev/null") == 0),
port = (port or 8080)
}
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@ -0,0 +1,15 @@
local m, s
m = Map("qbittorrent", translate("qBittorrent"), translate("qBittorrent is a cross-platform free and open-source BitTorrent client. Default username & password: admin / adminadmin"))
m:section(SimpleSection).template = "qbittorrent_status"
s=m:section(TypedSection, "qbittorrent", translate("Global settings"))
s.addremove=false
s.anonymous=true
s:option(Flag, "enabled", translate("Enable")).rmempty=false
s:option(Value, "port", translate("WebUI Port")).rmempty=false
s:option(Value, "profile_dir", translate("Configuration files Path")).rmempty=false
return m

View File

@ -0,0 +1,26 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/nas/qbittorrent_status")%>', null,
function(x, st)
{
var tb = document.getElementById('qbittorrent_status');
if (st && tb)
{
if (st.running)
{
tb.innerHTML = '<em style=\"color:green\"><b>qBittorrent <%:RUNNING%></b></em>' + "&nbsp;&nbsp;&nbsp;&nbsp;<input class=\"btn cbi-button cbi-button-apply \" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('http://" + window.location.hostname + ":" + st.port + "/')\"/>";
}
else
{
tb.innerHTML = '<em style=\"color:red\"><b>qBittorrent <%:NOT RUNNING%></b></em>';
}
}
}
);
//]]></script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="qbittorrent_status">
<em><b><%:Collecting data...%></b></em>
</p>
</fieldset>

View File

@ -0,0 +1,29 @@
msgid "qBittorrent"
msgstr "qBittorrent"
msgid "Running state"
msgstr "运行状态"
msgid "Open Web Interface"
msgstr "打开管理页面"
msgid "qBittorrent is a cross-platform free and open-source BitTorrent client. Default username & password: admin / adminadmin"
msgstr "qBittorrent 是一个基于 QT 的跨平台的开源 BitTorrent 客户端。默认用户名 & 密码admin / adminadmin"
msgid "Global settings"
msgstr "全局设置"
msgid "WebUI Port"
msgstr "WebUI 监听端口"
msgid "Configuration files Path"
msgstr "配置文件路径"
msgid "RUNNING"
msgstr "运行中"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "Collecting data..."
msgstr "收集数据..."

View File

@ -0,0 +1,4 @@
config qbittorrent
option 'enabled' '0'
option 'port' '8080'
option 'profile_dir' '/etc/qbittorrent'

View File

@ -0,0 +1,36 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/bin/qbittorrent-nox
get_config() {
config_get_bool enabled $1 enabled 1
config_get port $1 port 8080
config_get profile_dir $1 profile_dir "/etc/qbittorrent"
}
start_service() {
config_load qbittorrent
config_foreach get_config qbittorrent
[ $enabled != 1 ] && return 1
if [ ! -f "$profile_dir/qBittorrent/config/qBittorrent.conf" ]; then
mkdir -p $profile_dir/qBittorrent/config/
cp /etc/qbittorrent/qBittorrent.conf.example $profile_dir/qBittorrent/config/qBittorrent.conf
fi
procd_open_instance
procd_set_param command $PROG
procd_append_param command --webui-port=$port --profile=$profile_dir
procd_set_param respawn
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger "qbittorrent"
}
reload_service() {
stop
sleep 1
start
}

View File

@ -0,0 +1,66 @@
[AutoRun]
enabled=false
program=
[BitTorrent]
Session\DefaultSavePath=/tmp
Session\QueueingSystemEnabled=false
[Core]
AutoDeleteAddedTorrentFile=Never
[LegalNotice]
Accepted=true
[Meta]
MigrationVersion=3
[Network]
Proxy\OnlyForTorrents=false
[Preferences]
Advanced\RecheckOnCompletion=false
Advanced\trackerPort=9000
Connection\ResolvePeerCountries=true
DynDNS\DomainName=changeme.dyndns.org
DynDNS\Enabled=false
DynDNS\Password=
DynDNS\Service=DynDNS
DynDNS\Username=
General\Locale=zh
MailNotification\email=
MailNotification\enabled=false
MailNotification\password=
MailNotification\req_auth=true
MailNotification\req_ssl=false
MailNotification\sender=qBittorrent_notification@example.com
MailNotification\smtp_server=smtp.changeme.com
MailNotification\username=
WebUI\Address=*
WebUI\AlternativeUIEnabled=false
WebUI\AuthSubnetWhitelist=10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
WebUI\AuthSubnetWhitelistEnabled=true
WebUI\BanDuration=3600
WebUI\CSRFProtection=false
WebUI\ClickjackingProtection=false
WebUI\CustomHTTPHeaders=
WebUI\CustomHTTPHeadersEnabled=false
WebUI\HTTPS\CertificatePath=
WebUI\HTTPS\Enabled=false
WebUI\HTTPS\KeyPath=
WebUI\HostHeaderValidation=true
WebUI\LocalHostAuth=false
WebUI\MaxAuthenticationFailCount=20
WebUI\Port=8080
WebUI\ReverseProxySupportEnabled=false
WebUI\RootFolder=
WebUI\SecureCookie=true
WebUI\ServerDomains=*
WebUI\SessionTimeout=3600
WebUI\TrustedReverseProxiesList=
WebUI\UseUPnP=true
WebUI\Username=admin
[RSS]
AutoDownloader\DownloadRepacks=true
AutoDownloader\SmartEpisodeFilter=s(\\d+)e(\\d+), (\\d+)x(\\d+), "(\\d{4}[.\\-]\\d{1,2}[.\\-]\\d{1,2})", "(\\d{1,2}[.\\-]\\d{1,2}[.\\-]\\d{4})"

View File

@ -0,0 +1,11 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@qbittorrent[-1]
add ucitrack qbittorrent
set ucitrack.@qbittorrent[-1].init=qbittorrent
commit ucitrack
EOF
rm -f /tmp/luci-indexcache*
exit 0

View File

@ -0,0 +1,11 @@
{
"luci-app-qbittorrent": {
"description": "Grant UCI access for luci-app-qbittorrent",
"read": {
"uci": [ "qbittorrent" ]
},
"write": {
"uci": [ "qbittorrent" ]
}
}
}