diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2018-09-25 02:17:03 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-09-25 02:25:32 -0400 |
commit | 42b999d0510e55f302d8c871bbba4d87d38eb6a1 (patch) | |
tree | 0110770c7ff09d548ebec56e044af188f39e1eac | |
parent | 409980fcca34075f20d8d7da049f9859702a1daf (diff) |
make_repo_torrents: Tidy
-rwxr-xr-x | cron-jobs/make_repo_torrents | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index 68cc942..dfcdad1 100755 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -26,36 +26,27 @@ set -eE . "$(dirname "$(readlink -e "$0")")/../torrent.conf" . "$(dirname "$(readlink -e "$0")")/../db-functions" -make_individual_torrent() { - local pkgfile=$1 - local IFS=, - mktorrent \ - -a "${TRACKERS[*]}" \ - -w "${WEBSEED_MIRROR}${pkgfile#"${FTP_BASE}/"}" \ - -- "${pkgfile}" >/dev/null -} - mkdir -p -- "${FTP_BASE}/${TORRENTPOOL}" cd "${FTP_BASE}/${TORRENTPOOL}" +IFS=, # for ${TRACKERS[*]} + # Find any packages -for pkgpath in "$FTP_BASE"/*/os/*/*${PKGEXTS}; do +for pkgfile in "$FTP_BASE"/*/os/*/*${PKGEXTS}; do # Resolve any symlinks - pkgpath=$(readlink -f -- "$pkgpath") - pkgfile="${pkgpath##*/}" + pkgfile=$(readlink -f -- "$pkgfile") - # If a .torrent file does not already exist for this package, we call - # `make_individual_torrent' to make it. - if ! [[ -f ${pkgfile}.torrent ]]; then - make_individual_torrent "$pkgpath" + if ! [[ -f ${pkgfile##*/}.torrent ]]; then + mktorrent \ + --announce="${TRACKERS[*]}" \ + --web-seed="${WEBSEED_MIRROR}${pkgfile#"${FTP_BASE}/"}" \ + -- "${pkgfile}" >/dev/null fi done # For torrents older than 1 year, we check if it's package still -# exists, else clean it up. This shouldn't be done every hour, but it -# is good for it to be in this cronjob so it can re-use the -# $pkgfilelist we made earlier. So we do it with a 1-in-30 -# probability. +# exists, else clean it up. This shouldn't be done every hour. So we +# do it with a 1-in-30 probability. if ! (( $(shuf -e {0..29} | head -1) )); then while read -r torrent; do pkgfile="${torrent##*/}" |