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 6896 aaronmk
    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 5957 aaronmk
    make inputs/.TNRS/import "$@"
41 5959 aaronmk
42 6594 aaronmk
    wait # wait for asynchronous commands
43 5503 aaronmk
44 7087 aaronmk
    . "$selfDir/with_all" import "$@"
45 5836 aaronmk
    make inputs/.TNRS/tnrs/tnrs-remake wait=1 "$@" &
46 7089 aaronmk
    make inputs/.TNRS/public.unscrubbed_taxondetermination_view/scrub-remake \
47
        wait=1 "$@" &
48 6210 aaronmk
49
    after_import ()
50
    {
51
        bin/make_analytical_db
52 6958 aaronmk
53 6960 aaronmk
        make backups/TNRS.backup-remake &
54 7038 aaronmk
        make backups/vegbien.$version.backup/test & # uses $dump_opts
55 6958 aaronmk
        wait # wait for asynchronous commands
56 6210 aaronmk
    }
57
58
    jobs="$(jobs -p)"
59 6211 aaronmk
    (bin/waitpid $jobs; after_import) &
60 1952 aaronmk
}
61
import_all_main "$@"