gdp / apps / gdp-hongd-dump.sh @ master
History | View | Annotate | Download (1.77 KB)
1 | ad583a18 | Eric Allman | #!/bin/sh |
---|---|---|---|
2 | |||
3 | # |
||
4 | # Dump the HONGD database |
||
5 | # |
||
6 | |||
7 | args=`getopt Dv: $*` |
||
8 | test $? != 0 && echo "Usage: $0 [-D] [-v version]" >&2 && exit 1 |
||
9 | set -- $args |
||
10 | debug=false |
||
11 | : ${VER:=latest} |
||
12 | while true |
||
13 | do |
||
14 | case "$1" in |
||
15 | -D) |
||
16 | debug=true |
||
17 | ;; |
||
18 | -v) |
||
19 | VER=$1 |
||
20 | shift |
||
21 | ;; |
||
22 | --) |
||
23 | shift |
||
24 | break;; |
||
25 | esac |
||
26 | shift |
||
27 | done |
||
28 | |||
29 | : ${GDP_ETC:=/etc/gdp} |
||
30 | # This parses the same files that are used by the C library. |
||
31 | # It only handles a small set of important variables. |
||
32 | paramfiles=`cat <<-EOF |
||
33 | /etc/gdp/params/gdp |
||
34 | /usr/local/etc/gdp/params/gdp |
||
35 | $HOME/.ep_adm_params/gdp |
||
36 | EOF |
||
37 | ` |
||
38 | |||
39 | # drop comments, change dots in names to underscores, clean up syntax. |
||
40 | # need to repeat one of the patterns because the semantics of global |
||
41 | # substitute means it won't retry overlapping patterns. |
||
42 | tmpfile=/tmp/gdp-$$ |
||
43 | grep -h '^swarm' $paramfiles 2>/dev/null | sed \ |
||
44 | -e "/^#/d" \ |
||
45 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
46 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
47 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
48 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
49 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
50 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
51 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
52 | -e "s/\.\([^.=]*\)=/_\1=/" \ |
||
53 | -e "s/ *= */=\"/" \ |
||
54 | -e "s/$/\"/" \ |
||
55 | > $tmpfile 2>/dev/null |
||
56 | unset paramfiles |
||
57 | . $tmpfile |
||
58 | rm $tmpfile |
||
59 | |||
60 | if [ -z "${swarm_gdp_hongdb_host-}" ] |
||
61 | then |
||
62 | echo "HONGD not configured" 1>&2 |
||
63 | exit 72 |
||
64 | fi |
||
65 | : ${swarm_gdp_hongdb_database:=gdp_hongd} |
||
66 | : ${swarm_gdp_hongdb_table:=human_to_gdp} |
||
67 | : ${swarm_gdp_hongdb_user:=gdp_user} |
||
68 | : ${swarm_gdp_hongdb_passwd:=gdp_user} |
||
69 | |||
70 | 97b75e38 | Eric Allman | echo mysql -h${swarm_gdp_hongdb_host} \ |
71 | -D${swarm_gdp_hongdb_database} \ |
||
72 | -u${swarm_gdp_hongdb_user} \ |
||
73 | -p${swarm_gdp_hongdb_passwd} \ |
||
74 | 'SELECT hex(gname), hname FROM $swarm_gdp_hongdb_table;' |
||
75 | ad583a18 | Eric Allman | mysql -h${swarm_gdp_hongdb_host} \ |
76 | -D${swarm_gdp_hongdb_database} \ |
||
77 | -u${swarm_gdp_hongdb_user} \ |
||
78 | -p${swarm_gdp_hongdb_passwd} \ |
||
79 | <<- EOSQL |
||
80 | SELECT hex(gname), hname |
||
81 | FROM $swarm_gdp_hongdb_table; |
||
82 | EOSQL |