aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2005-03-16 06:13:04 +0000
committerBill Marquette <billm@pfsense.org>2005-03-16 06:13:04 +0000
commit5cfc0cb8368dd8dc6915ae0c9b43d5cb9d46da2d (patch)
tree603f8876ab8ca951bad43ee0938e544250a62f89
parentd6b39ba11516f288d96cd5c35563d871cbb4ba2e (diff)
downloadpfsense-packages-5cfc0cb8368dd8dc6915ae0c9b43d5cb9d46da2d.tar.gz
pfsense-packages-5cfc0cb8368dd8dc6915ae0c9b43d5cb9d46da2d.tar.bz2
pfsense-packages-5cfc0cb8368dd8dc6915ae0c9b43d5cb9d46da2d.zip
Keep the number of scp's to a minimum
-rw-r--r--packages/carp_sync_client.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/packages/carp_sync_client.php b/packages/carp_sync_client.php
index f94a04fe..6a295636 100644
--- a/packages/carp_sync_client.php
+++ b/packages/carp_sync_client.php
@@ -34,14 +34,14 @@ if($already_processed != 1)
if($carp['synchronizetoip'] <> "" ) {
/* lets sync! */
$synchronizetoip = $carp['synchronizetoip'];
+ $files_to_copy = "";
if($carp['synchronizerules'] <> "") {
$current_rules_section = backup_config_section("filter");
/* generate firewall rules xml */
$fout = fopen("{$g['tmp_path']}/filter_section.txt","w");
fwrite($fout, $current_rules_section);
fclose($fout);
- mwexec("/usr/bin/scp {$g['tmp_path']}/filter_section.txt root@{$synchronizetoip}:/tmp/");
- unlink("{$g['tmp_path']}/filter_section.txt");
+ $files_to_copy .= "{$g['tmp_path']}/filter_section.txt";
}
if($carp['synchronizenat'] <> "") {
$current_nat_section = backup_config_section("nat");
@@ -49,8 +49,7 @@ if($already_processed != 1)
$fout = fopen("{$g['tmp_path']}/nat_section.txt","w");
fwrite($fout, $current_nat_section);
fclose($fout);
- mwexec("/usr/bin/scp {$g['tmp_path']}/nat_section.txt root@{$synchronizetoip}:/tmp/");
- unlink("{$g['tmp_path']}/nat_section.txt");
+ $files_to_copy .= " {$g['tmp_path']}/nat_section.txt";
}
if($carp['synchronizealiases'] <> "") {
$current_aliases_section = backup_config_section("aliases");
@@ -58,8 +57,7 @@ if($already_processed != 1)
$fout = fopen("{$g['tmp_path']}/aliases_section.txt","w");
fwrite($fout, $current_aliases_section);
fclose($fout);
- mwexec("/usr/bin/scp {$g['tmp_path']}/aliases_section.txt root@{$synchronizetoip}:/tmp/");
- unlink("{$g['tmp_path']}/aliases_section.txt");
+ $files_to_copy .= " {$g['tmp_path']}/aliases_section.txt";
}
if($carp['synchronizetrafficshaper'] <> "") {
$current_trafficshaper_section = backup_config_section("shaper");
@@ -67,10 +65,18 @@ if($already_processed != 1)
$fout = fopen("{$g['tmp_path']}/shaper_section.txt","w");
fwrite($fout, $current_trafficshaper_section);
fclose($fout);
- mwexec("/usr/bin/scp {$g['tmp_path']}/shaper_section.txt root@{$synchronizetoip}:/tmp/");
- unlink("{$g['tmp_path']}/shaper_section.txt");
+ $files_to_copy .= " {$g['tmp_path']}/shaper_section.txt";
}
/* copy configuration to remote host */
+ mwexec("/usr/bin/scp {$files_to_copy} root@{$synchronizetoip}:/tmp/");
+
+ /* remove extracted config files */
+ unlink_if_exists("{$g['tmp_path']}/filter_section.txt");
+ unlink_if_exists("{$g['tmp_path']}/nat_section.txt");
+ unlink_if_exists("{$g['tmp_path']}/aliases_section.txt");
+ unlink_if_exists("{$g['tmp_path']}/shaper_section.txt");
+
+ /* execute configuration on remote host */
mwexec("/usr/bin/ssh {$synchronizetoip} /usr/local/pkg/carp_sync_server.php");
}
}