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