1
|
#!/bin/bash
|
2
|
# Imports all inputs at once
|
3
|
|
4
|
import_all_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=...;] . $self [vars...] (note initial \".\")"\
|
12
|
|fold -s >&2
|
13
|
return 2
|
14
|
fi
|
15
|
: ${version=$(make -s version)}
|
16
|
local dump_opts=${dump_opts---exclude-schema=public} full_import=1
|
17
|
export version dump_opts full_import
|
18
|
|
19
|
make schemas/$version/install
|
20
|
|
21
|
local all=1; . "$selfDir/with_all" Source/import by_col=1 "$@"
|
22
|
# note that this isn't affected by $import_source
|
23
|
wait # wait for asynchronous commands
|
24
|
unset all
|
25
|
|
26
|
local import_source= # Source tables have already been imported
|
27
|
export import_source # must come after local
|
28
|
|
29
|
make inputs/.herbaria/import "$@" &
|
30
|
sleep 5 # wait for make commands to scroll by
|
31
|
|
32
|
make inputs/.geoscrub/import "$@" &
|
33
|
sleep 5 # wait for make commands to scroll by
|
34
|
|
35
|
make inputs/.NCBI/import by_col=1 "$@"
|
36
|
|
37
|
wait # wait for asynchronous commands
|
38
|
|
39
|
. "$selfDir/with_all" import_scrub "$@"
|
40
|
|
41
|
local jobs="$(jobs -p)"
|
42
|
echo "import_scrub PIDs: $jobs" >&2
|
43
|
|
44
|
after_import ()
|
45
|
{
|
46
|
bin/waitpid $jobs
|
47
|
|
48
|
bin/make_analytical_db
|
49
|
|
50
|
make backups/TNRS.backup-remake &
|
51
|
make backups/vegbien.$version.backup/test & # uses $dump_opts
|
52
|
wait # wait for asynchronous commands
|
53
|
}
|
54
|
|
55
|
after_import &
|
56
|
echo "after_import PID: $!" >&2
|
57
|
|
58
|
. bin/disown_all
|
59
|
}
|
60
|
import_all_main "$@"
|