From c9ad9623c80ddf2db2a734b4a7914ab9eebd84fb Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Sun, 1 Jun 2014 16:04:55 +0100 Subject: Added the script `make_repo_torrents' which makes torrents for all the packages. --- cron-jobs/make_repo_torrents | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 cron-jobs/make_repo_torrents (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents new file mode 100644 index 0000000..d3c3df6 --- /dev/null +++ b/cron-jobs/make_repo_torrents @@ -0,0 +1,81 @@ +#! /bin/bash +# Copyright (C) 2014 Joseph Graham +# +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This script depends on `mktorrent' + +username=$( id -un ) + +case "${username}" in + repo | root ) + true + ;; + * ) + echo "This script must be run as repo user or root user." + echo "ByeBye!" + exit 1 + ;; +esac + +# pacman doesn't support multiple different packages of the same name, +# so it's OK to just stuff all the torrents into a single directory. +torrent_location='/srv/http/repo/public/torrents/' +public_location='/srv/http/repo/public/' + +# Tracker announce URL +tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon + +# All mirrors go here +declare -a url_prefixes=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') + +cd "${torrent_location}" + +find "${public_location}" -name 'os' -type 'd' | +while read dir +do + find "${dir}" -name '*\.pkg\.tar\.xz' | + while read pkg + do + pkg_name="${pkg##*/}" + + if [[ -h "${pkg}" ]] # check if it's a symbolic link + then + # We get the target of the symlink + pkg=$( readlink -f "${pkg}" ) + fi + + if ! [[ -f "${torrent_location}${pkg_name}.torrent" ]] + then + # We need to make a comma seperated list of webseeds (this is passed + # as a single argument to mktorrent) + webseeds='' + + for prefix in "${url_prefixes[@]}" + do + webseeds+="${prefix}${pkg#${public_location}}," + done + + # There should not be a random comma at the end of the webseeds + webseeds="${webseeds%,}" + + mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" # "${torrent_location}" + fi + done +done + +if [[ "${username}" == root ]] +then + chown repo * +fi -- cgit v1.2.3-2-g168b From ee8da885dc5062001861e4355602a39ae972c32c Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Mon, 2 Jun 2014 12:48:47 +0100 Subject: Made it randomize the order of the webseed list for every torrent. --- cron-jobs/make_repo_torrents | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index d3c3df6..dffd0dc 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -38,7 +38,25 @@ public_location='/srv/http/repo/public/' tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon # All mirrors go here -declare -a url_prefixes=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') +declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') + +# I got this function from http://mywiki.wooledge.org/BashFAQ/026 . It +# shuffles an array. Uses a global array variable. Must be compact +# (not a sparse array). The array must be called `array'. +shuffle() { + local i tmp size max rand + + # $RANDOM % (i+1) is biased because of the limited range of $RANDOM + # Compensate by using a range which is a multiple of the array size. + size=${#array[*]} + max=$(( 32768 / size * size )) + + for ((i=size-1; i>0; i--)); do + while (( (rand=$RANDOM) >= max )); do :; done + rand=$(( rand % (i+1) )) + tmp=${array[i]} array[i]=${array[rand]} array[rand]=$tmp + done +} cd "${torrent_location}" @@ -62,7 +80,12 @@ do # as a single argument to mktorrent) webseeds='' - for prefix in "${url_prefixes[@]}" + # Randomize the order of the list of webseeds because I + # don't know if transmission might always use the one at + # the top otherwize. + shuffle + + for prefix in "${array[@]}" do webseeds+="${prefix}${pkg#${public_location}}," done -- cgit v1.2.3-2-g168b From 6979cf5d1e4a599fbabaed4fe643e9db0f0f871c Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Mon, 2 Jun 2014 12:54:47 +0100 Subject: Added encyclomundi's mirror to the webseeds array. --- cron-jobs/make_repo_torrents | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index dffd0dc..246264d 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -38,7 +38,7 @@ public_location='/srv/http/repo/public/' tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon # All mirrors go here -declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/') +declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') # I got this function from http://mywiki.wooledge.org/BashFAQ/026 . It # shuffles an array. Uses a global array variable. Must be compact -- cgit v1.2.3-2-g168b From ad79659b3057fd5afac3629e9dd53ea3b93fb58e Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Fri, 6 Jun 2014 12:29:21 +0100 Subject: Made it only give output on an error. --- cron-jobs/make_repo_torrents | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index 246264d..797142e 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -93,7 +93,8 @@ do # There should not be a random comma at the end of the webseeds webseeds="${webseeds%,}" - mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" # "${torrent_location}" + mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" >/dev/null || + echo "Error making torrent for \"${pkg}\"" fi done done -- cgit v1.2.3-2-g168b From c121ead116f26ed2b36247247fdf4a0d19f063f2 Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Mon, 16 Jun 2014 14:09:50 +0100 Subject: removed all mirrors but one since pacman2pacman now re-writes the webseeds list to just point to the user's chosen mirror. --- cron-jobs/make_repo_torrents | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index 797142e..0798a5e 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -38,7 +38,11 @@ public_location='/srv/http/repo/public/' tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon # All mirrors go here -declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') +#declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') + +# I'm removing all mirrors but one since pacman2pacman now re-writes +# the webseeds list to just point to the user's chosen mirror +declare -a array=('http://repo.parabolagnulinux.org/') # I got this function from http://mywiki.wooledge.org/BashFAQ/026 . It # shuffles an array. Uses a global array variable. Must be compact -- cgit v1.2.3-2-g168b From ee08c7abc25647e8ad038df03ac35144401b6091 Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Sun, 29 Jun 2014 15:34:37 +0100 Subject: Added an additional tracker. --- cron-jobs/make_repo_torrents | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index 0798a5e..b5c6749 100644 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -34,8 +34,8 @@ esac torrent_location='/srv/http/repo/public/torrents/' public_location='/srv/http/repo/public/' -# Tracker announce URL -tracker='http://t67.eu:6969/announce' # t67.eu is run by Xylon +# Tracker announce URLs, comma seperated +tracker='http://t67.eu:6969/announce,http://tracker.hackcoop.com.ar/announce' # t67.eu is run by Xylon # All mirrors go here #declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') -- cgit v1.2.3-2-g168b From 5fad74e56b72810c9d7f86956236ff45654fb684 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 26 Jul 2014 20:20:33 -0400 Subject: make_repo_torrents: load the location from the common config file --- cron-jobs/make_repo_torrents | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) mode change 100644 => 100755 cron-jobs/make_repo_torrents (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents old mode 100644 new mode 100755 index b5c6749..faee191 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -31,8 +31,9 @@ esac # pacman doesn't support multiple different packages of the same name, # so it's OK to just stuff all the torrents into a single directory. -torrent_location='/srv/http/repo/public/torrents/' -public_location='/srv/http/repo/public/' +. "$(dirname "$(readlink -e "$0")")/../config" +public_location="$FTP_BASE/" +torrent_location="$FTP_BASE/torrents/" # Tracker announce URLs, comma seperated tracker='http://t67.eu:6969/announce,http://tracker.hackcoop.com.ar/announce' # t67.eu is run by Xylon -- cgit v1.2.3-2-g168b From b2a763cee1f67751065c39800a59c431ec872bfa Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Sun, 27 Jul 2014 11:55:01 +0100 Subject: Dividing make_repo_torrents into two scripts, one to make the actual torrent and a wrapper to find any updated packages and call the first script for each... --- cron-jobs/make_repo_torrents | 57 ++++++-------------------------------------- 1 file changed, 7 insertions(+), 50 deletions(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index faee191..c94d073 100755 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# This script depends on `mktorrent' +# This script finds any updated packages and makes calls +# `make_indivudual_torrent' for each of them. username=$( id -un ) @@ -35,71 +36,27 @@ esac public_location="$FTP_BASE/" torrent_location="$FTP_BASE/torrents/" -# Tracker announce URLs, comma seperated -tracker='http://t67.eu:6969/announce,http://tracker.hackcoop.com.ar/announce' # t67.eu is run by Xylon - -# All mirrors go here -#declare -a array=('http://repo.parabolagnulinux.org/' 'https://parabola.goodgnus.com.ar/' 'http://mirror.yandex.ru/mirrors/parabola/' 'http://alfplayer.com/parabola/' 'http://mirror.parlementum.net/') - -# I'm removing all mirrors but one since pacman2pacman now re-writes -# the webseeds list to just point to the user's chosen mirror -declare -a array=('http://repo.parabolagnulinux.org/') - -# I got this function from http://mywiki.wooledge.org/BashFAQ/026 . It -# shuffles an array. Uses a global array variable. Must be compact -# (not a sparse array). The array must be called `array'. -shuffle() { - local i tmp size max rand - - # $RANDOM % (i+1) is biased because of the limited range of $RANDOM - # Compensate by using a range which is a multiple of the array size. - size=${#array[*]} - max=$(( 32768 / size * size )) - - for ((i=size-1; i>0; i--)); do - while (( (rand=$RANDOM) >= max )); do :; done - rand=$(( rand % (i+1) )) - tmp=${array[i]} array[i]=${array[rand]} array[rand]=$tmp - done -} - cd "${torrent_location}" +# Find any directories that might have packages in then find "${public_location}" -name 'os' -type 'd' | while read dir do + # Find any packages find "${dir}" -name '*\.pkg\.tar\.xz' | while read pkg do - pkg_name="${pkg##*/}" - if [[ -h "${pkg}" ]] # check if it's a symbolic link then # We get the target of the symlink pkg=$( readlink -f "${pkg}" ) fi + # If a .torrent file does not already exist for this package, we call + # `make_individual_torrent' to make it. if ! [[ -f "${torrent_location}${pkg_name}.torrent" ]] then - # We need to make a comma seperated list of webseeds (this is passed - # as a single argument to mktorrent) - webseeds='' - - # Randomize the order of the list of webseeds because I - # don't know if transmission might always use the one at - # the top otherwize. - shuffle - - for prefix in "${array[@]}" - do - webseeds+="${prefix}${pkg#${public_location}}," - done - - # There should not be a random comma at the end of the webseeds - webseeds="${webseeds%,}" - - mktorrent -a "${tracker}" "${pkg}" -w "${webseeds}" >/dev/null || - echo "Error making torrent for \"${pkg}\"" + /srv/http/repo/dbscripts/make_individual_torrent "${pkg}" fi done done -- cgit v1.2.3-2-g168b From 6790ac43f2f79fea6adcfef2a10d3c4105574216 Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Sun, 27 Jul 2014 12:07:06 +0100 Subject: fixed loads of mistakes I make --- cron-jobs/make_repo_torrents | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index c94d073..a5d72a5 100755 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -46,6 +46,8 @@ do find "${dir}" -name '*\.pkg\.tar\.xz' | while read pkg do + pkg_name="${pkg##*/}" + if [[ -h "${pkg}" ]] # check if it's a symbolic link then # We get the target of the symlink @@ -56,7 +58,7 @@ do # `make_individual_torrent' to make it. if ! [[ -f "${torrent_location}${pkg_name}.torrent" ]] then - /srv/http/repo/dbscripts/make_individual_torrent "${pkg}" + /srv/http/repo/dbscripts/make_individual_torrent "${pkg}" "${public_location}" fi done done -- cgit v1.2.3-2-g168b From 5e9c23a6cc430138358c97544b1a9219d643b6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Mas=C5=82owski?= Date: Tue, 30 Sep 2014 21:18:41 +0200 Subject: Fix make_repo_torrents for the new server. --- cron-jobs/make_repo_torrents | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index a5d72a5..fec4698 100755 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -32,6 +32,7 @@ esac # pacman doesn't support multiple different packages of the same name, # so it's OK to just stuff all the torrents into a single directory. +script_directory="$(dirname "$(readlink -e "$0")")/.." . "$(dirname "$(readlink -e "$0")")/../config" public_location="$FTP_BASE/" torrent_location="$FTP_BASE/torrents/" @@ -58,7 +59,7 @@ do # `make_individual_torrent' to make it. if ! [[ -f "${torrent_location}${pkg_name}.torrent" ]] then - /srv/http/repo/dbscripts/make_individual_torrent "${pkg}" "${public_location}" + "$script_directory/make_individual_torrent" "${pkg}" "${public_location}" fi done done -- cgit v1.2.3-2-g168b From 724674000a5c4ac1ce87db0b5f86b51d1d070a41 Mon Sep 17 00:00:00 2001 From: Joseph Graham Date: Fri, 3 Oct 2014 22:21:44 +0100 Subject: Fixed typo in comments --- cron-jobs/make_repo_torrents | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index fec4698..fc723f1 100755 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# This script finds any updated packages and makes calls +# This script finds any updated packages and calls # `make_indivudual_torrent' for each of them. username=$( id -un ) -- cgit v1.2.3-2-g168b From d0834f7e6bd53ea729374eab138bb38a36c73996 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 20 May 2015 20:41:17 -0600 Subject: Clean up shebangs --- cron-jobs/make_repo_torrents | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cron-jobs/make_repo_torrents') diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index fc723f1..2eb0978 100755 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash # Copyright (C) 2014 Joseph Graham # # This program is free software: you can redistribute it and/or modify -- cgit v1.2.3-2-g168b