/[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

Diff of /bin/MasterSync

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Tue Aug 5 09:52:36 2003 UTC revision 1.4 by dpavlin, Tue Aug 5 21:10:28 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl -w
2  # MasterSync  # MasterSync
3  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.  # Vadim Mikheev, (c) 2000, PostgreSQL Inc.
4    
# Line 6  eval '(exit $?0)' && eval 'exec perl -S Line 6  eval '(exit $?0)' && eval 'exec perl -S
6      & eval 'exec perl -S $0 $argv:q'      & eval 'exec perl -S $0 $argv:q'
7      if 0;      if 0;
8    
9  use lib "/usr/share/postgresql/contrib";  BEGIN {
10            my $basedir = $0; $basedir =~ s#/[^/]+$##;
11            unshift(@INC, "$basedir/../share");
12    }
13    
14    use strict;
15  use Getopt::Long;  use Getopt::Long;
16  use RServ;  use RServ;
17    
18  $| = 1;  $| = 1;
19    
20  $result = GetOptions("debug!", "verbose!", "quiet!", "help",  my ($debug,$verbose,$quiet) = (0,0,0);
21                       "host=s", "user=s", "password=s");  my ($help,$masterhost,$masterport,$masteruser,$masterpassword);
   
 my $debug = $opt_debug || 0;  
 my $verbose = $opt_verbose || 0;  
 my $quiet = $opt_quiet || 0;  
22    
23  if (defined($opt_help) || (scalar(@ARGV) < 2) || ($ARGV[1] !~ /^\d+$/)) {  my $result = GetOptions(
24      print "Usage: $0 --host=name --user=name --password=string masterdb syncid\n";          "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);      exit ((scalar(@ARGV) < 2)? 1:0);
38  }  }
39    
# Line 30  my $server = 0; Line 42  my $server = 0;
42  my $syncid = $ARGV[1] || die "SyncID not specified";  my $syncid = $ARGV[1] || die "SyncID not specified";
43    
44  my $minfo = "dbname=$master";  my $minfo = "dbname=$master";
45  $minfo = "$minfo host=$opt_host" if (defined($opt_host));  $minfo = "$minfo host=$masterhost" if (defined($masterhost));
46  $minfo = "$minfo user=$opt_user" if (defined($opt_user));  $minfo = "$minfo port=$masterport" if (defined($masterport));
47  $minfo = "$minfo password=$opt_password" if (defined($opt_password));  $minfo = "$minfo user=$masteruser" if (defined($masteruser));
48    $minfo = "$minfo password=$masterpassword" if (defined($masterpassword));
49    
50  my $conn = Pg::connectdb($minfo);  my $conn = Pg::connectdb($minfo);
51  if ($conn->status != PGRES_CONNECTION_OK) {  if ($conn->status != Pg::PGRES_CONNECTION_OK) {
52      print STDERR "Failed opening $minfo\n";      print STDERR "Failed opening $minfo\n";
53      exit 1;      exit 1;
54  }  }
55    
56  $res = SyncSyncID($conn, $server, $syncid);  my $res = SyncSyncID($conn, $server, $syncid);
57    
58  if ($res == 0)  if ($res == 0)
59  {  {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.26