1
|
#!/bin/bash
|
2
|
# Imports all inputs at once
|
3
|
|
4
|
main()
|
5
|
{
|
6
|
local self="${BASH_SOURCE[0]}"
|
7
|
local selfDir="$(dirname -- "$self")"
|
8
|
cd "$selfDir/.."
|
9
|
|
10
|
if test "${BASH_LINENO[1]}" = 0; then # was run without initial "."
|
11
|
echo "usage: [version=...] [inputs=(inputs/src/ ...)]; . $self \
|
12
|
[vars...] (note initial \".\")"|fold -s >&2
|
13
|
return 2
|
14
|
fi
|
15
|
: ${version=$(make -s version)}
|
16
|
local by_col=${by_col-1} full_import=1
|
17
|
export version by_col full_import
|
18
|
|
19
|
# remove any leftover TNRS lockfile. usually, the PID in it would not exist,
|
20
|
# but sometimes it now refers to an active process which blocks tnrs.make.
|
21
|
"rm" inputs/.TNRS/tnrs/tnrs.make.lock
|
22
|
|
23
|
make schemas/$version/install
|
24
|
|
25
|
local hidden_srcs=1; . "$selfDir/with_all" Source/import by_col=1 "$@"
|
26
|
# note that this isn't affected by $import_source
|
27
|
wait # wait for asynchronous commands
|
28
|
unset hidden_srcs
|
29
|
|
30
|
local import_source= # Source tables have already been imported
|
31
|
export import_source # must come after local
|
32
|
|
33
|
# publish datasources that won't be published by `make .../import`
|
34
|
make inputs/.TNRS/publish
|
35
|
make inputs/.geoscrub/publish
|
36
|
|
37
|
make inputs/.herbaria/import "$@" &
|
38
|
sleep 5 # wait for make commands to scroll by
|
39
|
|
40
|
make inputs/.NCBI/import by_col=1 "$@"
|
41
|
|
42
|
wait # wait for asynchronous commands
|
43
|
|
44
|
. "$selfDir/with_all" import_scrub "$@" # uses $by_col
|
45
|
|
46
|
local jobs="$(jobs -p)"
|
47
|
echo "import_scrub PIDs: $jobs" >&2
|
48
|
|
49
|
bin/after_import $jobs &
|
50
|
echo "after_import PID: $!" >&2
|
51
|
|
52
|
. bin/disown_all
|
53
|
}
|
54
|
main "$@"
|