/[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.7 - (show annotations)
Sun Nov 2 10:21:45 2003 UTC (20 years, 5 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +1 -5 lines
moved all info preparation into MkInfo in 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 my $sserver = 1;
23
24 my $result = GetOptions(
25 "debug!" => \$debug, "verbose!" => \$verbose,
26 "quiet!" => \$quiet, "help" => \$help,
27 "masterhost=s" => \$masterhost, "masterport=i" => \$masterport,
28 "masteruser=s" => \$masteruser, "masterpassword=s" => \$masterpassword,
29 "slaveserver=i" => \$sserver,
30 );
31
32 if (defined($help) || (scalar(@ARGV) < 2) || ($ARGV[1] !~ /^\d+$/)) {
33 print "Usage: $0 [options] masterdb syncid
34 Options:
35 --masterhost=hostname --masterport=port
36 --masteruser=username --masterpassword=string
37 --quiet
38 [--slaveserver=slave_number]
39 ";
40 exit ((scalar(@ARGV) < 2)? 1:0);
41 }
42
43 $RServ::quiet = !$verbose;
44 if ($debug) {
45 $RServ::quiet = 0;
46 no warnings 'vars';
47 $RServ::debug = $debug;
48 }
49
50 my $master = $ARGV[0] || "master";
51 my $syncid = $ARGV[1] || die "SyncID not specified";
52
53 my $minfo = MkInfo($master,$masterhost,$masterport,$masteruser,$masterpassword);
54
55 my $conn = Pg::connectdb($minfo);
56 if ($conn->status != Pg::PGRES_CONNECTION_OK) {
57 print STDERR "Failed opening $minfo\n";
58 exit 1;
59 }
60
61 my $res = SyncSyncID($conn, $sserver, $syncid);
62
63 if ($res == 0)
64 {
65 printf STDERR "SyncID updated on $master\n" if ($verbose);
66 exit(0);
67 }
68
69 printf STDERR "ERROR\n" unless ($quiet);
70 exit(1);

  ViewVC Help
Powered by ViewVC 1.1.26