This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / bin / slony-setup
1 #!/usr/bin/perl
2 #
3 # hack to update/add read-only permissions for a user on the db
4 #
5 # usage: pg-readonly freesideuser readonlyuser
6
7 use strict;
8 use DBI;
9 use FS::UID qw(adminsuidsetup);
10 use FS::Record qw(dbdef);
11
12 my $user = shift or die &usage;
13 adminsuidsetup($user);
14
15 #---
16
17 #su postgres -c 'createlang plpgsql freeside'
18
19 #---
20
21 my $MASTERHOST = '172.21.0.204';
22 my $SLAVEHOST = '172.21.0.205';
23 #my $REPLICATIONUSER='pgsql';
24 my $REPLICATIONUSER='postgres';
25
26 #drop set ( id = 1, origin = 1);
27
28 print <<END;
29 cluster name = freeside;
30 node 1 admin conninfo = 'dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER';
31 node 2 admin conninfo = 'dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER';
32 init cluster ( id=1, comment = 'Master Node');
33 create set (id=1, origin=1, comment='All freeside tables');
34
35 END
36
37 my $id = 1;
38
39 foreach my $table ( dbdef->tables ) {
40   #next if $table =~ /^sql_/i;
41   print "set add table (set id=1, origin=1, id=". $id++. ", fully qualified name = 'public.$table' );\n";
42
43 }
44
45 print <<END;
46 store node (id=2, comment = 'Slave node');
47 store path (server = 1, client = 2, conninfo='dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER');
48 store path (server = 2, client = 1, conninfo='dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER');
49 store listen (origin=1, provider = 1, receiver =2);
50 store listen (origin=2, provider = 2, receiver =1);
51 END
52
53