diff --git a/docker/README.md b/docker/README.md index e30940efa..19d363058 100644 --- a/docker/README.md +++ b/docker/README.md @@ -18,7 +18,7 @@ 4. **TEMPORARY:** Until Lars' changes have been merged and a docker image is 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. diff --git a/docker/build b/docker/build index 2a9c4df63..29a903b92 100755 --- a/docker/build +++ b/docker/build @@ -1,6 +1,6 @@ #!/bin/bash -version=0.11 +version=0.20 program=${0##*/} progdir=${0%/*} if [ "$progdir" = "$program" ]; then progdir="."; fi @@ -8,104 +8,80 @@ if [ "$progdir" = "." ]; then progdir="$PWD"; fi parent=$(dirname "$progdir") if [ "$parent" = "." ]; then parent="$PWD"; fi -export LANG=C -# ---------------------------------------------------------------------- function usage() { cat < + Written by: + Henrik Levkowetz, + Lars Eggert, 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. + the code. All rights reserved. Redistribution and use in source and + 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 Trust’s Legal Provisions + Relating to IETF Documents(https://trustee.ietf.org/license-info). EOF - } -# ---------------------------------------------------------------------- + function die() { echo -e "\n$program: error: $*" >&2 exit 1 } -# ---------------------------------------------------------------------- + function version() { echo -e "$program $version" } -# ---------------------------------------------------------------------- + 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 IMAGE=ietf/datatracker-environment TAG=$(basename "$(svn info "$parent" | grep ^URL | awk '{print $2}')") -LOCAL="" +LOCAL=1 -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" -else - # Darwin, BSDs - args=$(getopt -o$shortopts $SV $*) - if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi - set -- $args -fi +# Option parsing +shortopts=hut:V +args=$(getopt -o$shortopts $*) +if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi +set -- $args while true ; do case "$1" in - -h| --help) usage; exit;; # Show this help, then exit - -l| --local) LOCAL=1;; # Don't upload - -t| --tag) TAG=$2; shift;; # Use this docker image tag, instead of the latest svn tags name - -V| --version) version; exit;; # Show program version, then exit - --) shift; break;; - *) die "Internal error, inconsistent option specification: '$1'";; + -h) usage; exit;; # Show this help, then exit + -u) LOCAL=0;; # Upload image to repository after build + -t) TAG=$2; shift;; # Use this docker image tag + -V) version; exit;; # Show program version, then exit + --) shift; break;; + *) die "Internal error, inconsistent option specification: '$1'";; esac shift done -# ---------------------------------------------------------------------- # The program itself - docker rmi -f $IMAGE:trunk 2>/dev/null || true docker build --progress plain -t "$IMAGE:$TAG" docker/ docker tag "$(docker images -q $IMAGE | head -n 1)" $IMAGE:latest diff --git a/docker/copydb b/docker/copydb index 672319769..27ac3b395 100755 --- a/docker/copydb +++ b/docker/copydb @@ -1,118 +1,88 @@ #!/bin/bash -version=0.10 +version=0.11 program=${0##*/} progdir=${0%/*} if [ "$progdir" = "$program" ]; then progdir="."; fi if [ "$progdir" = "." ]; then progdir="$PWD"; fi -parent=$(dirname $progdir) +parent=$(dirname "$progdir") if [ "$parent" = "." ]; then parent="$PWD"; fi -export LANG=C -# ---------------------------------------------------------------------- function usage() { cat < + Written by: + Henrik Levkowetz, + Lars Eggert, 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 + the code. All rights reserved. Redistribution and use in source and + 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 Trust’s Legal Provisions + Relating to IETF Documents(https://trustee.ietf.org/license-info). +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 +shortopts=hV +args=$(getopt -o$shortopts $SV $*) +if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi +set -- $args 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'";; + -h) usage; exit;; # Show this help, then exit + -V) version; exit;; # Show program version, then exit + --) shift; break;; + *) die "Internal error, inconsistent option specification: '$1'";; esac shift done -# ---------------------------------------------------------------------- # The program itself - 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." fi @@ -123,4 +93,4 @@ cd $workdir echo "Building tarfile ..." tar cjf ietf_utf8.bin.tar.bz2 mysql 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/ \ No newline at end of file diff --git a/docker/rsync-extras b/docker/rsync-extras index 9353469da..5cc7f9624 100755 --- a/docker/rsync-extras +++ b/docker/rsync-extras @@ -1,127 +1,104 @@ #!/bin/bash -version=0.10 +version=0.11 program=${0##*/} progdir=${0%/*} if [ "$progdir" = "$program" ]; then progdir="."; fi if [ "$progdir" = "." ]; then progdir="$PWD"; fi -parent=$(dirname $progdir) +parent=$(dirname "$progdir") if [ "$parent" = "." ]; then parent="$PWD"; fi -export LANG=C -# ---------------------------------------------------------------------- function usage() { cat < + Written by: + Henrik Levkowetz, + Lars Eggert, 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 + the code. All rights reserved. Redistribution and use in source and + 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 Trust’s Legal Provisions + Relating to IETF Documents(https://trustee.ietf.org/license-info). +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 +args=$(getopt -o$shortopts $SV $*) +if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi +set -- $args 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'";; + -h) usage; exit;; # Show this help, then exit + -v) VERBOSE=1;; # Be more talkative + -V) version; exit;; # Show program version, then exit + --) shift; break;; + *) die "Internal error, inconsistent option specification: '$1'";; esac shift done -# ---------------------------------------------------------------------- # 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 dest="$DEST_ROOT/ietf-ftp/$dir" + mkdir -p "$dest" 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" + mkdir -p "$dest" 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/ - - +dest="$DEST_ROOT/archive/id" +mkdir -p "$dest" +echo "Fetching $dest ..." +rsync -auz ${VERBOSE:+--info=progress2} rsync.ietf.org::id-archive/ $dest/ \ No newline at end of file diff --git a/docker/run b/docker/run index a24993598..87ab5511d 100755 --- a/docker/run +++ b/docker/run @@ -7,9 +7,8 @@ if [ "$progdir" = "$program" ]; then progdir="."; fi if [ "$progdir" = "." ]; then progdir="$PWD"; fi parent=$(dirname "$progdir") if [ "$parent" = "." ]; then parent="$PWD"; fi -if [[ $(uname) =~ CYGWIN.* ]]; then parent=$(echo "$parent" | sed -e 's/^\/cygdrive\/\(.\)/\1:/'); fi -# ---------------------------------------------------------------------- + function usage() { cat < + Written by: + Henrik Levkowetz, + Lars Eggert, 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. - + Copyright (c) 2016 IETF Trust and the persons identified as authors of + the code. All rights reserved. Redistribution and use in source and + 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 Trust’s Legal Provisions + Relating to IETF Documents(https://trustee.ietf.org/license-info). EOF - } -# ---------------------------------------------------------------------- + function die() { echo -e "\n$program: error: $*" >&2 exit 1 } -# ---------------------------------------------------------------------- + function version() { echo -e "$program $version" } -# ---------------------------------------------------------------------- + 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 MYSQLDIR=$parent/data/mysql PORT=8000 REPO="ietf/datatracker-environment" CACHED=':cached' -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" -else - # Darwin, BSDs - args=$(getopt -o$shortopts $SV $*) - if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi - set -- $args -fi +# Option parsing +shortopts=hp:VcC + +args=$(getopt -o$shortopts $SV $*) +if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi +set -- $args while true ; do case "$1" in - -c| --cached) CACHED=':cached';; # Use cached disk access to reduce system load - -C| --no-cached) CACHED=':consistent';; # Use fully synchronized disk access - -h| --help) usage; exit;; # Show this help, then exit - -p| --port) PORT=$2; shift;; # Bind the container's port 8000 to external port PORT - -V| --version) version; exit;; # Show program version, then exit - --) shift; break;; - *) die "Internal error, inconsistent option specification: '$1'";; + -c) CACHED=':cached';; # Use cached disk access to reduce system load + -C) CACHED=':consistent';; # Use fully synchronized disk access + -h) usage; exit;; # Show this help, then exit + -p) PORT=$2; shift;; # Bind the container's port 8000 to external port PORT + -V) version; exit;; # Show program version, then exit + --) shift; break;; + *) die "Internal error, inconsistent option specification: '$1'";; esac shift done @@ -108,8 +89,6 @@ if [ -z "$TAG" ]; then TAG=$(basename "$(svn info "$parent" | grep ^URL | awk '{print $2}')") fi -# ---------------------------------------------------------------------- - echo "Starting a docker container for '$REPO:$TAG'." mkdir -p "$MYSQLDIR" docker run -ti -p "$PORT":8000 -p 33306:3306 \ diff --git a/docker/updatedb b/docker/updatedb index b1fda05b5..2fb9a7ed9 100755 --- a/docker/updatedb +++ b/docker/updatedb @@ -1,5 +1,4 @@ #!/bin/bash -# -*- indent-with-tabs: 1 -*- version=0.20 program=${0##*/} @@ -9,7 +8,7 @@ if [ "$progdir" = "." ]; then progdir="$PWD"; fi parent=$(dirname "$progdir") if [ "$parent" = "." ]; then parent="$PWD"; fi -# ---------------------------------------------------------------------- + function usage() { cat < + Written by: + Henrik Levkowetz, + Lars Eggert, 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. - + Copyright (c) 2016 IETF Trust and the persons identified as authors of + the code. All rights reserved. Redistribution and use in source and + 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 Trust’s Legal Provisions + Relating to IETF Documents(https://trustee.ietf.org/license-info). EOF - } -# ---------------------------------------------------------------------- + function die() { echo -e "\n$program: error: $*" >&2 exit 1 } -# ---------------------------------------------------------------------- + function version() { echo -e "$program $version" } -# ---------------------------------------------------------------------- + trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR - -# ---------------------------------------------------------------------- # Option parsing - -# Options shortopts=DLZhqvV -longopts=no-download,no-load,no-zap,help,version - LOAD=1 DOWNLOAD=1 DROP=1 -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" -else - # Darwin, BSDs - args=$(getopt -o$shortopts $SV $*) - if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi - set -- $args -fi +args=$(getopt -o$shortopts $SV $*) +if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi +set -- $args while true ; do case "$1" in - -D| --no-download) DOWNLOAD="";; #Don't download, use existing file - -L| --no-load) LOAD=""; ;; # Don't load the database - -Z| --no-zap) DROP="";; # Don't drop new tables - -h| --help) usage; exit;; # Show this help, then exit - -V| --version) version; exit;; # Show program version, then exit - --) shift; break;; - *) die "Internal error, inconsistent option specification: '$1'";; + -D) DOWNLOAD="";; # Don't download, use existing file + -L) LOAD=""; ;; # Don't load the database + -Z) DROP="";; # Don't drop new tables + -h) usage; exit;; # Show this help, then exit + -V) version; exit;; # Show program version, then exit + --) shift; break;; + *) die "Internal error, inconsistent option specification: '$1'";; esac shift done -# ---------------------------------------------------------------------- # The program itself - DATADIR=$parent/data - DUMP=ietf_utf8.sql.gz if [ "$DOWNLOAD" ]; then echo "Fetching database dump..."