/[rserv]/bin/MasterSync
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/MasterSync

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations)
Tue Aug 5 21:43:24 2003 UTC (20 years, 9 months ago) by dpavlin
Branch: MAIN
CVS Tags: before_onlytables, before_multmaster, r_0_3
Changes since 1.4: +7 -0 lines
pass warning and debug flags to RServ.pm

1 #!/usr/bin/perl -w
2 # MasterSync
3 # Vadim Mikheev, (c) 2000, PostgreSQL Inc.
4
5 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
6 & eval 'exec perl -S $0 $argv:q'
7 if 0;
8
9 BEGIN {
10 my $basedir = $0; $basedir =~ s#/[^/]+$##;
11 unshift(@INC, "$basedir/../share");
12 }
13
14 use strict;
15 use Getopt::Long;
16 use RServ;
17
18 $| = 1;
19
20 my ($debug,$verbose,$quiet) = (0,0,0);
21 my ($help,$masterhost,$masterport,$masteruser,$masterpassword);
22
23 my $result = GetOptions(
24 "debug!" => \$debug, "verbose!" => \$verbose,
25 "quiet!" => \$quiet, "help" => \$help,
26 "masterhost=s" => \$masterhost, "masterport=i" => \$masterport,
27 "masteruser=s" => \$masteruser, "masterpassword=s" => \$masterpassword,
28 );
29
30 if (defined($help) || (scalar(@ARGV) < 2) || ($ARGV[1] !~ /^\d+$/)) {
31 print "Usage: $0 [options] masterdb syncid
32 Options:
33 --masterhost=hostname --masterport=port
34 --masteruser=username --masterpassword=string
35 --quiet
36 ";
37 exit ((scalar(@ARGV) < 2)? 1:0);
38 }
39
40 $RServ::quiet = !$verbose;
41 if ($debug) {
42 $RServ::quiet = 0;
43 no warnings 'vars';
44 $RServ::debug = $debug;
45 }
46
47 my $master = $ARGV[0] || "master";
48 my $server = 0;
49 my $syncid = $ARGV[1] || die "SyncID not specified";
50
51 my $minfo = "dbname=$master";
52 $minfo = "$minfo host=$masterhost" if (defined($masterhost));
53 $minfo = "$minfo port=$masterport" if (defined($masterport));
54 $minfo = "$minfo user=$masteruser" if (defined($masteruser));
55 $minfo = "$minfo password=$masterpassword" if (defined($masterpassword));
56
57 my $conn = Pg::connectdb($minfo);
58 if ($conn->status != Pg::PGRES_CONNECTION_OK) {
59 print STDERR "Failed opening $minfo\n";
60 exit 1;
61 }
62
63 my $res = SyncSyncID($conn, $server, $syncid);
64
65 if ($res == 0)
66 {
67 printf STDERR "SyncID updated on $master\n" if ($verbose);
68 exit(0);
69 }
70
71 printf STDERR "ERROR\n" unless ($quiet);
72 exit(1);

  ViewVC Help
Powered by ViewVC 1.1.26