From 5303d8c8b0c72914e62c97f8237bc9c853fe6eac Mon Sep 17 00:00:00 2001 From: Simon Doppler Date: Mon, 4 Sep 2017 18:39:27 +0200 Subject: Handle upload of files to hefur and a web server --- README.md | 16 ++++++++++------ al32-mktorrent.sh | 31 +++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7332da6..c1a7cbc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # al32-mktorrent -Torrent creation script for [ArchLinux32](https://archlinux32.org) +Torrent creation script for [ArchLinux32](https://archlinux32.org), with upload +capabilities via `scp` and to [hefur](https://github.com/abique/hefur). The latest torrents are hosted on [static.dopsi.ch](https://static.dopsi.ch/al32/) along with the RSS feeds (for [i686](https://static.dopsi.ch/al32/feed_i686.rss) and @@ -8,10 +9,12 @@ along with the RSS feeds (for [i686](https://static.dopsi.ch/al32/feed_i686.rss) ## Usage - al32-mktorrent.sh [ -d date ] [ arch... ] + al32-mktorrent.sh [ -d date ] [ -w webdir ] [ -t hefurdir ] [ arch... ] -If no arch is specified both `i686` and `dual` will be generated. -If no date is specified, the script will prompt for a date during the process. +If no `arch` is specified both `i686` and `dual` will be generated. +If no `date` is specified, the script will prompt for a date during the process. +If `hefurdir` or `webdir` is not specified no file will be uploaded to +the corresponding server. ## Features @@ -24,11 +27,12 @@ If no date is specified, the script will prompt for a date during the process. * [x] Create both torrent files at once * [x] Create a magnet link per architecture * [ ] Torrent upload - * [ ] Upload the torrent file to a server via SSH (for sharing) + * [x] Upload the torrent file to a web server via SSH + * [x] Upload the torrent file to a torrent tracker via SSH * [ ] Upload the torrent to transmission-server * [ ] Inform the world of the new torrent file * [x] Add the magnet link to a RSS feed - * [ ] Upload the new RSS feed to the server + * [x] Upload the new RSS feed to the server * [ ] Send an email to the arch-ports list ## License diff --git a/al32-mktorrent.sh b/al32-mktorrent.sh index 3190f0c..26f068d 100644 --- a/al32-mktorrent.sh +++ b/al32-mktorrent.sh @@ -17,7 +17,7 @@ set -euo pipefail function join_by { local IFS="$1"; shift; echo "$*"; } usage () { - echo "Usage: $0 [-d date] [arch...]" + echo "Usage: $0 [-d date] [-w webdir] [-t hefurdir] [arch...]" } fg_green="\033[32m" @@ -95,6 +95,13 @@ function create_torrent_for_arch () { python magnet2feed.py "$magnet_link" "$iso_date" } +function upload_file_to_remote_dir { + if [ -f "$1" ] && [ -n "$2" ] ; then + echo -e "$fg_reset${fg_bold}Uploading file$fg_reset "${fg_blue}$1$fg_reset" ${fg_bold}to$fg_reset "${fg_blue}$1$fg_reset" $fg_bold...$fg_reset" + scp "$1" "$2" + fi +} + ### Check for if required programs are present which mktorrent 2>/dev/null || ( @@ -111,12 +118,20 @@ python -c "import feedgenerator" 2>/dev/null || ( declare -a architectures=("i686" "dual") iso_date='' +web_dir='' +hefur_dir='' -while getopts "d:h" o; do +while getopts "d:w:t:h" o; do case "${o}" in d) iso_date=${OPTARG} ;; + t) + hefur_dir=${OPTARG} + ;; + w) + web_dir=${OPTARG} + ;; h) usage exit @@ -141,4 +156,16 @@ for a in "${architectures[@]}" ; do create_torrent_for_arch "$a" done +for a in "${architectures[@]}" ; do + torrent_filename="archlinux-$iso_date-$arch.iso.torrent" + if [ -n "$web_dir" ] ; then + feed_filename="feed_$arch.rss" + upload_file_to_remote_dir "$torrent_filename" "$web_dir" + upload_file_to_remote_dir "$feed_filename" "$web_dir" + fi + if [ -n "$hefur_dir" ] ; then + upload_file_to_remote_dir "$torrent_filename" "$hefur_dir" + fi +done + # vim: set ts=4 sw=4: -- cgit v1.2.3-54-g00ecf