From fe27caea29421b01e502a6b99cb59707bfe467be Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Sep 2018 01:49:27 -0400 Subject: Clean up make_individual_torrent, add config drop the second argument - Add 'torrent.conf' instead of hard-coding the settings - The second argument is $FTP_BASE, just load that from 'config', rather than asking for it. --- make_individual_torrent | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) (limited to 'make_individual_torrent') diff --git a/make_individual_torrent b/make_individual_torrent index d44bb24..2cfb6ce 100755 --- a/make_individual_torrent +++ b/make_individual_torrent @@ -1,5 +1,6 @@ #!/bin/bash # Copyright (C) 2014, 2017 Joseph Graham +# Copyright (C) 2018 Luke Shumaker # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,34 +20,19 @@ # $1 - path of package # $2 - public location -# Comma seperated list of trackers, no spaces -# taskenizer.crabdance.com is run by Xylon. the others come from https://github.com/ngosang/trackerslist -trackers='http://taskenizer.crabdance.com:6969/announce,http://tracker.opentrackr.org:1337/announce,udp://tracker.pirateparty.gr:6969/announce' +source "$(dirname "$(readlink -e "$0")")/config" +source "$(dirname "$(readlink -e "$0")")/torrent.conf" +source "$(librelib messages)" -# This mirror is put as a webseed. Which mirror we use for a webseed -# doesn't really matter since it's re-written on the client machine by -# pacman2pacman so it won't normally be used anyway. -seed_url='http://repo.parabolagnulinux.org/' - -if [[ -z "${1}" ]] -then - echo "Error. First arg must be the path of the package." - echo 1 -fi - -if [[ -z "${2}" ]] -then - echo "Error. Second arg must be the public location." - echo 1 +if (( $# != 1 )) || [[ $1 != "$FTP_BASE"/* ]]; then + msg "usage: %s " + exit $EXIT_INVALIDARGUMENT fi -pkg="${1}" -public_location="${2}" - -pkg_name="${pkg##*/}" - -# URL of the actual package for the webseed -webseed="${seed_url}${pkg#${public_location}}" +pkgfile=$1 -mktorrent -a "${trackers}" "${pkg}" -w "${webseed}" >/dev/null || - echo "Error making torrent for \"${pkg}\"" +IFS=, +mktorrent \ + -a "${TRACKERS[*]}" \ + -w "${WEBSEED_MIRROR}${pkgfile#"${FTP_BASE}/"}" \ + -- "${pkgfile}" >/dev/null -- cgit v1.2.2