]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/examples/build-eg-replication.sh
LP#827442 Z39.50 will split the total cap between locations when multiple locations...
[working/Evergreen.git] / Open-ILS / examples / build-eg-replication.sh
1 #!/bin/bash
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_agg(table_schema || '.' || table_name),' ')
56       from information_schema.tables
57       where table_schema in (
58         'acq', 'action', 'action_trigger', 'actor', 'asset', 'asset_hist', 'auditor',
59         'authority', 'biblio', 'booking', 'circ_stats', 'config', 'container',
60         'extend_reporter', 'metabib', 'money', 'offline', 'permission', 'query',
61         'reporter', 'search', 'serial', 'staging', 'stats', 'vandelay'
62       ) and table_type = 'BASE TABLE' order by 1;
63   ")
64   TABLES="$TABLES pg_ts_cfg pg_ts_cfgmap"
65 fi
66
67 if [ "_$SEQUENCES" == "_" ]; then
68   SEQUENCES=$(psql -tc "select array_to_string(array_agg(schemaname || '.' || relname),' ') from pg_statio_user_sequences;")
69 fi
70
71
72 if [ "_$1" == "_" ]; then
73   echo 'Please specify at least one host!'
74   exit
75 fi
76
77 DB1=$PGDATABASE
78 USER1=$PGUSER
79 PORT1=$PGPORT
80 HOST1=$1
81
82 if [ "_$2" != "_" ]; then
83   DB2=$PGDATABASE
84   USER2=$PGUSER
85   PORT2=$PGPORT
86   HOST2=$2
87 fi
88
89 if [ "_$3" != "_" ]; then
90   DB3=$PGDATABASE
91   USER3=$PGUSER
92   PORT3=$PGPORT
93   HOST3=$3
94 fi
95
96 if [ "_$4" != "_" ]; then
97   DB4=$PGDATABASE
98   USER4=$PGUSER
99   PORT4=$PGPORT
100   HOST4=$4
101 fi
102
103 if [ "_$5" != "_" ]; then
104   DB5=$PGDATABASE
105   USER5=$PGUSER
106   PORT5=$PGPORT
107   HOST5=$5
108 fi
109
110 ./configure-replication.sh
111