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