]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/examples/build-eg-replication.sh
Support IS NULL and IS NOT NULL expressions.
[working/Evergreen.git] / Open-ILS / examples / build-eg-replication.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2009 Equinox Software, Inc.
4 # Author: Mike Rylander <miker@esilibrary.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16
17 #
18 # This script will help build the slonik scripts required to start
19 # replicating an Evergreen database using Slony-I.
20 #
21 # See: slony-1.2.16/tools/configure-replication.txt
22 #  for more information on the process
23 #
24 # See: slony1-1.2.16/doc/adminguide/firstdb.html
25 #  for an example of how to get the schema copied
26 #
27
28 if [ "_$NUMNODES" == "_" ]; then
29   echo 'Please set the NUMNODES environment variable to the number of new nodes to be created in the new cluster'
30   exit
31 fi
32
33 if [ "_$CLUSTER" == "_" ]; then
34   echo 'Please set the CLUSTER environment variable to the new cluster name'
35   exit
36 fi
37
38 if [ "_$PGDATABASE" == "_" ]; then
39   echo 'Please set the PGDATABASE environment variable to the database name'
40   exit
41 fi
42
43 if [ "_$PGPORT" == "_" ]; then
44   echo 'Please set the PGPORT environment variable to the database port'
45   exit
46 fi
47
48 if [ "_$PGUSER" == "_" ]; then
49   echo 'Please set the PGPORT environment variable to the database superuser'
50   exit
51 fi
52
53 if [ "_$TABLES" == "_" ]; then
54   TABLES=$(psql -tc "
55     select array_to_string(array_accum(table_schema || '.' || table_name),' ')
56       from information_schema.tables
57       where table_schema in (
58         'action', 'actor', 'asset', 'authority', 'auditor', 'biblio', 'config',
59         'container', 'extend_reporter', 'metabib', 'money', 'offline', 'permission',
60         'reporter', 'search', 'stats', 'vandely'
61       ) and table_type = 'BASE TABLE' order by 1;
62   ")
63   TABLES="$TABLES pg_ts_cfg pg_ts_cfgmap"
64 fi
65
66 if [ "_$SEQUENCES" == "_" ]; then
67   SEQUENCES=$(psql -tc "select array_to_string(array_accum(schemaname || '.' || relname),' ') from pg_statio_user_sequences;")
68 fi
69
70
71 if [ "_$1" == "_" ]; then
72   echo 'Please specify at least one host!'
73   exit
74 fi
75
76 DB1=$PGDATABASE
77 USER1=$PGUSER
78 PORT1=$PGPORT
79 HOST1=$1
80
81 if [ "_$2" != "_" ]; then
82   DB2=$PGDATABASE
83   USER2=$PGUSER
84   PORT2=$PGPORT
85   HOST2=$2
86 fi
87
88 if [ "_$3" != "_" ]; then
89   DB3=$PGDATABASE
90   USER3=$PGUSER
91   PORT3=$PGPORT
92   HOST3=$3
93 fi
94
95 if [ "_$4" != "_" ]; then
96   DB4=$PGDATABASE
97   USER4=$PGUSER
98   PORT4=$PGPORT
99   HOST4=$4
100 fi
101
102 if [ "_$5" != "_" ]; then
103   DB5=$PGDATABASE
104   USER5=$PGUSER
105   PORT5=$PGPORT
106   HOST5=$5
107 fi
108
109 ./configure-replication.sh
110