commit 9850326f67dfcc5a69039b6bc9328b2c92a8bc6b Author: Ben Date: Sun Sep 3 05:07:02 2023 +0000 first commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0a8db18 --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=luci-app-qbittorrent +PKG_VERSION:=1.0.7 +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=luci + CATEGORY:=LuCI + SUBMENU:=3. Applications + TITLE:=qBittorrent Luci Application bundled with specific Qbittorrent x86 dependencies + DEPENDS:=+libstdcpp +luci-compat +libQt6Xml +libQt6Sql +libQt6Network +libQt6Core +libopenssl +boost-system +boost +zlib +rblibtorrent +qt6-plugin-libqsqlite +qt6-plugin-libqopensslbackend +qBittorrent +libpcre +endef + +define Package/$(PKG_NAME)/description + qBittorrent Luci is an all-in-one installer for Qbittorrent on x86 with custom dependencies +endef + +define Build/Prepare + $(foreach ipk,$(wildcard $(CURDIR)/files/*.ipk),$(CP) $(ipk) $(PKG_BUILD_DIR);) +endef + +define Build/Compile +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_DIR) $(1)/tmp + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/qbittorrent + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d/ + + $(INSTALL_BIN) ./files/etc/config/qbittorrent $(1)/etc/config/qbittorrent + $(INSTALL_BIN) ./files/etc/init.d/qbittorrent $(1)/etc/init.d/qbittorrent + $(INSTALL_BIN) ./files/etc/uci-defaults/80_qbittorrent $(1)/etc/uci-defaults/80_qbittorrent + $(INSTALL_DATA) ./files/usr/lib/lua/luci/model/cbi/qbittorrent.lua $(1)/usr/lib/lua/luci/model/cbi/qbittorrent.lua + $(INSTALL_DATA) ./files/usr/lib/lua/luci/controller/qbittorrent.lua $(1)/usr/lib/lua/luci/controller/qbittorrent.lua + $(INSTALL_DATA) ./files/usr/share/rpcd/acl.d/luci-app-qbittorrent.json $(1)/usr/share/rpcd/acl.d/luci-app-qbittorrent.json + $(INSTALL_DATA) ./files/usr/lib/lua/luci/view/qbittorrent/qbittorrent_status.htm $(1)/usr/lib/lua/luci/view/qbittorrent/qbittorrent_status.htm + + +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/files/etc/config/qbittorrent b/files/etc/config/qbittorrent new file mode 100644 index 0000000..614a8a4 --- /dev/null +++ b/files/etc/config/qbittorrent @@ -0,0 +1,10 @@ + +config qbittorrent + option profile_dir '/etc' + option download_dir '/mnt/download' + option port '8081' + option enable '0' + option socks5_server 'proxy.torguard.org' + option socks5_port '1085' + option socks5_user 'username' + option socks5_pass 'password' diff --git a/files/etc/init.d/qbittorrent b/files/etc/init.d/qbittorrent new file mode 100644 index 0000000..8d880e2 --- /dev/null +++ b/files/etc/init.d/qbittorrent @@ -0,0 +1,108 @@ +#!/bin/sh /etc/rc.common +START=99 + +get_config() +{ + config_get_bool enable "$1" enable 0 +} + +config_qbittorrent() +{ + local download_dir + local profile_dir + local port + local socks5_server + local socks5_port + local socks5_user + local socks5_pass + config_get download_dir "$1" "download_dir" + config_get port "$1" "port" + config_get socks5_server "$1" "socks5_server" + config_get socks5_port "$1" "socks5_port" + config_get socks5_user "$1" "socks5_user" + config_get socks5_pass "$1" "socks5_pass" + config_get profile_dir "$1" "profile_dir" + mkdir -p "$download_dir" + mkdir -p "$2" "$2/qBittorrent" "$2/qBittorrent/config" + { [ "$2" != "/etc" ] && [ "$2" != "/etc/" ]; } && 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 "/Downloads\\\SavePath/c\Downloads\\\SavePath=$download_dir" "$2/qBittorrent/config/qBittorrent.conf" + sed -i "/Proxy\\\IP/c\Proxy\\\IP=$socks5_server" "$2/qBittorrent/config/qBittorrent.conf" + sed -i "/Proxy\\\Port/c\Proxy\\\Port=$socks5_port" "$2/qBittorrent/config/qBittorrent.conf" + sed -i "/Proxy\\\Username/c\Proxy\\\Username=$socks5_user" "$2/qBittorrent/config/qBittorrent.conf" + sed -i "/Proxy\\\Password/c\Proxy\\\Password=$socks5_pass" "$2/qBittorrent/config/qBittorrent.conf" + else + cat >"$2/qBittorrent/config/qBittorrent.conf"</dev/null 2>&1 +} diff --git a/files/etc/uci-defaults/80_qbittorrent b/files/etc/uci-defaults/80_qbittorrent new file mode 100644 index 0000000..46c89f7 --- /dev/null +++ b/files/etc/uci-defaults/80_qbittorrent @@ -0,0 +1,15 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@qbittorrent[-1] + add ucitrack qbittorrent + set ucitrack.@qbittorrent[-1].init=qbittorrent + commit ucitrack +EOF + +touch /etc/config/qbittorrent +chmod +x /etc/init.d/qbittorrent + +/etc/init.d/qbittorrent start +rm -f /tmp/luci-indexcache +exit 0 diff --git a/files/usr/lib/lua/luci/controller/qbittorrent.lua b/files/usr/lib/lua/luci/controller/qbittorrent.lua new file mode 100644 index 0000000..09d0e72 --- /dev/null +++ b/files/usr/lib/lua/luci/controller/qbittorrent.lua @@ -0,0 +1,22 @@ + +module("luci.controller.qbittorrent", package.seeall) + +function index() + entry({"admin", "nas"}, firstchild(), _("NAS") , 45).dependent = false + if not nixio.fs.access("/etc/config/qbittorrent") then + return + end + + local page = entry({"admin", "nas", "qbittorrent"}, cbi("qbittorrent"), _("qBittorrent")) + page.order = 10 + page.dependent = true + page.acl_depends = { "luci-app-qbittorrent" } + entry({"admin","nas","qbittorrent","status"},call("act_status")).leaf=true +end + +function act_status() + local e={} + e.running=luci.sys.call("pgrep qbittorrent-nox >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/files/usr/lib/lua/luci/model/cbi/qbittorrent.lua b/files/usr/lib/lua/luci/model/cbi/qbittorrent.lua new file mode 100644 index 0000000..0e0e565 --- /dev/null +++ b/files/usr/lib/lua/luci/model/cbi/qbittorrent.lua @@ -0,0 +1,56 @@ +m = Map("qbittorrent", translate("qBittorrent"), translate("qBittorrent is a cross-platform free and open-source BitTorrent client.").."
"..translate("Default login username: admin, password: adminadmin.")) + +m:section(SimpleSection).template="qbittorrent/qbittorrent_status" + +s = m:section(TypedSection, "qbittorrent") +s.anonymous=true + +enable = s:option(Flag, "enable", translate("Enable")) +enable.rmempty = false +enable.write = enable.write + +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 = "/etc" +profile_dir.placeholder = "/etc" +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 + +download_dir = s:option(Value,"socks5_server",translate("Socks5 Server"),translate("Set your sock5 proxy server")) +download_dir.default = "proxy.torguard.org" +download_dir.placeholder = "proxy.torguard.org" +download_dir.rmempty = false + +download_dir = s:option(Value,"socks5_port",translate("Socks5 Port"),translate("Set your sock5 port number")) +download_dir.default = "1085" +download_dir.placeholder = "1085" +download_dir.rmempty = false + +download_dir = s:option(Value,"socks5_user",translate("Socks5 Username"),translate("Set your sock5 username")) +download_dir.default = "username" +download_dir.placeholder = "username" +download_dir.rmempty = false + +download_dir = s:option(Value,"socks5_pass",translate("Socks5 Password"),translate("Set your sock5 password")) +download_dir.default = "password" +download_dir.placeholder = "password" +download_dir.rmempty = false + +function enable.write(self, section, value) + Flag.write(self, section, value) + if value == "1" then + luci.sys.call("/etc/init.d/qbittorrent start >/dev/null 2>&1") + else + luci.sys.call("/etc/init.d/qbittorrent stop >/dev/null 2>&1") + end +end + +return m diff --git a/files/usr/lib/lua/luci/view/qbittorrent/qbittorrent_status.htm b/files/usr/lib/lua/luci/view/qbittorrent/qbittorrent_status.htm new file mode 100644 index 0000000..b604cd2 --- /dev/null +++ b/files/usr/lib/lua/luci/view/qbittorrent/qbittorrent_status.htm @@ -0,0 +1,27 @@ + + +
+

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

+
diff --git a/files/usr/share/rpcd/acl.d/luci-app-qbittorrent.json b/files/usr/share/rpcd/acl.d/luci-app-qbittorrent.json new file mode 100644 index 0000000..c46f3c9 --- /dev/null +++ b/files/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" ] + } + } +} diff --git a/install_dependancies.tar.gz b/install_dependancies.tar.gz new file mode 100644 index 0000000..001b496 Binary files /dev/null and b/install_dependancies.tar.gz differ diff --git a/removedline.txt b/removedline.txt new file mode 100644 index 0000000..0a7b80a --- /dev/null +++ b/removedline.txt @@ -0,0 +1,2 @@ + $(CP) $(PKG_BUILD_DIR)/*.ipk $(1)/tmp/ + $(INSTALL_BIN) ./files/install_dependencies.sh $(1)/usr/bin/install_dependencies.sh