|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +version=0.10 |
| 4 | +program=${0##*/} |
| 5 | +progdir=${0%/*} |
| 6 | +if [ "$progdir" = "$program" ]; then progdir="."; fi |
| 7 | +if [ "$progdir" = "." ]; then progdir="$PWD"; fi |
| 8 | +parent=$(dirname $progdir) |
| 9 | +if [ "$parent" = "." ]; then parent="$PWD"; fi |
| 10 | + |
| 11 | +export LANG=C |
| 12 | + |
| 13 | +# ---------------------------------------------------------------------- |
| 14 | +function usage() { |
| 15 | + cat <<EOF |
| 16 | +NAME |
| 17 | + $program - Copy additional data files from the ietf server |
| 18 | +
|
| 19 | +SYNOPSIS |
| 20 | + $program [OPTIONS] |
| 21 | +
|
| 22 | +DESCRIPTION |
| 23 | +
|
| 24 | + This script copies additional data files used by the datatracker |
| 25 | + from the ietf server to a local directory, for instance drafts, |
| 26 | + charters, rfcs, agendas, minutes, etc. |
| 27 | +
|
| 28 | +EOF |
| 29 | + echo -e "OPTIONS" |
| 30 | + if [ "$(uname)" = "Linux" ]; then |
| 31 | + egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | tr -s "\t|" "\t," | sed -r -e 's/\)[ \t]+([A-Z]+)=\$2[^#]*#/=\1\t/' -e 's/\)[^#]*#/\t/' |
| 32 | + else |
| 33 | + egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /' |
| 34 | + fi |
| 35 | + cat <<EOF |
| 36 | +
|
| 37 | +FILES |
| 38 | +
|
| 39 | +AUTHOR |
| 40 | + Written by Henrik Levkowetz, <henrik@levkowetz.com> |
| 41 | +
|
| 42 | +COPYRIGHT |
| 43 | +
|
| 44 | + Copyright (c) 2016 IETF Trust and the persons identified as authors of |
| 45 | + the code. All rights reserved. License 'Simplified BSD', as specified |
| 46 | + in http://opensource.org/licenses/BSD-3-Clause. |
| 47 | + |
| 48 | +EOF |
| 49 | + |
| 50 | +} |
| 51 | + |
| 52 | +# ---------------------------------------------------------------------- |
| 53 | +function die() { |
| 54 | + echo -e "\n$program: error: $*" >&2 |
| 55 | + exit 1 |
| 56 | +} |
| 57 | + |
| 58 | +function note() { |
| 59 | + if [ -n "$VERBOSE" ]; then echo -e "$*"; fi |
| 60 | +} |
| 61 | + |
| 62 | +# ---------------------------------------------------------------------- |
| 63 | +function version() { |
| 64 | + echo -e "$program $version" |
| 65 | +} |
| 66 | + |
| 67 | +# ---------------------------------------------------------------------- |
| 68 | +trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR |
| 69 | + |
| 70 | + |
| 71 | +# ---------------------------------------------------------------------- |
| 72 | +# Option parsing |
| 73 | + |
| 74 | +# Options |
| 75 | +shortopts=hvV |
| 76 | +longopts=help,verbose,version |
| 77 | + |
| 78 | +# Default values |
| 79 | + |
| 80 | +if [ "$(uname)" = "Linux" ]; then |
| 81 | + args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@") |
| 82 | + if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi |
| 83 | + eval set -- "$args" |
| 84 | + sed="sed -r" |
| 85 | +else |
| 86 | + # Darwin, BSDs |
| 87 | + args=$(getopt -o$shortopts $SV $*) |
| 88 | + if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi |
| 89 | + set -- $args |
| 90 | + sed="sed -E" |
| 91 | +fi |
| 92 | + |
| 93 | +while true ; do |
| 94 | + case "$1" in |
| 95 | + -h| --help) usage; exit;; # Show this help, then exit |
| 96 | + -v| --verbose) VERBOSE=1;; # Be more talkative |
| 97 | + -V| --version) version; exit;; # Show program version, then exit |
| 98 | + --) shift; break;; |
| 99 | + *) die "Internal error, inconsistent option specification: '$1'";; |
| 100 | + esac |
| 101 | + shift |
| 102 | +done |
| 103 | + |
| 104 | +# ---------------------------------------------------------------------- |
| 105 | +# The program itself |
| 106 | + |
| 107 | +[ $# -lt 1 ] && die "Missing argument: rsync destination" |
| 108 | + |
| 109 | +DEST_ROOT="${1%/}" |
| 110 | +for dir in charter conflict-reviews internet-drafts review rfc slides status-changes yang; do |
| 111 | + dest="$DEST_ROOT/ietf-ftp/$dir" |
| 112 | + echo "Fetching $dest ..." |
| 113 | + rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::everything-ftp/$dir/ $dest/ |
| 114 | +done |
| 115 | + |
| 116 | +for dir in floor photo; do |
| 117 | + dest="$DEST_ROOT/media/$dir" |
| 118 | + echo "Fetching $dest ..." |
| 119 | + rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::dev.media/$dir/ $dest/ |
| 120 | +done |
| 121 | + |
| 122 | + |
| 123 | + dest="$DEST_ROOT/archive/id" |
| 124 | + echo "Fetching $dest ..." |
| 125 | + rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::id-archive/ $dest/ |
| 126 | + |
| 127 | + |
0 commit comments