Utility script to populate a dev instance with drafts, rfcs, slides, etc.
- Legacy-Id: 17862
This commit is contained in:
parent
0240c5c0e6
commit
8d5d61c13c
127
docker/rsync-extras
Executable file
127
docker/rsync-extras
Executable file
|
@ -0,0 +1,127 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
version=0.10
|
||||||
|
program=${0##*/}
|
||||||
|
progdir=${0%/*}
|
||||||
|
if [ "$progdir" = "$program" ]; then progdir="."; fi
|
||||||
|
if [ "$progdir" = "." ]; then progdir="$PWD"; fi
|
||||||
|
parent=$(dirname $progdir)
|
||||||
|
if [ "$parent" = "." ]; then parent="$PWD"; fi
|
||||||
|
|
||||||
|
export LANG=C
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
function usage() {
|
||||||
|
cat <<EOF
|
||||||
|
NAME
|
||||||
|
$program - Copy additional data files from the ietf server
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
$program [OPTIONS]
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
|
||||||
|
This script copies additional data files used by the datatracker
|
||||||
|
from the ietf server to a local directory, for instance drafts,
|
||||||
|
charters, rfcs, agendas, minutes, etc.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
echo -e "OPTIONS"
|
||||||
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
|
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/'
|
||||||
|
else
|
||||||
|
egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /'
|
||||||
|
fi
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
FILES
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
Written by Henrik Levkowetz, <henrik@levkowetz.com>
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
|
||||||
|
Copyright (c) 2016 IETF Trust and the persons identified as authors of
|
||||||
|
the code. All rights reserved. License 'Simplified BSD', as specified
|
||||||
|
in http://opensource.org/licenses/BSD-3-Clause.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
function die() {
|
||||||
|
echo -e "\n$program: error: $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function note() {
|
||||||
|
if [ -n "$VERBOSE" ]; then echo -e "$*"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
function version() {
|
||||||
|
echo -e "$program $version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# Option parsing
|
||||||
|
|
||||||
|
# Options
|
||||||
|
shortopts=hvV
|
||||||
|
longopts=help,verbose,version
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
|
||||||
|
if [ "$(uname)" = "Linux" ]; then
|
||||||
|
args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@")
|
||||||
|
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
|
||||||
|
eval set -- "$args"
|
||||||
|
sed="sed -r"
|
||||||
|
else
|
||||||
|
# Darwin, BSDs
|
||||||
|
args=$(getopt -o$shortopts $SV $*)
|
||||||
|
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
|
||||||
|
set -- $args
|
||||||
|
sed="sed -E"
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true ; do
|
||||||
|
case "$1" in
|
||||||
|
-h| --help) usage; exit;; # Show this help, then exit
|
||||||
|
-v| --verbose) VERBOSE=1;; # Be more talkative
|
||||||
|
-V| --version) version; exit;; # Show program version, then exit
|
||||||
|
--) shift; break;;
|
||||||
|
*) die "Internal error, inconsistent option specification: '$1'";;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# The program itself
|
||||||
|
|
||||||
|
[ $# -lt 1 ] && die "Missing argument: rsync destination"
|
||||||
|
|
||||||
|
DEST_ROOT="${1%/}"
|
||||||
|
for dir in charter conflict-reviews internet-drafts review rfc slides status-changes yang; do
|
||||||
|
dest="$DEST_ROOT/ietf-ftp/$dir"
|
||||||
|
echo "Fetching $dest ..."
|
||||||
|
rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::everything-ftp/$dir/ $dest/
|
||||||
|
done
|
||||||
|
|
||||||
|
for dir in floor photo; do
|
||||||
|
dest="$DEST_ROOT/media/$dir"
|
||||||
|
echo "Fetching $dest ..."
|
||||||
|
rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::dev.media/$dir/ $dest/
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
dest="$DEST_ROOT/archive/id"
|
||||||
|
echo "Fetching $dest ..."
|
||||||
|
rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::id-archive/ $dest/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue