Project

General

Profile

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)} ${dump_opts=--exclude-schema=public}
16
    export version dump_opts
17
    
18
    make inputs/.TNRS/tnrs_accepted/reinstall
19
    make inputs/.TNRS/tnrs_other/reinstall
20
    
21
    make schemas/$version/install
22
    
23
    all=1; . "$selfDir/with_all" Source/import by_col=1 "$@"
24
        # note that this isn't affected by $import_source
25
    wait # wait for asynchronous commands
26
    unset all
27
    
28
    export import_source= # Source tables have already been imported
29
    
30
    make inputs/.herbaria/import "$@" &
31
    sleep 5 # wait for make commands to scroll by
32
    
33
    make inputs/.geoscrub/import "$@" &
34
    sleep 5 # wait for make commands to scroll by
35
    
36
    make inputs/.NCBI/import by_col=1 "$@"
37
    # Must come after NCBI for cross links to be made
38
    make inputs/.TNRS/import "$@"
39
    
40
    wait # wait for asynchronous commands
41
    
42
    make inputs/.TNRS/tnrs/tnrs-remake wait=1 "$@" &
43
    . "$selfDir/with_all" import "$@"
44
    
45
    after_import ()
46
    {
47
        bin/make_analytical_db
48
        
49
        make backups/TNRS.backup-remake &
50
        make backups/vegbien.$version.backup/test &
51
        wait # wait for asynchronous commands
52
    }
53
    
54
    jobs="$(jobs -p)"
55
    (bin/waitpid $jobs; after_import) &
56
    
57
    unset import_source
58
}
59
import_all_main "$@"
(27-27/72)