-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbootstrap.sh
46 lines (37 loc) · 1.43 KB
/
bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# This script "bootstraps" a container to fetch the lexicon files from git
# and create the databases/dawgs. See Dockerfile-bootstrap as well.
# XXX: THIS NEEDS TO BE UPDATED TO JUST FETCH THE LEXICA .DB FILES FROM
# AN S3 OR SPACES FOLDER.
# Otherwise, this initialization takes forever - more than 10 minutes.
# K8s does not deal well with containers that take that long to start,
# and along with the high CPU use during initialization, it's just not a
# great idea.
# Add more DBs here as Aerolith growz: (or make this generic? maybe not)
SUPPORTED_LEXICA=("CSW15" "NWL18" "FISE2" "OSPS40")
# check if the lexicon path contains ALL of these. If it does not, we need to
# re-clone the repo and copy the text files over.
should_clone=0
for lexicon in $SUPPORTED_LEXICA
do
if [ ! -f $LEXICON_PATH/$lexicon.txt ]; then
should_clone=1
break
fi
done
if [ $should_clone == 1 ]; then
git clone https://[email protected]/domino14/word-game-lexica /tmp/word-game-lexica
rm -rf /tmp/word-game-lexica/.git
mv *.txt $LEXICON_PATH
fi
# Figure out which DATABASES are missing.
declare -a dbs_to_create
for lexicon in $SUPPORTED_LEXICA
do
if [ ! -f $LEXICON_PATH/db/$lexicon.db ]; then
dbs_to_create+=("$lexicon")
fi
done
function join_by { local IFS="$1"; shift ; echo "$*"; }
dbs_str=$(join_by , "${dbs_to_create[@]}")
./cmd/dbmaker/dbmaker -outputdir $LEXICON_PATH/db -dbs $dbs_str