[gimp-web] tools: add mirrorsfile parameter to mt torrent script, convert trackers variables to array



commit adb5e6b4200585b39af08c822c70fa4194330bee
Author: Michael Schumacher <schumaml gmx de>
Date:   Tue Jun 8 21:26:08 2021 +0200

    tools: add mirrorsfile parameter to mt torrent script, convert trackers variables to array
    
    The parameter -m specifies the mirror file path and file name instead of assuming it is in the current
    directory. The torrent trackers are now an extensible string array (in sh-compatible syntax) instead of a
    limited list of variables.

 tools/downloads/mt | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/tools/downloads/mt b/tools/downloads/mt
index 0666a20d..115b0627 100755
--- a/tools/downloads/mt
+++ b/tools/downloads/mt
@@ -2,13 +2,15 @@
 
 OPTIND=1
 
-tracker1=udp://tracker.opentrackr.org:1337/announce
-tracker2=udp://tracker.coppersurfer.tk:6969/announce
-tracker3=udp://tracker.leechers-paradise.org:6969/announce
-tracker4=https://ashrise.com:443/phoenix/announce
-tracker5=udp://tracker.openbittorrent.com:80/announce
-
-while getopts "c:o:p:" opt; do
+# list of trackers - array in sh-compatible syntax
+trackers_list=""
+trackers_list="${trackers_list} udp://tracker.opentrackr.org:1337/announce"
+trackers_list="${trackers_list} udp://tracker.coppersurfer.tk:6969/announce"
+trackers_list="${trackers_list} udp://tracker.leechers-paradise.org:6969/announce"
+trackers_list="${trackers_list} udp://tracker.openbittorrent.com:80/announce"
+trackers_list="${trackers_list} https://ashrise.com:443/phoenix/announce";
+
+while getopts "c:o:p:m:" opt; do
     case "$opt" in
        c)
            comment=$OPTARG
@@ -19,6 +21,8 @@ while getopts "c:o:p:" opt; do
        p)
            localpath=$OPTARG
            ;;
+        m)
+            mirrorsfile=$OPTARG
     esac
 done
 
@@ -26,13 +30,21 @@ shift $((OPTIND-1))
 
 [ "$1" = "--" ] && shift
 
-echo "comment=$comment; outfile=$outfile; localpath=$localpath; 1=$1; rest=$@"
+echo "comment=$comment; outfile=$outfile; localpath=$localpath; mirrorsfile=$mirrorsfile; 1=$1; rest=$@"
 
-rawurllist=`cat ./downloads.http.txt | xargs | sed -e 's/ /localpath,/g' | sed -e 's/$/localpath/'`
+rawurllist=`cat $mirrorsfile | xargs | sed -e 's/ /localpath,/g' | sed -e 's/$/localpath/'`
 # currentpath=`readlink -f $1 | sed -e 's_/srv/ftp/pub/gimp/__'`
 # localpath=`dirname $currentpath`
 
 urllist=`echo $rawurllist | sed -e 's@localpath@'"$localpath/"'@g'`
 
-echo mktorrent -a $tracker1 -a $tracker2 -a $tracker3 -a $tracker4 -a $tracker5 -w $urllist -c \"$comment\" 
$1
-mktorrent -a $tracker1 -a $tracker2 -a $tracker3 -a $tracker4 -a $tracker5 -w $urllist -c "$comment" $1
+# build trackers list
+trackers=''
+for tracker in ${trackers_list}
+do
+    trackers="${trackers} -a ${tracker}"
+done
+
+# create the torrent
+echo mktorrent $trackers -w $urllist -c \"$comment\" $1
+mktorrent $trackers -w $urllist -c \"$comment\" $1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]