Skip to content

Commit 25c7c48

Browse files
authored
chore: fix rsync-extras script options + add quiet mode
1 parent d825a59 commit 25c7c48

1 file changed

Lines changed: 28 additions & 79 deletions

File tree

docker/scripts/app-rsync-extras.sh

Lines changed: 28 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,65 @@
11
#!/bin/bash
22

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
118
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
4512
4613
EOF
4714
}
4815

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+
;;
7531
esac
76-
shift
7732
done
7833

79-
# The program itself
80-
if [ $# -lt 1 ]; then
81-
DEST_ROOT=/assets
82-
else
83-
DEST_ROOT="${1%/}"
84-
fi
8534
echo "Using destination $DEST_ROOT"
8635

8736
for dir in bofreq; do
8837
dest="$DEST_ROOT/ietf-ftp/$dir"
8938
mkdir -p "$dest"
9039
echo "Fetching $dest ..."
91-
rsync -auz --info=progress2 rsync.ietf.org::$dir/ $dest/
40+
rsync -auz ${PROGRESS:+--info=progress2} rsync.ietf.org::$dir/ $dest/
9241
done
9342

9443
for dir in charter conflict-reviews internet-drafts review rfc slides status-changes yang; do
9544
dest="$DEST_ROOT/ietf-ftp/$dir"
9645
mkdir -p "$dest"
9746
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/
9948
done
10049

10150
for dir in floor photo; do
10251
dest="$DEST_ROOT/media/$dir"
10352
mkdir -p "$dest"
10453
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/
10655
done
10756

10857
dest="$DEST_ROOT/archive/id"
10958
mkdir -p "$dest"
11059
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/
11261

11362
dest="$DEST_ROOT/www6s/proceedings"
11463
mkdir -p "$dest"
11564
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

Comments
 (0)