Skip to content

Commit 5ad8db3

Browse files
committed
Additional docker tweaks
- Legacy-Id: 10468
1 parent d7595e5 commit 5ad8db3

3 files changed

Lines changed: 132 additions & 0 deletions

File tree

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ COPY settings_local.py ./
7777
COPY setprompt ./
7878

7979
COPY docker-init.sh /docker-init.sh
80+
RUN chmod +x /docker-init.sh
8081
ENTRYPOINT ["/docker-init.sh"]
8182

8283
CMD /bin/bash

docker/docker-init.sh

100755100644
File mode changed.

docker/updatedb

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
3+
version=0.10
4+
program=${0##*/}
5+
progdir=${0%/*}
6+
if [ "$progdir" = "$program" ]; then progdir="."; fi
7+
if [ "$progdir" = "." ]; then progdir="$PWD"; fi
8+
parent=$(dirname $progdir)
9+
if [ "$parent" = "." ]; then parent="$PWD"; fi
10+
11+
# ----------------------------------------------------------------------
12+
function usage() {
13+
cat <<EOF
14+
NAME
15+
$program - Update the local copy of the IETF database from a dump
16+
17+
SYNOPSIS
18+
$program [OPTIONS] ARGS
19+
20+
DESCRIPTION
21+
22+
This script downloads a dump of the IETF database and loads into the
23+
local sql server if it is newer than the current dump.
24+
25+
EOF
26+
echo -e "OPTIONS"
27+
if [ "$(uname)" = "Linux" ]; then
28+
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/'
29+
else
30+
egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /'
31+
fi
32+
cat <<EOF
33+
34+
FILES
35+
36+
AUTHOR
37+
Written by Henrik Levkowetz, <henrik@levkowetz.com>
38+
39+
COPYRIGHT
40+
41+
Copyright (c) 2015 IETF Trust and the persons identified as authors of
42+
the code. All rights reserved. License 'Simplified BSD', as specified
43+
in http://opensource.org/licenses/BSD-3-Clause.
44+
45+
EOF
46+
47+
}
48+
49+
# ----------------------------------------------------------------------
50+
function die() {
51+
echo -e "\n$program: error: $*" >&2
52+
exit 1
53+
}
54+
55+
function note() {
56+
if [ -n "$VERBOSE" ]; then echo -e "$*"; fi
57+
}
58+
59+
# ----------------------------------------------------------------------
60+
function version() {
61+
echo -e "$program $version"
62+
}
63+
64+
# ----------------------------------------------------------------------
65+
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
66+
67+
68+
# ----------------------------------------------------------------------
69+
# Option parsing
70+
71+
# Options
72+
shortopts=hvV
73+
longopts=help,verbose,version
74+
75+
if [ "$(uname)" = "Linux" ]; then
76+
args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@")
77+
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
78+
eval set -- "$args"
79+
sed="sed -r"
80+
else
81+
# Darwin, BSDs
82+
args=$(getopt -o$shortopts $SV $*)
83+
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
84+
set -- $args
85+
sed="sed -E"
86+
fi
87+
88+
while true ; do
89+
case "$1" in
90+
-h| --help) usage; exit;; # Show this help, then exit
91+
-v| --verbose) VERBOSE=1;; # Be more talkative
92+
-V| --version) version; exit;; # Show program version, then exit
93+
--) shift; break;;
94+
*) die "Internal error, inconsistent option specification: '$1'";;
95+
esac
96+
shift
97+
done
98+
99+
# ----------------------------------------------------------------------
100+
# The program itself
101+
102+
echo "Gathering info ..."
103+
MYSQLDIR="$(/usr/sbin/mysqld --verbose --help 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
104+
MYSQLDIR=${MYSQLDIR%/}
105+
DATADIR=$parent/data
106+
107+
# echo "Checking if MySQL base data exists ..."
108+
# if [ ! -d $MYSQLDIR/mysql ]; then
109+
# die "Expected the directory $MYSQLDIR/mysql/ to exist -- have you downloaded and unpacked the IETF binary database tarball?"
110+
# fi
111+
112+
113+
# echo "Checking if the IETF database exists at $MYSQLDIR ..."
114+
# if [ ! -d $MYSQLDIR/ietf_utf8 ]; then
115+
# echo "Creating database ..."
116+
# mysqladmin -u root --default-character-set=utf8 create ietf_utf8
117+
#
118+
# echo "Setting up permissions ..."
119+
# mysql -u root ietf_utf8 <<< "GRANT ALL PRIVILEGES ON ietf_utf8.* TO django@localhost IDENTIFIED BY 'RkTkDPFnKpko'; FLUSH PRIVILEGES;"
120+
# fi
121+
122+
echo "Fetching database dump ..."
123+
wget -N -P $DATADIR http://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz
124+
125+
echo "Loading database ..."
126+
gunzip < $DATADIR/ietf_utf8.sql.gz \
127+
| pv --progress --bytes --rate --eta --size $(gzip --list --quiet $DATADIR/ietf_utf8.sql.gz | awk '{ print $2 }') \
128+
| sed -e 's/ENGINE=MyISAM/ENGINE=InnoDB/' \
129+
| mysql --host=localhost --user=django --password=RkTkDPFnKpko -s -f ietf_utf8
130+
131+

0 commit comments

Comments
 (0)