Revision 8893
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/runscripts/local.run | ||
---|---|---|
1 |
#!/bin/bash -e |
|
2 |
# links to locally-available resources |
|
3 |
. "$(dirname "${BASH_SOURCE[0]}")"/util.run |
|
4 |
|
|
5 |
if self_not_included; then |
|
6 |
|
|
7 |
root_dir="$(dirname "${BASH_SOURCE[0]}")"/../.. |
|
8 |
bin_dir="$root_dir"/bin |
|
9 |
|
|
10 |
export PATH="$bin_dir:$PATH" |
|
11 |
|
|
12 |
#### connection vars |
|
13 |
|
|
14 |
: "${remote_server=vegbiendev.nceas.ucsb.edu}" |
|
15 |
: "${local_server=localhost}" |
|
16 |
: "${local_user=bien}" |
|
17 |
: "${local_password="$(cat "$root_dir"/config/bien_password)"}" |
|
18 |
|
|
19 |
#### databases |
|
20 |
|
|
21 |
### MySQL |
|
22 |
|
|
23 |
: "${postgres_compat=1}" |
|
24 |
|
|
25 |
mysql () |
|
26 |
{ |
|
27 |
echo_func |
|
28 |
echo_run mysql_bien --database="$schema" --verbose "$@" |
|
29 |
} |
|
30 |
|
|
31 |
mysqldump_local () |
|
32 |
{ |
|
33 |
echo_func |
|
34 |
use_local_remote; mysqldump_diffable "$@" |
|
35 |
} |
|
36 |
|
|
37 |
### PostgreSQL |
|
38 |
|
|
39 |
psql () # usage: [file=...] [dir=...] self |
|
40 |
{ |
|
41 |
echo_func |
|
42 |
if test -n "$file"; then |
|
43 |
set -- --file "$file" "$@" |
|
44 |
local dir="${dir:-$(dirname "$file")}" |
|
45 |
fi |
|
46 |
local dir="${dir:-$top_dir}" |
|
47 |
|
|
48 |
local psql_cmd="psql_$(if log_sql; then echo verbose; else echo script; fi)_vegbien" |
|
49 |
(cat <<EOF |
|
50 |
\cd $dir |
|
51 |
\set schema "$schema" |
|
52 |
\set table "$table" |
|
53 |
\set table_str '''"$table"''' |
|
54 |
SET search_path TO "$schema", util; |
|
55 |
EOF |
|
56 |
cat)| |
|
57 |
env no_search_path=1 "$psql_cmd" --output /dev/fd/3 "$@" 3>&1 >&2 |
|
58 |
} |
|
59 |
|
|
60 |
fi |
|
61 | 0 |
run | ||
---|---|---|
1 | 1 |
#!/bin/bash -e |
2 | 2 |
. "$(dirname "${BASH_SOURCE[0]}")"/lib/runscripts/import.run |
3 |
. "$(dirname "${BASH_SOURCE[0]}")"/lib/runscripts/local.run
|
|
3 |
. "$(dirname "${BASH_SOURCE[0]}")"/lib/local.sh
|
|
4 | 4 |
|
5 | 5 |
if self_not_included; then |
6 | 6 |
|
lib/local.sh | ||
---|---|---|
1 |
#!/bin/bash -e |
|
2 |
# links to locally-available resources |
|
3 |
. "$(dirname "${BASH_SOURCE[0]}")"/util.sh |
|
4 |
|
|
5 |
if self_not_included; then |
|
6 |
|
|
7 |
root_dir="$(dirname "${BASH_SOURCE[0]}")"/../.. |
|
8 |
bin_dir="$root_dir"/bin |
|
9 |
|
|
10 |
export PATH="$bin_dir:$PATH" |
|
11 |
|
|
12 |
#### connection vars |
|
13 |
|
|
14 |
: "${remote_server=vegbiendev.nceas.ucsb.edu}" |
|
15 |
: "${local_server=localhost}" |
|
16 |
: "${local_user=bien}" |
|
17 |
: "${local_password="$(cat "$root_dir"/config/bien_password)"}" |
|
18 |
|
|
19 |
#### databases |
|
20 |
|
|
21 |
### MySQL |
|
22 |
|
|
23 |
: "${postgres_compat=1}" |
|
24 |
|
|
25 |
mysql () |
|
26 |
{ |
|
27 |
echo_func |
|
28 |
echo_run mysql_bien --database="$schema" --verbose "$@" |
|
29 |
} |
|
30 |
|
|
31 |
mysqldump_local () |
|
32 |
{ |
|
33 |
echo_func |
|
34 |
use_local_remote; mysqldump_diffable "$@" |
|
35 |
} |
|
36 |
|
|
37 |
### PostgreSQL |
|
38 |
|
|
39 |
psql () # usage: [file=...] [dir=...] self |
|
40 |
{ |
|
41 |
echo_func |
|
42 |
if test -n "$file"; then |
|
43 |
set -- --file "$file" "$@" |
|
44 |
local dir="${dir:-$(dirname "$file")}" |
|
45 |
fi |
|
46 |
local dir="${dir:-$top_dir}" |
|
47 |
|
|
48 |
local psql_cmd="psql_$(if log_sql; then echo verbose; else echo script; fi)_vegbien" |
|
49 |
(cat <<EOF |
|
50 |
\cd $dir |
|
51 |
\set schema "$schema" |
|
52 |
\set table "$table" |
|
53 |
\set table_str '''"$table"''' |
|
54 |
SET search_path TO "$schema", util; |
|
55 |
EOF |
|
56 |
cat)| |
|
57 |
env no_search_path=1 "$psql_cmd" --output /dev/fd/3 "$@" 3>&1 >&2 |
|
58 |
} |
|
59 |
|
|
60 |
fi |
|
0 | 61 |
web/links/index.htm.run | ||
---|---|---|
1 | 1 |
#!/bin/bash -e |
2 | 2 |
# reformats index.htm for display |
3 |
. "$(dirname "${BASH_SOURCE[0]}")"/../../lib/runscripts/local.run |
|
3 |
. "$(dirname "${BASH_SOURCE[0]}")"/../../lib/runscripts/util.run |
|
4 |
. "$(dirname "${BASH_SOURCE[0]}")"/../../lib/local.sh |
|
4 | 5 |
|
5 | 6 |
if self_not_included; then |
6 | 7 |
|
Also available in: Unified diff
renamed lib/runscripts/local.run to lib/local.sh since the things it defines are not just for runscripts