CVS User Account cvsuser
Mon Jan 10 18:20:35 PST 2005
Log Message:
-----------
Add Steve Simms usage, allow nodes to be 123 rather than node123

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

-------------- next part --------------
Index: drop_set.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/drop_set.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -Ltools/altperl/drop_set.pl -Ltools/altperl/drop_set.pl -u -w -r1.4 -r1.5
--- tools/altperl/drop_set.pl
+++ tools/altperl/drop_set.pl
@@ -1,29 +1,48 @@
-#!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: drop_set.pl [--config file] set#
+
+    Drops a set.
+
+";
+
+if ($SHOW_USAGE) {
+  print $USAGE;
+  exit 0;
+}
+
 require 'slon-tools.pm';
-require 'slon.env';
+require $SLON_ENV_FILE;
+
 my ($set) = @ARGV;
-if ($set =~ /^set(\d+)$/) {
+if ($set =~ /^(?:set)?(\d+)$/) {
   $set = $1;
 } else {
   print "Need set identifier\n";
-  die "drop_set.pl setN\n";
+  die $USAGE;
 }
-$OUTFILE="/tmp/dropset.$$";
-open(SLONIK, ">>$OUTFILE");
 
+$FILE = "/tmp/dropset.$$";
+open(SLONIK, ">", $FILE);
 print SLONIK genheader();
-
-print SLONIK qq{
-try {
-      drop set (id = $set, origin=1);
-} on error {
-      exit 1;
-}
-echo 'Dropped set $set';
-};
+print SLONIK "  try {\n";
+print SLONIK "        drop set (id = $set, origin = $MASTERNODE);\n";
+print SLONIK "  } on error {\n";
+print SLONIK "        exit 1;\n";
+print SLONIK "  }\n";
+print SLONIK "  echo 'Dropped set $set';\n";
 close SLONIK;
-run_slonik_script($OUTFILE);
+run_slonik_script($FILE);


More information about the Slony1-commit mailing list