1 |
1551
|
aaronmk
|
#!/bin/bash
|
2 |
1541
|
aaronmk
|
# Imports all inputs at once
|
3 |
|
|
|
4 |
1952
|
aaronmk
|
import_all_main ()
|
5 |
|
|
{
|
6 |
|
|
local self="${BASH_SOURCE[0]}"
|
7 |
|
|
local selfDir="$(dirname -- "$self")"
|
8 |
6211
|
aaronmk
|
cd "$selfDir/.."
|
9 |
1952
|
aaronmk
|
|
10 |
1953
|
aaronmk
|
if test "${BASH_LINENO[1]}" = 0; then # was run without initial "."
|
11 |
6946
|
aaronmk
|
echo "Usage: [version=...;] . $self [vars...] (note initial \".\")"\
|
12 |
|
|
|fold -s >&2
|
13 |
1952
|
aaronmk
|
return 2
|
14 |
|
|
fi
|
15 |
7103
|
aaronmk
|
: ${version=$(make -s version)}
|
16 |
|
|
local dump_opts=${dump_opts---exclude-schema=public} public_import=1
|
17 |
|
|
export version dump_opts public_import
|
18 |
1952
|
aaronmk
|
|
19 |
7127
|
aaronmk
|
make inputs/.TNRS/tnrs+accepted/reinstall
|
20 |
5917
|
aaronmk
|
make inputs/.TNRS/tnrs_accepted/reinstall
|
21 |
|
|
make inputs/.TNRS/tnrs_other/reinstall
|
22 |
5503
|
aaronmk
|
|
23 |
6946
|
aaronmk
|
make schemas/$version/install
|
24 |
|
|
|
25 |
7121
|
aaronmk
|
local all=1; . "$selfDir/with_all" Source/import by_col=1 "$@"
|
26 |
6897
|
aaronmk
|
# note that this isn't affected by $import_source
|
27 |
6593
|
aaronmk
|
wait # wait for asynchronous commands
|
28 |
6896
|
aaronmk
|
unset all
|
29 |
6593
|
aaronmk
|
|
30 |
7095
|
aaronmk
|
local import_source= # Source tables have already been imported
|
31 |
|
|
export import_source # must come after local
|
32 |
6897
|
aaronmk
|
|
33 |
6382
|
aaronmk
|
make inputs/.herbaria/import "$@" &
|
34 |
|
|
sleep 5 # wait for make commands to scroll by
|
35 |
|
|
|
36 |
5957
|
aaronmk
|
make inputs/.geoscrub/import "$@" &
|
37 |
5959
|
aaronmk
|
sleep 5 # wait for make commands to scroll by
|
38 |
|
|
|
39 |
5836
|
aaronmk
|
make inputs/.NCBI/import by_col=1 "$@"
|
40 |
5943
|
aaronmk
|
# Must come after NCBI for cross links to be made
|
41 |
7125
|
aaronmk
|
make inputs/.TNRS/tnrs_accepted/import "$@"
|
42 |
|
|
make inputs/.TNRS/tnrs_other/import "$@"
|
43 |
5959
|
aaronmk
|
|
44 |
6594
|
aaronmk
|
wait # wait for asynchronous commands
|
45 |
5503
|
aaronmk
|
|
46 |
7087
|
aaronmk
|
. "$selfDir/with_all" import "$@"
|
47 |
5836
|
aaronmk
|
make inputs/.TNRS/tnrs/tnrs-remake wait=1 "$@" &
|
48 |
7089
|
aaronmk
|
make inputs/.TNRS/public.unscrubbed_taxondetermination_view/scrub-remake \
|
49 |
|
|
wait=1 "$@" &
|
50 |
6210
|
aaronmk
|
|
51 |
|
|
after_import ()
|
52 |
|
|
{
|
53 |
|
|
bin/make_analytical_db
|
54 |
6958
|
aaronmk
|
|
55 |
6960
|
aaronmk
|
make backups/TNRS.backup-remake &
|
56 |
7038
|
aaronmk
|
make backups/vegbien.$version.backup/test & # uses $dump_opts
|
57 |
6958
|
aaronmk
|
wait # wait for asynchronous commands
|
58 |
6210
|
aaronmk
|
}
|
59 |
|
|
|
60 |
7121
|
aaronmk
|
local jobs="$(jobs -p)"
|
61 |
6211
|
aaronmk
|
(bin/waitpid $jobs; after_import) &
|
62 |
1952
|
aaronmk
|
}
|
63 |
|
|
import_all_main "$@"
|