From f0f38c7807dbbd7eb8e34b6927a7a486a3bb7d8d Mon Sep 17 00:00:00 2001 From: Simon Doppler Date: Mon, 14 May 2018 16:38:45 +0200 Subject: update-website: add option '--torrent-only' Useful to automate torrent generation and website update (no manual intervention required). --- update-website | 74 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/update-website b/update-website index 2d51bc3..fb58871 100755 --- a/update-website +++ b/update-website @@ -24,6 +24,8 @@ usage() { >&2 echo ' Set website-dir to $dir.' >&2 echo ' --mirror-dir $dir:' >&2 echo ' Set mirror-dir to $dir.' + >&2 echo ' --torrent-only:' + >&2 echo ' Update only torrent related data.' [ -z "$1" ] && exit 1 || exit "$1" } @@ -36,6 +38,7 @@ eval set -- "$( --long torrent-seed-dual: \ --long mirror-dir: \ --long website-dir: \ + --long torrent-only \ -n "$(basename "$0")" -- "$@" || \ echo usage )" @@ -109,6 +112,13 @@ while [ $# -gt 0 ]; do website_dir="$1" echo "$website_dir" > "${tmp_dir}/website_dir.set" ;; + '--torrent-only') + if [ -s "${tmp_dir}/torrent_only.set" ]; then + printf 'Option %s given multiple times.\n' "$1" + usage + fi + echo "true" > "${tmp_dir}/torrent_only.set" + ;; '--') shift break @@ -194,6 +204,40 @@ declare -A desc desc['i686']='i686 only' desc['dual']='dual bootable' +for arch in "${!desc[@]}"; do + if [ ! -s "${tmp_dir}/magnet.${arch}" ]; then + continue + fi + if ! tr '&' '\n' < \ + "${tmp_dir}/magnet.${arch}" | \ + grep -qxF "dn=archlinux-${latest_iso_date}-${arch}.iso"; then + >&2 printf 'Magnet link for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" + continue + fi + sed -i ' + /
  • Magnet link for \S\+ ('"${desc["${arch}"]}"')/ s/>Magnet link for \S\+ />Magnet link for '"${latest_iso_date}"' / + ' "${website_dir}/download/index.html" +done + +for arch in "${!desc[@]}"; do + if [ ! -s "${tmp_dir}/torrent-seed.${arch}" ]; then + continue + fi + if ! grep -qF "archlinux-${latest_iso_date}-${arch}" "${tmp_dir}/torrent-seed.${arch}"; then + >&2 printf 'Torrent seed for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" + continue + fi + sed -i ' + /
  • Torrent for \S\+ ('"${desc["${arch}"]}"')/ s/>Torrent for \S\+ />Torrent for '"${latest_iso_date}"' / + ' "${website_dir}/download/index.html" +done + +if [ -s "${tmp_dir}/torrent_only.set" ]; then + exit +fi + unset kernels unset sizes declare -A sizes @@ -281,33 +325,3 @@ sed -i "$( ) " \ "${website_dir}/download/index.html" - -for arch in "${!desc[@]}"; do - if [ ! -s "${tmp_dir}/magnet.${arch}" ]; then - continue - fi - if ! tr '&' '\n' < \ - "${tmp_dir}/magnet.${arch}" | \ - grep -qxF "dn=archlinux-${latest_iso_date}-${arch}.iso"; then - >&2 printf 'Magnet link for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" - continue - fi - sed -i ' - /
  • Magnet link for \S\+ ('"${desc["${arch}"]}"')/ s/>Magnet link for \S\+ />Magnet link for '"${latest_iso_date}"' / - ' "${website_dir}/download/index.html" -done - -for arch in "${!desc[@]}"; do - if [ ! -s "${tmp_dir}/torrent-seed.${arch}" ]; then - continue - fi - if ! grep -qF "archlinux-${latest_iso_date}-${arch}" "${tmp_dir}/torrent-seed.${arch}"; then - >&2 printf 'Torrent seed for %s is not for %s, skipping.\n' "${arch}" "archlinux-${latest_iso_date}-${arch}.iso" - continue - fi - sed -i ' - /
  • Torrent for \S\+ ('"${desc["${arch}"]}"')/ s/>Torrent for \S\+ />Torrent for '"${latest_iso_date}"' / - ' "${website_dir}/download/index.html" -done -- cgit v1.2.3-70-g09d2