Fri Oct 27 10:54:22 PDT 2006
- Previous message: [Slony1-commit] By cbbrowne: Per Bernd Helmle, changing altperl scripts to not use
- Next message: [Slony1-commit] By cbbrowne: Use SLON_FATAL rather than FATAL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message:
-----------
Per Bernd Helmle, changing altperl scripts to not use (possibly insecure)
/tmp files, but rather submit output via a string
----------------------------------------------------------------------
Tags:
----
REL_1_2_STABLE
Modified Files:
--------------
slony1-engine/tools/altperl:
slonik_create_set.pl (r1.3 -> r1.3.2.1)
slonik_drop_node.pl (r1.1 -> r1.1.4.1)
slonik_drop_set.pl (r1.1 -> r1.1.4.1)
slonik_drop_table.pl (r1.1.2.1 -> r1.1.2.2)
slonik_execute_script.pl (r1.1 -> r1.1.4.1)
slonik_failover.pl (r1.1 -> r1.1.4.1)
slonik_init_cluster.pl (r1.1.4.1 -> r1.1.4.2)
slonik_merge_sets.pl (r1.1 -> r1.1.4.1)
slonik_move_set.pl (r1.1 -> r1.1.4.1)
slonik_print_preamble.pl (r1.1.2.1 -> r1.1.2.2)
slonik_restart_node.pl (r1.1 -> r1.1.4.1)
slonik_store_node.pl (r1.2 -> r1.2.2.1)
slonik_subscribe_set.pl (r1.1.4.1 -> r1.1.4.2)
slonik_uninstall_nodes.pl (r1.1 -> r1.1.4.1)
slonik_unsubscribe_set.pl (r1.1 -> r1.1.4.1)
slonik_update_nodes.pl (r1.1 -> r1.1.4.1)
-------------- next part --------------
Index: slonik_update_nodes.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_update_nodes.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_update_nodes.pl -Ltools/altperl/slonik_update_nodes.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_update_nodes.pl
+++ tools/altperl/slonik_update_nodes.pl
@@ -28,10 +28,10 @@
require '@@PGLIBDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-open(SLONIK, ">", "/tmp/update_nodes.$$");
-print SLONIK genheader();
+my $slonik = '';
+$slonik .= genheader();
foreach my $node (@NODES) {
- print SLONIK " update functions (id = $node);\n";
+ $slonik .= " update functions (id = $node);\n";
};
-close SLONIK;
-run_slonik_script("/tmp/update_nodes.$$");
+
+run_slonik_script($slonik, 'UPDATE FUNCTIONS');
Index: slonik_print_preamble.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_print_preamble.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Ltools/altperl/slonik_print_preamble.pl -Ltools/altperl/slonik_print_preamble.pl -u -w -r1.1.2.1 -r1.1.2.2
--- tools/altperl/slonik_print_preamble.pl
+++ tools/altperl/slonik_print_preamble.pl
@@ -32,8 +32,7 @@
require '@@PGLIBDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-$FILE="/tmp/print_preamble.$$";
-open (SLONIK, ">", $FILE);
-print SLONIK genheader();
-close SLONIK;
-run_slonik_script($FILE);
+my $slonik = '';
+$slonik .= genheader();
+
+run_slonik_script($slonik, 'PRINT PREAMBLE');
Index: slonik_merge_sets.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_merge_sets.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_merge_sets.pl -Ltools/altperl/slonik_merge_sets.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_merge_sets.pl
+++ tools/altperl/slonik_merge_sets.pl
@@ -53,14 +53,15 @@
my ($dbname, $dbhost) = ($DBNAME[$MASTERNODE], $HOST[$MASTERNODE]);
-open(SLONIK, ">", "/tmp/slonik.$$");
-print SLONIK genheader();
-print SLONIK " try {\n";
-print SLONIK " merge set (id = $set1, add id = $set2, origin = $node);\n";
-print SLONIK " } on error {\n";
-print SLONIK " echo 'Failure to merge sets $set1 and $set2 with origin $node';\n";
-print SLONIK " exit 1;\n";
-print SLONIK " }\n";
-print SLONIK " echo 'Replication set $set2 merged in with $set1 on origin $node';\n";
-close SLONIK;
-run_slonik_script("/tmp/slonik.$$");
+my $slonik = '';
+
+$slonik .= genheader();
+$slonik .= " try {\n";
+$slonik .= " merge set (id = $set1, add id = $set2, origin = $node);\n";
+$slonik .= " } on error {\n";
+$slonik .= " echo 'Failure to merge sets $set1 and $set2 with origin $node';\n";
+$slonik .= " exit 1;\n";
+$slonik .= " }\n";
+$slonik .= " echo 'Replication set $set2 merged in with $set1 on origin $node';\n";
+
+run_slonik_script($slonik, 'MERGE SET');
Index: slonik_drop_set.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_drop_set.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_drop_set.pl -Ltools/altperl/slonik_drop_set.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_drop_set.pl
+++ tools/altperl/slonik_drop_set.pl
@@ -38,14 +38,14 @@
get_set($set) or die "Non-existent set specified.\n";
-$FILE = "/tmp/dropset.$$";
-open(SLONIK, ">", $FILE);
-print SLONIK genheader();
-print SLONIK " try {\n";
-print SLONIK " drop set (id = $set, origin = $SET_ORIGIN);\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($FILE);
+my $slonik = '';
+
+$slonik .= genheader();
+$slonik .= " try {\n";
+$slonik .= " drop set (id = $set, origin = $SET_ORIGIN);\n";
+$slonik .= " } on error {\n";
+$slonik .= " exit 1;\n";
+$slonik .= " }\n";
+$slonik .= " echo 'Dropped set $set';\n";
+
+run_slonik_script($slonik, 'DROP SET');
Index: slonik_restart_node.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_restart_node.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_restart_node.pl -Ltools/altperl/slonik_restart_node.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_restart_node.pl
+++ tools/altperl/slonik_restart_node.pl
@@ -47,11 +47,10 @@
die $USAGE unless scalar @nodes;
-my $FILE="/tmp/restart.$$";
-open(SLONIK, ">", $FILE);
-print SLONIK genheader();
+my $slonik = '';
+$slonik .= genheader();
foreach my $node (@nodes) {
- print SLONIK " restart node $node;\n";
+ $slonik .= " restart node $node;\n";
}
-close SLONIK;
-run_slonik_script($FILE);
+
+run_slonik_script($slonik, 'RESTART NODE');
Index: slonik_create_set.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_create_set.pl,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -Ltools/altperl/slonik_create_set.pl -Ltools/altperl/slonik_create_set.pl -u -w -r1.3 -r1.3.2.1
--- tools/altperl/slonik_create_set.pl
+++ tools/altperl/slonik_create_set.pl
@@ -20,6 +20,8 @@
";
+my $slonik = '';
+
if ($SHOW_USAGE) {
print $USAGE;
exit 0;
@@ -34,58 +36,56 @@
die $USAGE;
}
-$FILE="/tmp/add_tables.$$";
-open (SLONIK, ">", $FILE);
-print SLONIK genheader();
+$slonik .= genheader();
# Tables without primary keys
-print SLONIK "\n";
-print SLONIK "# TABLE ADD KEY\n";
+$slonik .= "\n";
+$slonik .= "# TABLE ADD KEY\n";
foreach my $table (@SERIALTABLES) {
$table = ensure_namespace($table);
$table = lc($table) if $FOLD_CASE;
- print SLONIK " echo ' Adding unique key to table $table...';\n";
- print SLONIK " table add key (\n";
- print SLONIK " node id = $SET_ORIGIN,\n";
- print SLONIK " full qualified name='$table'\n";
- print SLONIK " );\n";
+ $slonik .= " echo ' Adding unique key to table $table...';\n";
+ $slonik .= " table add key (\n";
+ $slonik .= " node id = $SET_ORIGIN,\n";
+ $slonik .= " full qualified name='$table'\n";
+ $slonik .= " );\n";
}
# CREATE SET
-print SLONIK "\n";
-print SLONIK "# CREATE SET\n";
-print SLONIK " try {\n";
-print SLONIK " create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID for $CLUSTER_NAME');\n";
-print SLONIK " } on error {\n";
-print SLONIK " echo 'Could not create subscription set $SET_ID for $CLUSTER_NAME!';\n";
-print SLONIK " exit -1;\n";
-print SLONIK " }\n";
+$slonik .= "\n";
+$slonik .= "# CREATE SET\n";
+$slonik .= " try {\n";
+$slonik .= " create set (id = $SET_ID, origin = $SET_ORIGIN, comment = 'Set $SET_ID for $CLUSTER_NAME');\n";
+$slonik .= " } on error {\n";
+$slonik .= " echo 'Could not create subscription set $SET_ID for $CLUSTER_NAME!';\n";
+$slonik .= " exit -1;\n";
+$slonik .= " }\n";
# SET ADD TABLE
-print SLONIK "\n";
-print SLONIK "# SET ADD TABLE\n";
-print SLONIK " echo 'Subscription set $SET_ID created';\n";
-print SLONIK " echo 'Adding tables to the subscription set';\n";
+$slonik .= "\n";
+$slonik .= "# SET ADD TABLE\n";
+$slonik .= " echo 'Subscription set $SET_ID created';\n";
+$slonik .= " echo 'Adding tables to the subscription set';\n";
$TABLE_ID = 1 if $TABLE_ID < 1;
foreach my $table (@SERIALTABLES) {
$table = ensure_namespace($table);
$table = lc($table) if $FOLD_CASE;
- print SLONIK " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
- print SLONIK " full qualified name = '$table', key=serial,\n";
- print SLONIK " comment = 'Table $table without primary key');\n";
- print SLONIK " echo 'Add unkeyed table $table';\n";
+ $slonik .= " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
+ $slonik .= " full qualified name = '$table', key=serial,\n";
+ $slonik .= " comment = 'Table $table without primary key');\n";
+ $slonik .= " echo 'Add unkeyed table $table';\n";
$TABLE_ID++;
}
foreach my $table (@PKEYEDTABLES) {
$table = ensure_namespace($table);
$table = lc($table) if $FOLD_CASE;
- print SLONIK " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
- print SLONIK " full qualified name = '$table',\n";
- print SLONIK " comment = 'Table $table with primary key');\n";
- print SLONIK " echo 'Add primary keyed table $table';\n";
+ $slonik .= " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
+ $slonik .= " full qualified name = '$table',\n";
+ $slonik .= " comment = 'Table $table with primary key');\n";
+ $slonik .= " echo 'Add primary keyed table $table';\n";
$TABLE_ID++;
}
@@ -93,32 +93,31 @@
my $key = $KEYEDTABLES{$table};
$table = ensure_namespace($table);
$table = lc($table) if $FOLD_CASE;
- print SLONIK " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
- print SLONIK " full qualified name = '$table', key='$key',\n";
- print SLONIK " comment = 'Table $table with candidate primary key $key');\n";
- print SLONIK " echo 'Add candidate primary keyed table $table';\n";
+ $slonik .= " set add table (set id = $SET_ID, origin = $SET_ORIGIN, id = $TABLE_ID,\n";
+ $slonik .= " full qualified name = '$table', key='$key',\n";
+ $slonik .= " comment = 'Table $table with candidate primary key $key');\n";
+ $slonik .= " echo 'Add candidate primary keyed table $table';\n";
$TABLE_ID++;
}
# SET ADD SEQUENCE
-print SLONIK "\n";
-print SLONIK "# SET ADD SEQUENCE\n";
-print SLONIK " echo 'Adding sequences to the subscription set';\n";
+$slonik .= "\n";
+$slonik .= "# SET ADD SEQUENCE\n";
+$slonik .= " echo 'Adding sequences to the subscription set';\n";
$SEQUENCE_ID = 1 if $SEQUENCE_ID < 1;
foreach my $seq (@SEQUENCES) {
$seq = ensure_namespace($seq);
$seq = lc($seq) if $FOLD_CASE;
- print SLONIK " set add sequence (set id = $SET_ID, origin = $SET_ORIGIN, id = $SEQUENCE_ID,\n";
- print SLONIK " full qualified name = '$seq',\n";
- print SLONIK " comment = 'Sequence $seq');\n";
- print SLONIK " echo 'Add sequence $seq';\n";
+ $slonik .= " set add sequence (set id = $SET_ID, origin = $SET_ORIGIN, id = $SEQUENCE_ID,\n";
+ $slonik .= " full qualified name = '$seq',\n";
+ $slonik .= " comment = 'Sequence $seq');\n";
+ $slonik .= " echo 'Add sequence $seq';\n";
$SEQUENCE_ID++;
}
-print SLONIK " echo 'All tables added';\n";
+$slonik .= " echo 'All tables added';\n";
-close SLONIK;
-run_slonik_script($FILE);
+run_slonik_script($slonik, 'CREATE SET');
### If object hasn't a namespace specified, assume it's in "public", and make it so...
sub ensure_namespace {
Index: slonik_failover.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_failover.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_failover.pl -Ltools/altperl/slonik_failover.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_failover.pl
+++ tools/altperl/slonik_failover.pl
@@ -45,14 +45,14 @@
die $USAGE;
}
-open(SLONIK, ">", "/tmp/slonik.$$");
-print SLONIK genheader();
-print SLONIK " try {\n";
-print SLONIK " failover (id = $node1, backup node = $node2);\n";
-print SLONIK " } on error {\n";
-print SLONIK " echo 'Failure to fail node $node1 over to $node2';\n";
-print SLONIK " exit 1;\n";
-print SLONIK " }\n";
-print SLONIK " echo 'Replication sets originating on $node1 failed over to $node2';\n";
-close SLONIK;
-run_slonik_script("/tmp/slonik.$$");
+my $slonik = '';
+$slonik .= genheader();
+$slonik .= " try {\n";
+$slonik .= " failover (id = $node1, backup node = $node2);\n";
+$slonik .= " } on error {\n";
+$slonik .= " echo 'Failure to fail node $node1 over to $node2';\n";
+$slonik .= " exit 1;\n";
+$slonik .= " }\n";
+$slonik .= " echo 'Replication sets originating on $node1 failed over to $node2';\n";
+
+run_slonik_script($slonik, 'FAILOVER');
Index: slonik_unsubscribe_set.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_unsubscribe_set.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_unsubscribe_set.pl -Ltools/altperl/slonik_unsubscribe_set.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_unsubscribe_set.pl
+++ tools/altperl/slonik_unsubscribe_set.pl
@@ -43,15 +43,15 @@
die $USAGE;
}
-open(SLONIK, ">", "/tmp/slonik-unsubscribe.$$");
-print SLONIK genheader();
-print SLONIK " try {\n";
-print SLONIK " unsubscribe set (id = $set, receiver = $node);\n";
-print SLONIK " }\n";
-print SLONIK " on error {\n";
-print SLONIK " echo 'Failed to unsubscribe node $node from set $set';\n";
-print SLONIK " exit 1;\n";
-print SLONIK " }\n";
-print SLONIK " echo 'unsubscribed node $node from set $set';\n";
-close SLONIK;
-run_slonik_script("/tmp/slonik-unsubscribe.$$");
+my $slonik = '';
+$slonik .= genheader();
+$slonik .= " try {\n";
+$slonik .= " unsubscribe set (id = $set, receiver = $node);\n";
+$slonik .= " }\n";
+$slonik .= " on error {\n";
+$slonik .= " echo 'Failed to unsubscribe node $node from set $set';\n";
+$slonik .= " exit 1;\n";
+$slonik .= " }\n";
+$slonik .= " echo 'unsubscribed node $node from set $set';\n";
+
+run_slonik_script($slonik, 'UNSUBSCRIBE SET');
Index: slonik_drop_node.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_drop_node.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_drop_node.pl -Ltools/altperl/slonik_drop_node.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_drop_node.pl
+++ tools/altperl/slonik_drop_node.pl
@@ -35,15 +35,15 @@
die $USAGE;
}
-my $FILE="/tmp/slonik-drop.$$";
-open(SLONIK, ">", $FILE);
-print SLONIK genheader();
-print SLONIK " try {\n";
-print SLONIK " drop node (id = $node, event node = $MASTERNODE);\n";
-print SLONIK " } on error {\n";
-print SLONIK " echo 'Failed to drop node $node from cluster';\n";
-print SLONIK " exit 1;\n";
-print SLONIK " }\n";
-print SLONIK " echo 'dropped node $node cluster';\n";
-close SLONIK;
-run_slonik_script($FILE);
+my $slonik = '';
+
+$slonik .= genheader();
+$slonik .= " try {\n";
+$slonik .= " drop node (id = $node, event node = $MASTERNODE);\n";
+$slonik .= " } on error {\n";
+$slonik .= " echo 'Failed to drop node $node from cluster';\n";
+$slonik .= " exit 1;\n";
+$slonik .= " }\n";
+$slonik .= " echo 'dropped node $node cluster';\n";
+
+run_slonik_script($slonik, 'DROP NODE');
Index: slonik_uninstall_nodes.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_uninstall_nodes.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_uninstall_nodes.pl -Ltools/altperl/slonik_uninstall_nodes.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_uninstall_nodes.pl
+++ tools/altperl/slonik_uninstall_nodes.pl
@@ -28,13 +28,12 @@
require '@@PGLIBDIR@@/slon-tools.pm';
require $CONFIG_FILE;
-$FILE="/tmp/slonik.$$";
-open(SLONIK, ">$FILE");
-print SLONIK genheader();
+my $slonik = '';
+$slonik .= genheader();
foreach my $node (@NODES) {
next if $node == $MASTERNODE; # Do this one last
- print SLONIK " uninstall node (id=$node);\n";
+ $slonik .= " uninstall node (id=$node);\n";
}
-print SLONIK " uninstall node (id=$MASTERNODE);\n";
-close SLONIK;
-run_slonik_script($FILE);
+$slonik .= " uninstall node (id=$MASTERNODE);\n";
+
+run_slonik_script($slonik, 'UNINSTALL NODE');
Index: slonik_drop_table.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_drop_table.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Ltools/altperl/slonik_drop_table.pl -Ltools/altperl/slonik_drop_table.pl -u -w -r1.1.2.1 -r1.1.2.2
--- tools/altperl/slonik_drop_table.pl
+++ tools/altperl/slonik_drop_table.pl
@@ -40,20 +40,18 @@
die $USAGE;
}
-$FILE="/tmp/drop_table.$$";
-open (SLONIK, ">", $FILE);
-print SLONIK genheader();
+my $slonik = '';
-# DROP TABLE
-print SLONIK "\n";
-print SLONIK "# DROP TABLE \n";
-print SLONIK " try {\n";
-print SLONIK " SET DROP TABLE (id = $TABLE_ID, origin = $SET_ORIGIN);\n";
-print SLONIK " } on error {\n";
-print SLONIK " echo 'Could not drop table $TABLE_ID for $CLUSTER_NAME!';\n";
-print SLONIK " exit -1;\n";
-print SLONIK " }\n";
+$slonik .= genheader();
+# DROP TABLE
+$slonik .= "\n";
+$slonik .= "# DROP TABLE \n";
+$slonik .= " try {\n";
+$slonik .= " SET DROP TABLE (id = $TABLE_ID, origin = $SET_ORIGIN);\n";
+$slonik .= " } on error {\n";
+$slonik .= " echo 'Could not drop table $TABLE_ID for $CLUSTER_NAME!';\n";
+$slonik .= " exit -1;\n";
+$slonik .= " }\n";
-close SLONIK;
-run_slonik_script($FILE);
+run_slonik_script($slonik, 'DROP TABLE');
Index: slonik_store_node.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_store_node.pl,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -Ltools/altperl/slonik_store_node.pl -Ltools/altperl/slonik_store_node.pl -u -w -r1.2 -r1.2.2.1
--- tools/altperl/slonik_store_node.pl
+++ tools/altperl/slonik_store_node.pl
@@ -39,26 +39,25 @@
die $USAGE;
}
-my $FILE="/tmp/store_node.$$";
+my $slonik = '';
-open(SLONIK, ">", $FILE);
-print SLONIK genheader();
+$slonik .= genheader();
# STORE NODE
-print SLONIK "\n# STORE NODE\n";
+$slonik .= "\n# STORE NODE\n";
my ($dbname, $dbhost) = ($DBNAME[$node], $HOST[$node]);
-print SLONIK " store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
-print SLONIK " echo 'Set up replication nodes';\n";
+$slonik .= " store node (id = $node, event node = $MASTERNODE, comment = 'Node $node - $dbname\@$dbhost');\n";
+$slonik .= " echo 'Set up replication nodes';\n";
# STORE PATH
-print SLONIK "\n# STORE PATH\n";
+$slonik .= "\n# STORE PATH\n";
my @COST;
my @VIA;
my @PATH;
generate_listen_paths();
-print SLONIK " echo 'Next: configure paths for each node/origin';\n";
+$slonik .= " echo 'Next: configure paths for each node/origin';\n";
foreach my $nodea (@NODES) {
my $dsna = $DSN[$nodea];
foreach my $nodeb (@NODES) {
@@ -68,21 +67,21 @@
my $providerba = $VIA[$nodea][$nodeb];
my $providerab = $VIA[$nodeb][$nodea];
if (!$printed[$nodea][$nodeb] and $providerab == $nodea) {
- print SLONIK " store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
+ $slonik .= " store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
$printed[$nodea][$nodeb] = "done";
}
if (!$printed[$nodeb][$nodea] and $providerba == $nodea) {
- print SLONIK " store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
+ $slonik .= " store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
$printed[$nodeb][$nodea] = "done";
}
}
}
}
-print SLONIK " echo 'Replication nodes prepared';\n";
-print SLONIK " echo 'Please start a slon replication daemon for each node';\n";
-close SLONIK;
-run_slonik_script($FILE);
+$slonik .= " echo 'Replication nodes prepared';\n";
+$slonik .= " echo 'Please start a slon replication daemon for each node';\n";
+
+run_slonik_script($slonik, 'STORE NODE');
report_on_paths();
sub generate_listen_paths {
Index: slonik_init_cluster.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_init_cluster.pl,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -Ltools/altperl/slonik_init_cluster.pl -Ltools/altperl/slonik_init_cluster.pl -u -w -r1.1.4.1 -r1.1.4.2
--- tools/altperl/slonik_init_cluster.pl
+++ tools/altperl/slonik_init_cluster.pl
@@ -61,20 +61,29 @@
my $providerba = $VIA[$nodea][$nodeb];
my $providerab = $VIA[$nodeb][$nodea];
if (!$printed[$nodea][$nodeb] and $providerab == $nodea) {
- print SLONIK " store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
+ $slonik .= " store path (server = $nodea, client = $nodeb, conninfo = '$dsna');\n";
$printed[$nodea][$nodeb] = "done";
}
if (!$printed[$nodeb][$nodea] and $providerba == $nodea) {
- print SLONIK " store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
+ $slonik .= " store path (server = $nodeb, client = $nodea, conninfo = '$dsnb');\n";
$printed[$nodeb][$nodea] = "done";
}
}
}
}
+# STORE LISTEN
+print SLONIK "\n# STORE LISTEN\n";
+foreach my $origin (@NODES) {
+ my $dsna = $DSN[$origin];
+ foreach my $receiver (@NODES) {
+ if ($origin != $receiver) {
+ my $provider = $VIA[$origin][$receiver];
+ print SLONIK " store listen (origin = $origin, receiver = $receiver, provider = $provider);\n";
+ }
+ }
+}
print SLONIK " echo 'Replication nodes prepared';\n";
print SLONIK " echo 'Please start a slon replication daemon for each node';\n";
close SLONIK;
run_slonik_script($FILE);
-
-
Index: slonik_execute_script.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_execute_script.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_execute_script.pl -Ltools/altperl/slonik_execute_script.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_execute_script.pl
+++ tools/altperl/slonik_execute_script.pl
@@ -4,6 +4,7 @@
# Copyright 2004 Afilias Canada
use Getopt::Long;
+use File::Temp qw(tempfile);
# Defaults
$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
@@ -14,6 +15,10 @@
# the get_set function.
$node = 0;
+# temp file variable for script handling
+my $filename = '';
+my $fh = undef;
+
# Read command-line options
GetOptions("config=s" => \$CONFIG_FILE,
"help" => \$SHOW_USAGE,
@@ -69,9 +74,7 @@
}
elsif ($SCRIPT_ARG) {
# Put the script into a file
- $file = "/tmp/execute_script.sql.$$";
- my $fh;
- open $fh, ">", $file;
+ ($fh, $filename) = tempfile();
print $fh $SCRIPT_ARG;
close $fh;
}
@@ -80,13 +83,13 @@
die $USAGE;
}
-my $FILE="/tmp/gensql.$$";
-open(SLONIK, ">", $FILE);
-print SLONIK genheader();
-print SLONIK " execute script (\n";
-print SLONIK " set id = $set,\n";
-print SLONIK " filename = '$file',\n";
-print SLONIK " event node = $node\n";
-print SLONIK " );\n";
-close SLONIK;
-run_slonik_script($FILE);
+my $slonik = '';
+
+$slonik .= genheader();
+$slonik .= " execute script (\n";
+$slonik .= " set id = $set,\n";
+$slonik .= " filename = '$filename',\n";
+$slonik .= " event node = $node\n";
+$slonik .= " );\n";
+
+run_slonik_script($slonik, 'EXECUTE SCRIPT');
Index: slonik_move_set.pl
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/tools/altperl/slonik_move_set.pl,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -Ltools/altperl/slonik_move_set.pl -Ltools/altperl/slonik_move_set.pl -u -w -r1.1 -r1.1.4.1
--- tools/altperl/slonik_move_set.pl
+++ tools/altperl/slonik_move_set.pl
@@ -51,14 +51,15 @@
die $USAGE;
}
-open(SLONIK, ">", "/tmp/slonik.$$");
-print SLONIK genheader();
-print SLONIK " echo 'Locking down set $set on node $node1';\n";
-print SLONIK " lock set (id = $set, origin = $node1);\n";
-print SLONIK " echo 'Locked down - moving it';\n";
-print SLONIK " move set (id = $set, old origin = $node1, new origin = $node2);\n";
-print SLONIK " echo 'Replication set $set moved from node $node1 to $node2. Remember to';\n";
-print SLONIK " echo 'update your configuration file, if necessary, to note the new location';\n";
-print SLONIK " echo 'for the set.';\n";
-close SLONIK;
-run_slonik_script("/tmp/slonik.$$");
+my $slonik = '';
+
+$slonik .= genheader();
+$slonik .= " echo 'Locking down set $set on node $node1';\n";
+$slonik .= " lock set (id = $set, origin = $node1);\n";
+$slonik .= " echo 'Locked down - moving it';\n";
+$slonik .= " move set (id = $set, old origin = $node1, new origin = $node2);\n";
+$slonik .= " echo 'Replication set $set moved from node $node1 to $node2. Remember to';\n";
+$slonik .= " echo 'update your configuration file, if necessary, to note the new location';\n";
+$slonik .= " echo 'for the set.';\n";
+
+run_slonik_script($slonik, 'MOVE SET');
- Previous message: [Slony1-commit] By cbbrowne: Per Bernd Helmle, changing altperl scripts to not use
- Next message: [Slony1-commit] By cbbrowne: Use SLON_FATAL rather than FATAL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list