标签 thunder 下的文章

本补丁文件,修正了V1.0.0版本的适配问题。新增了用户运行权限。
微信图片_20231229001008.png

--- feeds/thunder/openwrt/luci-app-thunder/luasrc/view/thunder/thunder_status.htm
+++ feeds/thunder/openwrt/luci-app-thunder/luasrc/view/thunder/thunder_status.htm
@@ -7,7 +7,7 @@
             {
                 if (data.running)
                 {
-                    tb.innerHTML = '<em style=\"color:green\"><b>' + data.application + '<%:RUNNING%></b></em>' + "<input class=\"cbi-button cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('//" + window.location.hostname + ":" + <%=luci.sys.exec("uci -q get thunder.@thunder[0].port"):gsub("^%s*(.-)%s*$", "%1")%> + "/')\"/>";
+                    tb.innerHTML = '<em style=\"color:green\"><b>' + data.application + '<%:RUNNING%></b></em>' + "<input class=\"cbi-button cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('//" + window.location.hostname + ":" + <%=luci.sys.exec("uci -q get thunder.@thunder[0].bind | awk -F: '//{print $2}'"):gsub("^%s*(.-)%s*$", "%1")%> + "/')\"/>";
                 }
                 else
                 {


--- feeds/thunder/openwrt/luci-app-thunder/luasrc/model/cbi/thunder/client.lua
+++ feeds/thunder/openwrt/luci-app-thunder/luasrc/model/cbi/thunder/client.lua
@@ -1,3 +1,6 @@
+local sys  = require "luci.sys"
+local util = require "luci.util"
+
 local m, s
 
 m = Map("thunder", translate("Thunder"))
@@ -15,6 +18,12 @@
 o = s:option(Flag, "debug", translate("Debug"))
 o.rmempty = false
 
+user = s:option(ListValue, "user", translate("Run daemon as user"))
+local p_user
+for _, p_user in util.vspairs(util.split(sys.exec("cat /etc/passwd | cut -f 1 -d :"))) do
+    user:value(p_user)
+end
+
 o = s:option(Value, "bind", translate("Bind"))
 o.default = "0.0.0.0:5055"
 

--- feeds/thunder/openwrt/thunder/files/thunder.init
+++ feeds/thunder/openwrt/thunder/files/thunder.init
@@ -8,6 +8,7 @@
     config_get_bool enabled $1 enabled 0
     config_get_bool debug $1 debug 0
     config_get bind $1 bind "0.0.0.0:5055"
+    config_get user $1 user "root"
     config_get auth_password $1 auth_password ''
     config_get config_path $1 config_path "/opt/thunder"
     config_get download_path $1 download_path "/opt/thunder/downloads"
@@ -42,10 +43,19 @@
     fi
 
     rm -rf /var/packages/pan-xunlei-com
-    mkdir -p /var/packages/pan-xunlei-com
-    ln -s /usr/share/thunder/target /var/packages/pan-xunlei-com
-    ln -s /usr/share/thunder/target/host/etc/synoinfo.conf /etc/synoinfo.conf
-    ln -s /usr/share/thunder/target/host/usr/syno/synoman/webman/modules/authenticate.cgi /usr/syno/synoman/webman/modules/authenticate.cgi
+    #mkdir -p /var/packages/pan-xunlei-com
+    if [ ! -d  "/opt/pan-xunlei-com" ] ; then
+        ln -s /mnt/sdb1 /opt
+    fi
+    ln -s /opt/pan-xunlei-com /var/packages/pan-xunlei-com
+    #ln -s /usr/share/thunder/target /var/packages/pan-xunlei-com
+    #ln -s /usr/share/thunder/target/host/etc/synoinfo.conf /etc/synoinfo.conf
+    #ln -s /usr/share/thunder/target/host/usr/syno/synoman/webman/modules/authenticate.cgi /usr/syno/synoman/webman/modules/authenticate.cgi
+
+    /bin/sh -c "$PROG uninstall --uid 0 --gid 0 "
+
+    /bin/sh -c "$PROG install --uid $(awk -F: '/'$user'/{print $3}' /etc/passwd)  --gid 0  --config-path $config_path --download-path $download_path --mount-bind-download-path $mount_bind_download_path"
+
 
     if [ ! -d "$config_path" ]; then
         mkdir -p $config_path
@@ -59,7 +69,7 @@
         mkdir -p $mount_bind_download_path
     fi
     
-    args="--bind $bind --config-path $config_path --download-path $download_path --mount-bind-download-path $mount_bind_download_path"
+    args="--bind $bind"
 
     if [ -n "$auth_password" ]; then
         args="$args --auth-password $auth_password"
@@ -70,7 +80,7 @@
     fi
     
     procd_open_instance
-    procd_set_param command /bin/sh -c "$PROG launcher $args >>/var/log/thunder.log 2>&1"
+    procd_set_param command /bin/sh -c "$PROG start $args >>/var/log/thunder.log 2>&1"
     procd_set_param stdout 0
     procd_set_param stderr 0
     procd_set_param pidfile /var/run/thunder.pid
@@ -91,3 +101,8 @@
     done
     start
 }
+
+stop_service() {
+    /bin/sh -c "$PROG stop --uid 0 --gid 0 "
+
+}


--- feeds/thunder/openwrt/thunder/files/thunder.config
+++ feeds/thunder/openwrt/thunder/files/thunder.config
@@ -3,7 +3,7 @@
     option 'enabled' '0'
     option 'debug' '0'
     option 'bind' '0.0.0.0:5055'
-    option 'port' '5055'
+    option 'user' 'root'
     option 'auth_password' ''
     option 'download_path' '/opt/thunder/downloads'
     option 'mount_bind_download_path' '/thunder'


--- feeds/thunder/openwrt/thunder/Makefile
+++ feeds/thunder/openwrt/thunder/Makefile
@@ -2,7 +2,7 @@
 
 PKG_NAME:=thunder
 
-PKG_VERSION:=3.11.2-32
+PKG_VERSION:=1.0.0
 
 PKG_LICENSE:=MIT
 PKG_MAINTAINER:=gngpp <gngppz@gmail.com>
@@ -42,7 +42,7 @@
     rm $(PKG_SOURCE).sha256 $(PKG_SOURCE)
 
     tar -xvf $(DL_DIR)/$(PKG_SOURCE)
-    mv thunder-$(PKG_VERSION)-$(ARCH)-unknown-linux-musl/* $(PKG_BUILD_DIR)/
+    mv thunder $(PKG_BUILD_DIR)/
 endef
 
 define Build/Compile
@@ -69,7 +69,7 @@
     $(INSTALL_DIR) $(1)/usr/share/thunder/target
     $(INSTALL_DIR) $(1)/usr/share/thunder/target/host
     $(INSTALL_DIR) $(1)/usr/share/thunder/target/etc
-    $(CP) $(PKG_BUILD_DIR)/bin/* $(1)/usr/share/thunder/target/
+    #$(CP) $(PKG_BUILD_DIR)/bin/* $(1)/usr/share/thunder/target/
 
     $(INSTALL_DIR) $(1)/etc/init.d
     $(INSTALL_BIN) $(CURDIR)/files/thunder.init $(1)/etc/init.d/thunder

补丁文件下载:071_fix-thunder.zip