#!/bin/sh # first choice is curl(1), should be OK for Linux if command -v curl >/dev/null 2>&1; then __download () { curl -sL "$1" } # second is fetch(1), for FreeBSD elif command -v fetch >/dev/null 2>&1; then __download () { fetch -q -o - "$1" } # last comes ftp(1), which does far more than its name implies (OpenBSD only) elif [ "$(uname -s)" = OpenBSD ] && command -v ftp >/dev/null 2>&1; then __download () { ftp -o - "$1" } else printf '%s\n' "Oh no! You don't seem to have curl(1) or fetch(1)" >&2 printf '%s\n' "I'm cowardly exiting" >&2 exit 4 fi # We find magnet links __magnet () { __download "$1" | grep -Eo 'magnet:\?[^"<> ]+' } # We find absolute torrent links __abs_torrent () { __download "$1" | grep -Eo 'href="?[^"]+\.torrent' | grep -Eo '[^"=]+\.torrent' } __root_torrent () { _domain="$(printf '%s\n' "$1" | grep -Eo 'https?://[^/]+')" __download "$1" | grep -Eo 'href="?[^"]+\.torrent' | grep -Eo '[^"=]+\.torrent' | while read -r _root_link; do printf '%s/%s\n' "$_domain" "$_root_link" done } # We find relative links to the torrents and generate an absolute link __rel_torrent () { _page="$1" __download "$_page" | grep -Eo 'href="?[^"]+\.torrent' | grep -Eo '[^"=]+\.torrent' | while read -r _rel_link; do printf '%s%s\n' "$_page" "$_rel_link" done unset _page _rel_link } # Archlinux __magnet 'https://www.archlinux.org/download/' # Debian for _arch in amd64 i386 ; do # Installation media for _medium in 'cd' 'dvd'; do __rel_torrent "https://cdimage.debian.org/debian-cd/current/$_arch/bt-$_medium/" done # Live CD __rel_torrent "https://cdimage.debian.org/debian-cd/current-live/$_arch/bt-hybrid/" done # devuan __magnet "https://www.devuan.org/get-devuan" # Ubuntu __abs_torrent 'https://ubuntu.com/download/alternative-downloads' # openSUSE # Doesn't provide torrents anymore! # Linux Mint # It's not trivial to get a page with the latest torrents # Fedora # Doesn't seem to provide torrents..? # Elementary __magnet 'https://elementary.io' # CentOS # It's not trivial to get a page with the latest torrents # ReactOS # Uses sourceforge to distribute its isos # Kali # https://www.kali.org/downloads/ forces gzip encoding. I'm not dealing with # this crap. Learn how to configure your webserver. # KDE Neon # Doesn't seem to provide torrents..? # Mageia __magnet "http://www.mageia.org/en/downloads/alternative/" # tails __rel_torrent 'https://tails.boum.org/torrents/files/' # FreeBSD __magnet "https://wiki.freebsd.org/Torrents" # Solus __abs_torrent "https://getsol.us/download/" # Parrot for _version in security home; do __abs_torrent "https://parrotsec.org/${_version}-edition/" done # lubuntu __abs_torrent "https://lubuntu.me/downloads/" # slackware __root_torrent "http://www.slackware.com/getslack/torrents.php"