From d7595e506b6b22c10be85c7d4ada9a98de0c8dc4 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Fri, 13 Nov 2015 08:06:28 +0000 Subject: [PATCH] A little script to pull down and unpack a copy of the datatracker's mysql database files. - Legacy-Id: 10467 --- docker/setupdb | 108 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100755 docker/setupdb diff --git a/docker/setupdb b/docker/setupdb new file mode 100755 index 000000000..74fdfaec5 --- /dev/null +++ b/docker/setupdb @@ -0,0 +1,108 @@ +#!/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 + +# ---------------------------------------------------------------------- +function usage() { + cat < + +COPYRIGHT + + Copyright (c) 2015 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 + +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 + +[ -n "$MYSQLDIR" ] || MYSQLDIR=$parent/data/mysql +[ -n "$URL"] || URL=https://www.ietf.org/lib/dt/sprint/ietf_utf8.bin.tar.bz2 + +cd $(dirname $MYSQLDIR) +wget -N $URL && tar xjf ietf_utf8.bin.tar.bz2 && chmod -R go+rwX mysql +