Rip out more unused stuff, and update copyright based on TLP

- Legacy-Id: 19418
This commit is contained in:
Lars Eggert 2021-10-13 13:09:32 +00:00
parent 6fb64998ce
commit c4ba1ea75f
6 changed files with 153 additions and 273 deletions

View file

@ -18,7 +18,7 @@
4. **TEMPORARY:** Until Lars' changes have been merged and a docker image is 4. **TEMPORARY:** Until Lars' changes have been merged and a docker image is
available for download, you will need to build it locally: available for download, you will need to build it locally:
docker/build -l docker/build
This will take a while, but only needs to be done once. This will take a while, but only needs to be done once.

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
version=0.11 version=0.20
program=${0##*/} program=${0##*/}
progdir=${0%/*} progdir=${0%/*}
if [ "$progdir" = "$program" ]; then progdir="."; fi if [ "$progdir" = "$program" ]; then progdir="."; fi
@ -8,104 +8,80 @@ if [ "$progdir" = "." ]; then progdir="$PWD"; fi
parent=$(dirname "$progdir") parent=$(dirname "$progdir")
if [ "$parent" = "." ]; then parent="$PWD"; fi if [ "$parent" = "." ]; then parent="$PWD"; fi
export LANG=C
# ----------------------------------------------------------------------
function usage() { function usage() {
cat <<EOF cat <<EOF
NAME NAME
$program - Build a docker datatracker image. $program - Build a datatracker docker image
SYNOPSIS SYNOPSIS
$program [OPTIONS] ARGS $program [OPTIONS]
DESCRIPTION DESCRIPTION
This script builds a Ubuntu-based docker image that has been
This script builds a debian-based docker image which has been
set up with the dependencies needed to easily run the IETF set up with the dependencies needed to easily run the IETF
datatracker in development mode. It uses docker/Dockerfile; datatracker in development mode. It uses docker/Dockerfile;
i.e., the Dockerfile in the same directory as this script. i.e., the Dockerfile in the same directory as this script.
It assumes that the user has upload rights for the docker
ietf/datatracker-environment repository, in order to push the
image.
OPTIONS
EOF EOF
echo -e "OPTIONS" sed -n -E "s|(^\s+-[A-Za-z])\).*#(.*)|\1 \2|p" "$0"
if [ "$(uname)" = "Linux" ] || [ "$(uname)" = "Darwin" ]; then
grep -E "^[ ]+[-][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
grep -E "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" "$0" | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /'
fi
cat <<EOF cat <<EOF
FILES
AUTHOR AUTHOR
Written by Henrik Levkowetz, <henrik@levkowetz.com> Written by:
Henrik Levkowetz, <henrik@levkowetz.com>
Lars Eggert, <lars@eggert.org>
COPYRIGHT COPYRIGHT
Copyright (c) 2016 IETF Trust and the persons identified as authors of Copyright (c) 2016 IETF Trust and the persons identified as authors of
the code. All rights reserved. License 'Simplified BSD', as specified the code. All rights reserved. Redistribution and use in source and
in http://opensource.org/licenses/BSD-3-Clause. binary forms, with or without modification, is permitted pursuant to,
and subject to the license terms contained in, the Revised BSD
License set forth in Section 4.c of the IETF Trusts Legal Provisions
Relating to IETF Documents(https://trustee.ietf.org/license-info).
EOF EOF
} }
# ----------------------------------------------------------------------
function die() { function die() {
echo -e "\n$program: error: $*" >&2 echo -e "\n$program: error: $*" >&2
exit 1 exit 1
} }
# ----------------------------------------------------------------------
function version() { function version() {
echo -e "$program $version" echo -e "$program $version"
} }
# ----------------------------------------------------------------------
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
# ----------------------------------------------------------------------
# Option parsing
# Options
shortopts=hlt:vV
longopts=help,local,tag=,version
# Default values # Default values
IMAGE=ietf/datatracker-environment IMAGE=ietf/datatracker-environment
TAG=$(basename "$(svn info "$parent" | grep ^URL | awk '{print $2}')") TAG=$(basename "$(svn info "$parent" | grep ^URL | awk '{print $2}')")
LOCAL="" LOCAL=1
if [ "$(uname)" = "Linux" ]; then # Option parsing
args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@") shortopts=hut:V
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi args=$(getopt -o$shortopts $*)
eval set -- "$args" if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
else set -- $args
# Darwin, BSDs
args=$(getopt -o$shortopts $SV $*)
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
set -- $args
fi
while true ; do while true ; do
case "$1" in case "$1" in
-h| --help) usage; exit;; # Show this help, then exit -h) usage; exit;; # Show this help, then exit
-l| --local) LOCAL=1;; # Don't upload -u) LOCAL=0;; # Upload image to repository after build
-t| --tag) TAG=$2; shift;; # Use this docker image tag, instead of the latest svn tags name -t) TAG=$2; shift;; # Use this docker image tag
-V| --version) version; exit;; # Show program version, then exit -V) version; exit;; # Show program version, then exit
--) shift; break;; --) shift; break;;
*) die "Internal error, inconsistent option specification: '$1'";; *) die "Internal error, inconsistent option specification: '$1'";;
esac esac
shift shift
done done
# ----------------------------------------------------------------------
# The program itself # The program itself
docker rmi -f $IMAGE:trunk 2>/dev/null || true docker rmi -f $IMAGE:trunk 2>/dev/null || true
docker build --progress plain -t "$IMAGE:$TAG" docker/ docker build --progress plain -t "$IMAGE:$TAG" docker/
docker tag "$(docker images -q $IMAGE | head -n 1)" $IMAGE:latest docker tag "$(docker images -q $IMAGE | head -n 1)" $IMAGE:latest

View file

@ -1,118 +1,88 @@
#!/bin/bash #!/bin/bash
version=0.10 version=0.11
program=${0##*/} program=${0##*/}
progdir=${0%/*} progdir=${0%/*}
if [ "$progdir" = "$program" ]; then progdir="."; fi if [ "$progdir" = "$program" ]; then progdir="."; fi
if [ "$progdir" = "." ]; then progdir="$PWD"; fi if [ "$progdir" = "." ]; then progdir="$PWD"; fi
parent=$(dirname $progdir) parent=$(dirname "$progdir")
if [ "$parent" = "." ]; then parent="$PWD"; fi if [ "$parent" = "." ]; then parent="$PWD"; fi
export LANG=C
# ----------------------------------------------------------------------
function usage() { function usage() {
cat <<EOF cat <<EOF
NAME NAME
$program - Make a tarball of the MySQL database files and upload it. $program - Make a tarball of the MySQL database files and upload it
SYNOPSIS SYNOPSIS
$program [OPTIONS] $program [OPTIONS]
DESCRIPTION DESCRIPTION
This script creates a compressed tarball from the MySQL database files This script creates a compressed tarball from the MySQL database files
on disk, and uploads it to the ietf datatracker developer area on on disk, and uploads it to the ietf datatracker developer area on
www.ietf.org. www.ietf.org.
It is intended to be used with the docker datatracker environment, after It is intended to be used with the docker datatracker environment, after
you have set up the database with docker/setupdb, started the docker you have set up the database with docker/setupdb, started the docker
image with docker/run, and updated the database with docker/updatedb. image with docker/run, and updated the database with docker/updatedb.
To use it, exit from the docker container, to make sure that mysqldb To use it, exit from the docker container, to make sure that mysqldb
isn't running and all the files consistent and available for copy. Then isn't running and all the files consistent and available for copy. Then
run docker/$program outside the docker container. You need to have ssh run docker/$program outside the docker container. You need to have ssh
access to www.ietf.org in order for the scp command to succeed. access to www.ietf.org in order for the scp command to succeed.
OPTIONS
EOF EOF
echo -e "OPTIONS" sed -n -E "s|(^\s+-[A-Za-z])\).*#(.*)|\1 \2|p" "$0"
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 cat <<EOF
FILES
AUTHOR AUTHOR
Written by Henrik Levkowetz, <henrik@levkowetz.com> Written by:
Henrik Levkowetz, <henrik@levkowetz.com>
Lars Eggert, <lars@eggert.org>
COPYRIGHT COPYRIGHT
Copyright (c) 2016 IETF Trust and the persons identified as authors of Copyright (c) 2016 IETF Trust and the persons identified as authors of
the code. All rights reserved. License 'Simplified BSD', as specified the code. All rights reserved. Redistribution and use in source and
in http://opensource.org/licenses/BSD-3-Clause. binary forms, with or without modification, is permitted pursuant to,
and subject to the license terms contained in, the Revised BSD
EOF License set forth in Section 4.c of the IETF Trusts Legal Provisions
Relating to IETF Documents(https://trustee.ietf.org/license-info).
EOF
} }
# ----------------------------------------------------------------------
function die() { function die() {
echo -e "\n$program: error: $*" >&2 echo -e "\n$program: error: $*" >&2
exit 1 exit 1
} }
function note() {
if [ -n "$VERBOSE" ]; then echo -e "$*"; fi
}
# ----------------------------------------------------------------------
function version() { function version() {
echo -e "$program $version" echo -e "$program $version"
} }
# ----------------------------------------------------------------------
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
# ----------------------------------------------------------------------
# Option parsing # Option parsing
shortopts=hV
# Options args=$(getopt -o$shortopts $SV $*)
shortopts=hvV if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
longopts=help,verbose,version set -- $args
# 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 while true ; do
case "$1" in case "$1" in
-h| --help) usage; exit;; # Show this help, then exit -h) usage; exit;; # Show this help, then exit
-v| --verbose) VERBOSE=1;; # Be more talkative -V) version; exit;; # Show program version, then exit
-V| --version) version; exit;; # Show program version, then exit --) shift; break;;
--) shift; break;; *) die "Internal error, inconsistent option specification: '$1'";;
*) die "Internal error, inconsistent option specification: '$1'";;
esac esac
shift shift
done done
# ----------------------------------------------------------------------
# The program itself # The program itself
if [ -e "/.dockerenv" -o -n "$(grep -s '/docker/' /proc/self/cgroup)" ]; then if [ -e "/.dockerenv" -o -n "$(grep -s '/docker/' /proc/self/cgroup)" ]; then
die "It looks as if you're running inside docker -- please quit docker first." die "It looks as if you're running inside docker -- please quit docker first."
fi fi
@ -123,4 +93,4 @@ cd $workdir
echo "Building tarfile ..." echo "Building tarfile ..."
tar cjf ietf_utf8.bin.tar.bz2 mysql tar cjf ietf_utf8.bin.tar.bz2 mysql
echo "Copying tarfile to ietfa.amsl.com ..." echo "Copying tarfile to ietfa.amsl.com ..."
scp ietf_utf8.bin.tar.bz2 ietfa.amsl.com:/a/www/www6s/lib/dt/sprint/ scp ietf_utf8.bin.tar.bz2 ietfa.amsl.com:/a/www/www6s/lib/dt/sprint/

View file

@ -1,127 +1,104 @@
#!/bin/bash #!/bin/bash
version=0.10 version=0.11
program=${0##*/} program=${0##*/}
progdir=${0%/*} progdir=${0%/*}
if [ "$progdir" = "$program" ]; then progdir="."; fi if [ "$progdir" = "$program" ]; then progdir="."; fi
if [ "$progdir" = "." ]; then progdir="$PWD"; fi if [ "$progdir" = "." ]; then progdir="$PWD"; fi
parent=$(dirname $progdir) parent=$(dirname "$progdir")
if [ "$parent" = "." ]; then parent="$PWD"; fi if [ "$parent" = "." ]; then parent="$PWD"; fi
export LANG=C
# ----------------------------------------------------------------------
function usage() { function usage() {
cat <<EOF cat <<EOF
NAME NAME
$program - Copy additional data files from the ietf server $program - Copy additional data files from the ietf server
SYNOPSIS SYNOPSIS
$program [OPTIONS] $program [OPTIONS] [DESTINATION]
DESCRIPTION DESCRIPTION
This script copies additional data files used by the datatracker This script copies additional data files used by the datatracker
from the ietf server to a local directory, for instance drafts, from the ietf server to a local directory, for instance drafts,
charters, rfcs, agendas, minutes, etc. charters, rfcs, agendas, minutes, etc.
If no destination is given, the default is data/developers.
OPTIONS
EOF EOF
echo -e "OPTIONS" sed -n -E "s|(^\s+-[A-Za-z])\).*#(.*)|\1 \2|p" "$0"
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 cat <<EOF
FILES
AUTHOR AUTHOR
Written by Henrik Levkowetz, <henrik@levkowetz.com> Written by:
Henrik Levkowetz, <henrik@levkowetz.com>
Lars Eggert, <lars@eggert.org>
COPYRIGHT COPYRIGHT
Copyright (c) 2016 IETF Trust and the persons identified as authors of Copyright (c) 2016 IETF Trust and the persons identified as authors of
the code. All rights reserved. License 'Simplified BSD', as specified the code. All rights reserved. Redistribution and use in source and
in http://opensource.org/licenses/BSD-3-Clause. binary forms, with or without modification, is permitted pursuant to,
and subject to the license terms contained in, the Revised BSD
EOF License set forth in Section 4.c of the IETF Trusts Legal Provisions
Relating to IETF Documents(https://trustee.ietf.org/license-info).
EOF
} }
# ----------------------------------------------------------------------
function die() { function die() {
echo -e "\n$program: error: $*" >&2 echo -e "\n$program: error: $*" >&2
exit 1 exit 1
} }
function note() {
if [ -n "$VERBOSE" ]; then echo -e "$*"; fi
}
# ----------------------------------------------------------------------
function version() { function version() {
echo -e "$program $version" echo -e "$program $version"
} }
# ----------------------------------------------------------------------
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
# ----------------------------------------------------------------------
# Option parsing # Option parsing
# Options
shortopts=hvV shortopts=hvV
longopts=help,verbose,version args=$(getopt -o$shortopts $SV $*)
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
# Default values set -- $args
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 while true ; do
case "$1" in case "$1" in
-h| --help) usage; exit;; # Show this help, then exit -h) usage; exit;; # Show this help, then exit
-v| --verbose) VERBOSE=1;; # Be more talkative -v) VERBOSE=1;; # Be more talkative
-V| --version) version; exit;; # Show program version, then exit -V) version; exit;; # Show program version, then exit
--) shift; break;; --) shift; break;;
*) die "Internal error, inconsistent option specification: '$1'";; *) die "Internal error, inconsistent option specification: '$1'";;
esac esac
shift shift
done done
# ----------------------------------------------------------------------
# The program itself # The program itself
if [ $# -lt 1 ]; then
DEST_ROOT=data/developers
else
DEST_ROOT="${1%/}"
fi
echo "Using destination $DEST_ROOT"
[ $# -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 for dir in charter conflict-reviews internet-drafts review rfc slides status-changes yang; do
dest="$DEST_ROOT/ietf-ftp/$dir" dest="$DEST_ROOT/ietf-ftp/$dir"
mkdir -p "$dest"
echo "Fetching $dest ..." echo "Fetching $dest ..."
rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::everything-ftp/$dir/ $dest/ rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::everything-ftp/$dir/ $dest/
done done
for dir in floor photo; do for dir in floor photo; do
dest="$DEST_ROOT/media/$dir" dest="$DEST_ROOT/media/$dir"
mkdir -p "$dest"
echo "Fetching $dest ..." echo "Fetching $dest ..."
rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::dev.media/$dir/ $dest/ rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::dev.media/$dir/ $dest/
done done
dest="$DEST_ROOT/archive/id"
dest="$DEST_ROOT/archive/id" mkdir -p "$dest"
echo "Fetching $dest ..." echo "Fetching $dest ..."
rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::id-archive/ $dest/ rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::id-archive/ $dest/

View file

@ -7,9 +7,8 @@ if [ "$progdir" = "$program" ]; then progdir="."; fi
if [ "$progdir" = "." ]; then progdir="$PWD"; fi if [ "$progdir" = "." ]; then progdir="$PWD"; fi
parent=$(dirname "$progdir") parent=$(dirname "$progdir")
if [ "$parent" = "." ]; then parent="$PWD"; fi if [ "$parent" = "." ]; then parent="$PWD"; fi
if [[ $(uname) =~ CYGWIN.* ]]; then parent=$(echo "$parent" | sed -e 's/^\/cygdrive\/\(.\)/\1:/'); fi
# ----------------------------------------------------------------------
function usage() { function usage() {
cat <<EOF cat <<EOF
NAME NAME
@ -19,87 +18,69 @@ SYNOPSIS
$program [OPTIONS] ARGS $program [OPTIONS] ARGS
DESCRIPTION DESCRIPTION
This is a wrapper which runs an Ubuntu-based docker image which
has been set up with the dependencies needed to easily run the
IETF datatracker in development mode.
This is a wrapper which runs docker with suitable arguments on a MySQL database files at data/mysql will be used; if they do not exist,
debian-based docker image which has been set up with the dependencies a database dump will be retrieved and restored on first run.
needed to easily run the IETF datatracker in development mode. By
default, it expects to find the MySQL database files at
$parent/data/mysql, which is mapped inside the
container to /var/lib/mysql, and it will set up a home directory for
the current user ($USER) and map it to $HOME.
OPTIONS
EOF EOF
echo -e "OPTIONS" sed -n -E "s|(^\s+-[A-Za-z])\).*#(.*)|\1 \2|p" "$0"
if [ "$(uname)" = "Linux" ] || [ "$(uname)" = "Darwin" ]; then
grep -E "^[ ]+[-][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
grep -E "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" "$0" | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /'
fi
cat <<EOF cat <<EOF
FILES
AUTHOR AUTHOR
Written by Henrik Levkowetz, <henrik@levkowetz.com> Written by:
Henrik Levkowetz, <henrik@levkowetz.com>
Lars Eggert, <lars@eggert.org>
COPYRIGHT COPYRIGHT
Copyright (c) 2016 IETF Trust and the persons identified as authors of
Copyright (c) 2015 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and
the code. All rights reserved. License 'Simplified BSD', as specified binary forms, with or without modification, is permitted pursuant to,
in http://opensource.org/licenses/BSD-3-Clause. and subject to the license terms contained in, the Revised BSD
License set forth in Section 4.c of the IETF Trusts Legal Provisions
Relating to IETF Documents(https://trustee.ietf.org/license-info).
EOF EOF
} }
# ----------------------------------------------------------------------
function die() { function die() {
echo -e "\n$program: error: $*" >&2 echo -e "\n$program: error: $*" >&2
exit 1 exit 1
} }
# ----------------------------------------------------------------------
function version() { function version() {
echo -e "$program $version" echo -e "$program $version"
} }
# ----------------------------------------------------------------------
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
# ----------------------------------------------------------------------
# Option parsing
# Options
shortopts=hp:vVcC
longopts=help,port=,version,cached,no-cached
# Default values # Default values
MYSQLDIR=$parent/data/mysql MYSQLDIR=$parent/data/mysql
PORT=8000 PORT=8000
REPO="ietf/datatracker-environment" REPO="ietf/datatracker-environment"
CACHED=':cached' CACHED=':cached'
if [ "$(uname)" = "Linux" ]; then # Option parsing
args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@") shortopts=hp:VcC
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$args" args=$(getopt -o$shortopts $SV $*)
else if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
# Darwin, BSDs set -- $args
args=$(getopt -o$shortopts $SV $*)
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
set -- $args
fi
while true ; do while true ; do
case "$1" in case "$1" in
-c| --cached) CACHED=':cached';; # Use cached disk access to reduce system load -c) CACHED=':cached';; # Use cached disk access to reduce system load
-C| --no-cached) CACHED=':consistent';; # Use fully synchronized disk access -C) CACHED=':consistent';; # Use fully synchronized disk access
-h| --help) usage; exit;; # Show this help, then exit -h) usage; exit;; # Show this help, then exit
-p| --port) PORT=$2; shift;; # Bind the container's port 8000 to external port PORT -p) PORT=$2; shift;; # Bind the container's port 8000 to external port PORT
-V| --version) version; exit;; # Show program version, then exit -V) version; exit;; # Show program version, then exit
--) shift; break;; --) shift; break;;
*) die "Internal error, inconsistent option specification: '$1'";; *) die "Internal error, inconsistent option specification: '$1'";;
esac esac
shift shift
done done
@ -108,8 +89,6 @@ if [ -z "$TAG" ]; then
TAG=$(basename "$(svn info "$parent" | grep ^URL | awk '{print $2}')") TAG=$(basename "$(svn info "$parent" | grep ^URL | awk '{print $2}')")
fi fi
# ----------------------------------------------------------------------
echo "Starting a docker container for '$REPO:$TAG'." echo "Starting a docker container for '$REPO:$TAG'."
mkdir -p "$MYSQLDIR" mkdir -p "$MYSQLDIR"
docker run -ti -p "$PORT":8000 -p 33306:3306 \ docker run -ti -p "$PORT":8000 -p 33306:3306 \

View file

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
# -*- indent-with-tabs: 1 -*-
version=0.20 version=0.20
program=${0##*/} program=${0##*/}
@ -9,7 +8,7 @@ if [ "$progdir" = "." ]; then progdir="$PWD"; fi
parent=$(dirname "$progdir") parent=$(dirname "$progdir")
if [ "$parent" = "." ]; then parent="$PWD"; fi if [ "$parent" = "." ]; then parent="$PWD"; fi
# ----------------------------------------------------------------------
function usage() { function usage() {
cat <<EOF cat <<EOF
NAME NAME
@ -19,89 +18,68 @@ SYNOPSIS
$program [OPTIONS] ARGS $program [OPTIONS] ARGS
DESCRIPTION DESCRIPTION
This script downloads a dump of the IETF database and loads into the This script downloads a dump of the IETF database and loads into the
local sql server if it is newer than the current dump. local sql server if it is newer than the current dump.
OPTIONS
EOF EOF
echo -e "OPTIONS" sed -n -E "s|(^\s+-[A-Za-z])\).*#(.*)|\1 \2|p" "$0"
if [ "$(uname)" = "Linux" ]; then
grep -E "^[ ]+[-][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
grep -E "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" "$0" | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /'
fi
cat <<EOF cat <<EOF
FILES
AUTHOR AUTHOR
Written by Henrik Levkowetz, <henrik@levkowetz.com> Written by:
Henrik Levkowetz, <henrik@levkowetz.com>
Lars Eggert, <lars@eggert.org>
COPYRIGHT COPYRIGHT
Copyright (c) 2016 IETF Trust and the persons identified as authors of
Copyright (c) 2015 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and
the code. All rights reserved. License 'Simplified BSD', as specified binary forms, with or without modification, is permitted pursuant to,
in http://opensource.org/licenses/BSD-3-Clause. and subject to the license terms contained in, the Revised BSD
License set forth in Section 4.c of the IETF Trusts Legal Provisions
Relating to IETF Documents(https://trustee.ietf.org/license-info).
EOF EOF
} }
# ----------------------------------------------------------------------
function die() { function die() {
echo -e "\n$program: error: $*" >&2 echo -e "\n$program: error: $*" >&2
exit 1 exit 1
} }
# ----------------------------------------------------------------------
function version() { function version() {
echo -e "$program $version" echo -e "$program $version"
} }
# ----------------------------------------------------------------------
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
# ----------------------------------------------------------------------
# Option parsing # Option parsing
# Options
shortopts=DLZhqvV shortopts=DLZhqvV
longopts=no-download,no-load,no-zap,help,version
LOAD=1 LOAD=1
DOWNLOAD=1 DOWNLOAD=1
DROP=1 DROP=1
if [ "$(uname)" = "Linux" ]; then args=$(getopt -o$shortopts $SV $*)
args=$(getopt -o "$shortopts" --long "$longopts" -n "$program" -- $SV "$@") if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi set -- $args
eval set -- "$args"
else
# Darwin, BSDs
args=$(getopt -o$shortopts $SV $*)
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
set -- $args
fi
while true ; do while true ; do
case "$1" in case "$1" in
-D| --no-download) DOWNLOAD="";; #Don't download, use existing file -D) DOWNLOAD="";; # Don't download, use existing file
-L| --no-load) LOAD=""; ;; # Don't load the database -L) LOAD=""; ;; # Don't load the database
-Z| --no-zap) DROP="";; # Don't drop new tables -Z) DROP="";; # Don't drop new tables
-h| --help) usage; exit;; # Show this help, then exit -h) usage; exit;; # Show this help, then exit
-V| --version) version; exit;; # Show program version, then exit -V) version; exit;; # Show program version, then exit
--) shift; break;; --) shift; break;;
*) die "Internal error, inconsistent option specification: '$1'";; *) die "Internal error, inconsistent option specification: '$1'";;
esac esac
shift shift
done done
# ----------------------------------------------------------------------
# The program itself # The program itself
DATADIR=$parent/data DATADIR=$parent/data
DUMP=ietf_utf8.sql.gz DUMP=ietf_utf8.sql.gz
if [ "$DOWNLOAD" ]; then if [ "$DOWNLOAD" ]; then
echo "Fetching database dump..." echo "Fetching database dump..."