Project

General

Profile

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 5917 aaronmk
    make inputs/.TNRS/tnrs_accepted/reinstall
20
    make inputs/.TNRS/tnrs_other/reinstall
21 5503 aaronmk
22 6946 aaronmk
    make schemas/$version/install
23
24 7121 aaronmk
    local all=1; . "$selfDir/with_all" Source/import by_col=1 "$@"
25 6897 aaronmk
        # note that this isn't affected by $import_source
26 6593 aaronmk
    wait # wait for asynchronous commands
27 6896 aaronmk
    unset all
28 6593 aaronmk
29 7095 aaronmk
    local import_source= # Source tables have already been imported
30
    export import_source # must come after local
31 6897 aaronmk
32 6382 aaronmk
    make inputs/.herbaria/import "$@" &
33
    sleep 5 # wait for make commands to scroll by
34
35 5957 aaronmk
    make inputs/.geoscrub/import "$@" &
36 5959 aaronmk
    sleep 5 # wait for make commands to scroll by
37
38 5836 aaronmk
    make inputs/.NCBI/import by_col=1 "$@"
39 5943 aaronmk
    # Must come after NCBI for cross links to be made
40 7125 aaronmk
    make inputs/.TNRS/tnrs_accepted/import "$@"
41
    make inputs/.TNRS/tnrs_other/import "$@"
42 5959 aaronmk
43 6594 aaronmk
    wait # wait for asynchronous commands
44 5503 aaronmk
45 7087 aaronmk
    . "$selfDir/with_all" import "$@"
46 5836 aaronmk
    make inputs/.TNRS/tnrs/tnrs-remake wait=1 "$@" &
47 7089 aaronmk
    make inputs/.TNRS/public.unscrubbed_taxondetermination_view/scrub-remake \
48
        wait=1 "$@" &
49 6210 aaronmk
50
    after_import ()
51
    {
52
        bin/make_analytical_db
53 6958 aaronmk
54 6960 aaronmk
        make backups/TNRS.backup-remake &
55 7038 aaronmk
        make backups/vegbien.$version.backup/test & # uses $dump_opts
56 6958 aaronmk
        wait # wait for asynchronous commands
57 6210 aaronmk
    }
58
59 7121 aaronmk
    local jobs="$(jobs -p)"
60 6211 aaronmk
    (bin/waitpid $jobs; after_import) &
61 1952 aaronmk
}
62
import_all_main "$@"