From 6a7214ed114a3c68b8c0f75aab3c2ab41e35f8ed Mon Sep 17 00:00:00 2001 From: Simon Doppler Date: Sun, 6 Aug 2017 15:50:39 +0200 Subject: Use the options for the date --- al32-mktorrent.sh | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/al32-mktorrent.sh b/al32-mktorrent.sh index 005ac13..34607b7 100644 --- a/al32-mktorrent.sh +++ b/al32-mktorrent.sh @@ -4,21 +4,9 @@ set -euo pipefail function join_by { local IFS="$1"; shift; echo "$*"; } usage () { - echo "Usage: $0 [i686|dual]" + echo "Usage: $0 [-d date] [i686|dual]" } -if [ "$#" -eq 0 ] ; then - echo "No architecture specified, selecting 'i686'" - arch="i686" -elif [ "$#" -eq 1 ] ; then - echo "Selecting architecture '$1'" - arch="$1" -else - usage - echo "Too many arguments, exiting" >&2 - exit 1 -fi - fg_green="\033[32m" fg_red="\033[31m" fg_blue="\033[34m" @@ -30,8 +18,33 @@ MIRRORLIST_FILE="https://raw.githubusercontent.com/archlinux32/packages/master/c mirrorlist="$(curl "$MIRRORLIST_FILE" 2>/dev/null | grep Server | cut -d '=' -f 2 | sed -e 's/\s//g;s_$arch/$repo_archisos/_')" declare -a available_mirrors +iso_date='' + +while getopts "u:p:t:f:d:" o; do + case "${o}" in + d) + iso_date=${OPTARG} + ;; + *) + usage + ;; + esac +done +shift $((OPTIND-1)) -read -r -p "Date of the ISO: " iso_date +[ -z "$iso_date" ] && read -r -p "Date of the ISO: " iso_date + +if [ "$#" -eq 0 ] ; then + echo "No architecture specified, selecting 'i686'" + arch="i686" +elif [ "$#" -eq 1 ] ; then + echo "Selecting architecture '$1'" + arch="$1" +else + usage + echo "Too many arguments, exiting" >&2 + exit 1 +fi iso_string="archlinux-$iso_date-$arch.iso" -- cgit v1.2.3-70-g09d2