CVS User Account cvsuser
Mon Jan 10 18:21:39 PST 2005
Log Message:
-----------
Steve Simms changes - subscribe_set.pl - add usage printout, allow node to be
called 123 as well as node123

Modified Files:
--------------
    slony1-engine/tools/altperl:
        subscribe_set.pl (r1.4 -> r1.5)

-------------- next part --------------
Index: subscribe_set.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/subscribe_set.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -Ltools/altperl/subscribe_set.pl -Ltools/altperl/subscribe_set.pl -u -w -r1.4 -r1.5
--- tools/altperl/subscribe_set.pl
+++ tools/altperl/subscribe_set.pl
@@ -1,23 +1,45 @@
-#!perl # -*- perl -*-
+#!/usr/bin/perl
 # $Id$
 # Author: Christopher Browne
 # Copyright 2004 Afilias Canada
 
+use Getopt::Long;
+
+$SLON_ENV_FILE = 'slon.env'; # Where to find the slon.env file
+$SHOW_USAGE    = 0;          # Show usage, then quit
+
+# Read command-line options
+GetOptions("config=s"  => \$SLON_ENV_FILE,
+	   "help"      => \$SHOW_USAGE);
+
+my $USAGE =
+"Usage: subscribe_set.pl [--config file] set# node#
+
+    Begins replicating a set to the specified node.
+
+";
+
+if ($SHOW_USAGE) {
+  print $USAGE;
+  exit 0;
+}
+
 require 'slon-tools.pm';
-require 'slon.env';
+require $SLON_ENV_FILE;
+
 my ($set, $node) = @ARGV;
-if ($node =~ /^node(\d+)$/) {
+if ($node =~ /^(?:node)?(\d+)$/) {
   $node = $1;
 } else {
   print "Need to specify node!\n";
-  die "subscribe_set setM nodeN\n";
+  die $USAGE;
 }
 
-if ($set =~ /^set(\d+)$/) {
+if ($set =~ /^(?:set)?(\d+)$/) {
   $set = $1;
 } else {
   print "Need to specify set!\n";
-  die "subscribe_set setM nodeN\n";
+  die $USAGE;
 }
 
 $FILE="/tmp/slonik-subscribe.$$";
@@ -42,12 +64,9 @@
 }
 
 print SLONIK "}\n";
-print SLONIK qq{
-        on error {
-                exit 1;
-        }
-        echo 'Subscribed nodes to set $set';
-};
-
+print SLONIK "  on error {\n";
+print SLONIK "    exit 1;\n";
+print SLONIK "  }\n";
+print SLONIK "  echo 'Subscribed nodes to set $set';\n";
 close SLONIK;
 run_slonik_script($FILE);


More information about the Slony1-commit mailing list