Additional docker tweaks
- Legacy-Id: 10468
This commit is contained in:
parent
d7595e506b
commit
5ad8db39e9
|
@ -77,6 +77,7 @@ COPY settings_local.py ./
|
|||
COPY setprompt ./
|
||||
|
||||
COPY docker-init.sh /docker-init.sh
|
||||
RUN chmod +x /docker-init.sh
|
||||
ENTRYPOINT ["/docker-init.sh"]
|
||||
|
||||
CMD /bin/bash
|
||||
|
|
0
docker/docker-init.sh
Executable file → Normal file
0
docker/docker-init.sh
Executable file → Normal file
131
docker/updatedb
Executable file
131
docker/updatedb
Executable file
|
@ -0,0 +1,131 @@
|
|||
#!/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 <<EOF
|
||||
NAME
|
||||
$program - Update the local copy of the IETF database from a dump
|
||||
|
||||
SYNOPSIS
|
||||
$program [OPTIONS] ARGS
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This script downloads a dump of the IETF database and loads into the
|
||||
local sql server if it is newer than the current dump.
|
||||
|
||||
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) 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
|
||||
|
||||
echo "Gathering info ..."
|
||||
MYSQLDIR="$(/usr/sbin/mysqld --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
|
||||
MYSQLDIR=${MYSQLDIR%/}
|
||||
DATADIR=$parent/data
|
||||
|
||||
# echo "Checking if MySQL base data exists ..."
|
||||
# if [ ! -d $MYSQLDIR/mysql ]; then
|
||||
# die "Expected the directory $MYSQLDIR/mysql/ to exist -- have you downloaded and unpacked the IETF binary database tarball?"
|
||||
# fi
|
||||
|
||||
|
||||
# echo "Checking if the IETF database exists at $MYSQLDIR ..."
|
||||
# if [ ! -d $MYSQLDIR/ietf_utf8 ]; then
|
||||
# echo "Creating database ..."
|
||||
# mysqladmin -u root --default-character-set=utf8 create ietf_utf8
|
||||
#
|
||||
# echo "Setting up permissions ..."
|
||||
# mysql -u root ietf_utf8 <<< "GRANT ALL PRIVILEGES ON ietf_utf8.* TO django@localhost IDENTIFIED BY 'RkTkDPFnKpko'; FLUSH PRIVILEGES;"
|
||||
# fi
|
||||
|
||||
echo "Fetching database dump ..."
|
||||
wget -N -P $DATADIR http://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz
|
||||
|
||||
echo "Loading database ..."
|
||||
gunzip < $DATADIR/ietf_utf8.sql.gz \
|
||||
| pv --progress --bytes --rate --eta --size $(gzip --list --quiet $DATADIR/ietf_utf8.sql.gz | awk '{ print $2 }') \
|
||||
| sed -e 's/ENGINE=MyISAM/ENGINE=InnoDB/' \
|
||||
| mysql --host=localhost --user=django --password=RkTkDPFnKpko -s -f ietf_utf8
|
||||
|
||||
|
Loading…
Reference in a new issue