|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -version=0.12 |
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 | | -if [[ $(uname) =~ CYGWIN.* ]]; then parent=$(echo "$parent" | sed -e 's/^\/cygdrive\/\(.\)/\1:/'); fi |
| 3 | +# Usage info |
| 4 | +show_help() { |
| 5 | + cat << EOF |
| 6 | +Usage: ${0##*/} [-h] [-p PATH] [-q] |
| 7 | +Fetch all assets using rsync |
11 | 8 |
|
12 | | - |
13 | | -function usage() { |
14 | | - cat <<EOF |
15 | | -NAME |
16 | | - $program - Copy additional data files from the ietf server |
17 | | -
|
18 | | -SYNOPSIS |
19 | | - $program [OPTIONS] [DESTINATION] |
20 | | -
|
21 | | -DESCRIPTION |
22 | | - This script copies additional data files used by the datatracker |
23 | | - from the ietf server to a local directory, for instance drafts, |
24 | | - charters, rfcs, agendas, minutes, etc. |
25 | | -
|
26 | | - If no destination is given, the default is /assets. |
27 | | -
|
28 | | -OPTIONS |
29 | | -EOF |
30 | | - grep -E '^\s+-[a-zA-Z])' "$0" | sed -E -e 's/\)[^#]+#/ /' |
31 | | - cat <<EOF |
32 | | -
|
33 | | -AUTHOR |
34 | | - Written by: |
35 | | - Henrik Levkowetz, <henrik@levkowetz.com> |
36 | | - Lars Eggert, <lars@eggert.org> |
37 | | -
|
38 | | -COPYRIGHT |
39 | | - Copyright (c) 2016 IETF Trust and the persons identified as authors of |
40 | | - the code. All rights reserved. Redistribution and use in source and |
41 | | - binary forms, with or without modification, is permitted pursuant to, |
42 | | - and subject to the license terms contained in, the Revised BSD |
43 | | - License set forth in Section 4.c of the IETF Trust's Legal Provisions |
44 | | - Relating to IETF Documents(https://trustee.ietf.org/license-info). |
| 9 | + -h display this help and exit |
| 10 | + -p PATH set a custom destination path |
| 11 | + -q quiet mode, don't show progress stats |
45 | 12 |
|
46 | 13 | EOF |
47 | 14 | } |
48 | 15 |
|
49 | | - |
50 | | -function die() { |
51 | | - echo -e "\n$program: error: $*" >&2 |
52 | | - exit 1 |
53 | | -} |
54 | | - |
55 | | - |
56 | | -function version() { |
57 | | - echo -e "$program $version" |
58 | | -} |
59 | | - |
60 | | -trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR |
61 | | - |
62 | | - |
63 | | -# Option parsing |
64 | | -shortopts=hv |
65 | | -args=$(getopt -o$shortopts $*) |
66 | | -if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi |
67 | | -set -- $args |
68 | | - |
69 | | -while true ; do |
70 | | - case "$1" in |
71 | | - -h) usage; exit;; # Show this help, then exit |
72 | | - -v) version; exit;; # Show program version, then exit |
73 | | - --) shift; break;; |
74 | | - *) die "Internal error, inconsistent option specification: '$1'";; |
| 16 | +DEST_ROOT=/assets |
| 17 | +PROGRESS=1 |
| 18 | + |
| 19 | +while getopts "hp:q" opt; do |
| 20 | + case $opt in |
| 21 | + h) |
| 22 | + show_help |
| 23 | + exit 0 |
| 24 | + ;; |
| 25 | + p) |
| 26 | + DEST_ROOT=$OPTARG |
| 27 | + ;; |
| 28 | + q) |
| 29 | + unset PROGRESS |
| 30 | + ;; |
75 | 31 | esac |
76 | | - shift |
77 | 32 | done |
78 | 33 |
|
79 | | -# The program itself |
80 | | -if [ $# -lt 1 ]; then |
81 | | - DEST_ROOT=/assets |
82 | | -else |
83 | | - DEST_ROOT="${1%/}" |
84 | | -fi |
85 | 34 | echo "Using destination $DEST_ROOT" |
86 | 35 |
|
87 | 36 | for dir in bofreq; do |
88 | 37 | dest="$DEST_ROOT/ietf-ftp/$dir" |
89 | 38 | mkdir -p "$dest" |
90 | 39 | echo "Fetching $dest ..." |
91 | | - rsync -auz --info=progress2 rsync.ietf.org::$dir/ $dest/ |
| 40 | + rsync -auz ${PROGRESS:+--info=progress2} rsync.ietf.org::$dir/ $dest/ |
92 | 41 | done |
93 | 42 |
|
94 | 43 | for dir in charter conflict-reviews internet-drafts review rfc slides status-changes yang; do |
95 | 44 | dest="$DEST_ROOT/ietf-ftp/$dir" |
96 | 45 | mkdir -p "$dest" |
97 | 46 | echo "Fetching $dest ..." |
98 | | - rsync -auz --info=progress2 rsync.ietf.org::everything-ftp/$dir/ $dest/ |
| 47 | + rsync -auz ${PROGRESS:+--info=progress2} rsync.ietf.org::everything-ftp/$dir/ $dest/ |
99 | 48 | done |
100 | 49 |
|
101 | 50 | for dir in floor photo; do |
102 | 51 | dest="$DEST_ROOT/media/$dir" |
103 | 52 | mkdir -p "$dest" |
104 | 53 | echo "Fetching $dest ..." |
105 | | - rsync -auz --info=progress2 rsync.ietf.org::dev.media/$dir/ $dest/ |
| 54 | + rsync -auz ${PROGRESS:+--info=progress2} rsync.ietf.org::dev.media/$dir/ $dest/ |
106 | 55 | done |
107 | 56 |
|
108 | 57 | dest="$DEST_ROOT/archive/id" |
109 | 58 | mkdir -p "$dest" |
110 | 59 | echo "Fetching $dest ..." |
111 | | -rsync -auz --info=progress2 rsync.ietf.org::id-archive/ $dest/ |
| 60 | +rsync -auz ${PROGRESS:+--info=progress2} rsync.ietf.org::id-archive/ $dest/ |
112 | 61 |
|
113 | 62 | dest="$DEST_ROOT/www6s/proceedings" |
114 | 63 | mkdir -p "$dest" |
115 | 64 | echo "Fetching $dest ..." |
116 | | -rsync -auz --info=progress2 rsync.ietf.org::proceedings/ $dest/ |
| 65 | +rsync -auz ${PROGRESS:+--info=progress2} rsync.ietf.org::proceedings/ $dest/ |
0 commit comments