diff --git a/package/lean/luci-app-qbittorrent-simple/Makefile b/package/lean/luci-app-qbittorrent-simple/Makefile new file mode 100644 index 000000000..1f117f924 --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/Makefile @@ -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 diff --git a/package/lean/luci-app-qbittorrent-simple/luasrc/controller/qbittorrent.lua b/package/lean/luci-app-qbittorrent-simple/luasrc/controller/qbittorrent.lua new file mode 100644 index 000000000..28b42470a --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/luasrc/controller/qbittorrent.lua @@ -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 diff --git a/package/lean/luci-app-qbittorrent-simple/luasrc/model/cbi/qbittorrent.lua b/package/lean/luci-app-qbittorrent-simple/luasrc/model/cbi/qbittorrent.lua new file mode 100644 index 000000000..6c28c18c4 --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/luasrc/model/cbi/qbittorrent.lua @@ -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 diff --git a/package/lean/luci-app-qbittorrent-simple/luasrc/view/qbittorrent_status.htm b/package/lean/luci-app-qbittorrent-simple/luasrc/view/qbittorrent_status.htm new file mode 100644 index 000000000..5cc87f244 --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/luasrc/view/qbittorrent_status.htm @@ -0,0 +1,26 @@ + + + +
+

+ <%:Collecting data...%> +

+
diff --git a/package/lean/luci-app-qbittorrent-simple/po/zh-cn/qbittorrent.po b/package/lean/luci-app-qbittorrent-simple/po/zh-cn/qbittorrent.po new file mode 100644 index 000000000..b87fb8834 --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/po/zh-cn/qbittorrent.po @@ -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 "收集数据..." diff --git a/package/lean/luci-app-qbittorrent-simple/root/etc/config/qbittorrent b/package/lean/luci-app-qbittorrent-simple/root/etc/config/qbittorrent new file mode 100644 index 000000000..66f31acca --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/root/etc/config/qbittorrent @@ -0,0 +1,4 @@ +config qbittorrent + option 'enabled' '0' + option 'port' '8080' + option 'profile_dir' '/etc/qbittorrent' diff --git a/package/lean/luci-app-qbittorrent-simple/root/etc/init.d/qbittorrent b/package/lean/luci-app-qbittorrent-simple/root/etc/init.d/qbittorrent new file mode 100755 index 000000000..c6871ffa8 --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/root/etc/init.d/qbittorrent @@ -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 +} diff --git a/package/lean/luci-app-qbittorrent-simple/root/etc/qbittorrent/qBittorrent.conf.example b/package/lean/luci-app-qbittorrent-simple/root/etc/qbittorrent/qBittorrent.conf.example new file mode 100644 index 000000000..e3d73617f --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/root/etc/qbittorrent/qBittorrent.conf.example @@ -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})" diff --git a/package/lean/luci-app-qbittorrent-simple/root/etc/uci-defaults/50_luci-qbittorrent b/package/lean/luci-app-qbittorrent-simple/root/etc/uci-defaults/50_luci-qbittorrent new file mode 100755 index 000000000..0cdbab333 --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/root/etc/uci-defaults/50_luci-qbittorrent @@ -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 diff --git a/package/lean/luci-app-qbittorrent-simple/root/usr/share/rpcd/acl.d/luci-app-qbittorrent.json b/package/lean/luci-app-qbittorrent-simple/root/usr/share/rpcd/acl.d/luci-app-qbittorrent.json new file mode 100644 index 000000000..c46f3c92d --- /dev/null +++ b/package/lean/luci-app-qbittorrent-simple/root/usr/share/rpcd/acl.d/luci-app-qbittorrent.json @@ -0,0 +1,11 @@ +{ + "luci-app-qbittorrent": { + "description": "Grant UCI access for luci-app-qbittorrent", + "read": { + "uci": [ "qbittorrent" ] + }, + "write": { + "uci": [ "qbittorrent" ] + } + } +}