1 |
11823
|
aaronmk
|
#!/bin/bash -e
|
2 |
1541
|
aaronmk
|
# Imports all inputs at once
|
3 |
11823
|
aaronmk
|
set -o errexit -o pipefail # errexit since may be called from shell
|
4 |
1541
|
aaronmk
|
|
5 |
11422
|
aaronmk
|
if test "$1" = .; then set --; fi # was .-included without args, so $@ is wrong
|
6 |
|
|
|
7 |
11416
|
aaronmk
|
main()
|
8 |
1952
|
aaronmk
|
{
|
9 |
|
|
local self="${BASH_SOURCE[0]}"
|
10 |
|
|
local selfDir="$(dirname -- "$self")"
|
11 |
11430
|
aaronmk
|
pushd "$selfDir/.."
|
12 |
1952
|
aaronmk
|
|
13 |
1953
|
aaronmk
|
if test "${BASH_LINENO[1]}" = 0; then # was run without initial "."
|
14 |
11371
|
aaronmk
|
echo "usage: [version=...] [inputs=(inputs/src/ ...)]; . $self \
|
15 |
|
|
[vars...] (note initial \".\")"|fold -s >&2
|
16 |
1952
|
aaronmk
|
return 2
|
17 |
|
|
fi
|
18 |
7103
|
aaronmk
|
: ${version=$(make -s version)}
|
19 |
10579
|
aaronmk
|
local by_col=${by_col-1} full_import=1
|
20 |
|
|
export version by_col full_import
|
21 |
1952
|
aaronmk
|
|
22 |
10847
|
aaronmk
|
# remove any leftover TNRS lockfile. usually, the PID in it would not exist,
|
23 |
|
|
# but sometimes it now refers to an active process which blocks tnrs.make.
|
24 |
11419
|
aaronmk
|
"rm" -f inputs/.TNRS/tnrs/tnrs.make.lock
|
25 |
10847
|
aaronmk
|
|
26 |
11421
|
aaronmk
|
make schemas/$version/reinstall
|
27 |
6946
|
aaronmk
|
|
28 |
11415
|
aaronmk
|
local hidden_srcs=1; . "$selfDir/with_all" Source/import by_col=1 "$@"
|
29 |
6897
|
aaronmk
|
# note that this isn't affected by $import_source
|
30 |
6593
|
aaronmk
|
wait # wait for asynchronous commands
|
31 |
11374
|
aaronmk
|
unset hidden_srcs
|
32 |
6593
|
aaronmk
|
|
33 |
7095
|
aaronmk
|
local import_source= # Source tables have already been imported
|
34 |
|
|
export import_source # must come after local
|
35 |
6897
|
aaronmk
|
|
36 |
11393
|
aaronmk
|
# publish datasources that won't be published by `make .../import`
|
37 |
|
|
make inputs/.TNRS/publish
|
38 |
|
|
make inputs/.geoscrub/publish
|
39 |
|
|
|
40 |
6382
|
aaronmk
|
make inputs/.herbaria/import "$@" &
|
41 |
|
|
sleep 5 # wait for make commands to scroll by
|
42 |
|
|
|
43 |
5836
|
aaronmk
|
make inputs/.NCBI/import by_col=1 "$@"
|
44 |
5959
|
aaronmk
|
|
45 |
6594
|
aaronmk
|
wait # wait for asynchronous commands
|
46 |
5503
|
aaronmk
|
|
47 |
11286
|
aaronmk
|
. "$selfDir/with_all" import_scrub "$@" # uses $by_col
|
48 |
6210
|
aaronmk
|
|
49 |
7418
|
aaronmk
|
local jobs="$(jobs -p)"
|
50 |
|
|
echo "import_scrub PIDs: $jobs" >&2
|
51 |
|
|
|
52 |
10586
|
aaronmk
|
bin/after_import $jobs &
|
53 |
7276
|
aaronmk
|
echo "after_import PID: $!" >&2
|
54 |
7228
|
aaronmk
|
|
55 |
|
|
. bin/disown_all
|
56 |
11430
|
aaronmk
|
|
57 |
|
|
popd
|
58 |
1952
|
aaronmk
|
}
|
59 |
11416
|
aaronmk
|
main "$@"
|