|
651
|
1 |
#!/usr/bin/env bash |
|
|
2 |
|
|
|
3 |
set -e |
|
|
4 |
|
|
|
5 |
current_path=$PWD |
|
|
6 |
scratch=$(mktemp -d -t tmp.XXXXXXXXXX) |
|
|
7 |
|
|
|
8 |
# download export in tmp folder |
|
|
9 |
# untar it |
|
|
10 |
# build path for ttl file |
|
|
11 |
|
|
|
12 |
# activate virtualenv |
|
|
13 |
|
|
|
14 |
# call import rdf |
|
|
15 |
|
|
|
16 |
# call import_hdabo_db -c |
|
|
17 |
|
|
|
18 |
# call rebuild index |
|
|
19 |
|
|
|
20 |
# tarball="linux-${major}-${minor}-${patchlevel}.tar.bz2" |
|
|
21 |
# curl -q "http://kernel.org/path/to/$tarball" -o "$scratch/$tarball" || true |
|
|
22 |
|
|
|
23 |
usage() { echo "Usage: $0 <virtualenv> <manage_path> <url>" 1>&2; exit 1; } |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
if [[ $# -ne 3 ]]; then |
|
|
27 |
echo "Illegal number of parameters" |
|
|
28 |
usage |
|
|
29 |
fi |
|
|
30 |
|
|
|
31 |
|
|
|
32 |
VIRTUALENV_PATH=$1 |
|
|
33 |
MANAGE_PATH=$2 |
|
|
34 |
RDF_URL=$3 |
|
|
35 |
|
|
|
36 |
curl -q "$RDF_URL" -o "$scratch/export.tar.gz" |
|
|
37 |
|
|
|
38 |
cd "$scratch" |
|
|
39 |
tar zxvf export.tar.gz |
|
|
40 |
|
|
|
41 |
flist=( hda_data_* ) |
|
|
42 |
|
|
|
43 |
TTL_FILE=$PWD/${flist[0]} |
|
|
44 |
|
|
|
45 |
cd "$MANAGE_PATH" |
|
|
46 |
|
|
|
47 |
source "$VIRTUALENV_PATH/bin/activate" |
|
|
48 |
export PYTHONPATH=$PWD |
|
|
49 |
export LD_LIBRARY_PATH="$VIRTUALENV_PATH/lib" |
|
|
50 |
|
|
|
51 |
python manage.py import_rdf "$TTL_FILE" |
|
|
52 |
python manage.py import_hdabo_db -c |
|
|
53 |
python manage.py rebuild_index -r --noinput |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
function finish { |
|
|
57 |
cd "$current_path" |
|
|
58 |
rm -rf "$scratch" |
|
|
59 |
} |
|
|
60 |
|
|
|
61 |
trap finish EXIT |