diff options
Diffstat (limited to 'packages/carp_sync_client.php')
-rw-r--r-- | packages/carp_sync_client.php | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/packages/carp_sync_client.php b/packages/carp_sync_client.php index cfe59d4b..2d27501b 100644 --- a/packages/carp_sync_client.php +++ b/packages/carp_sync_client.php @@ -29,32 +29,47 @@ if($config['installedpackages']['carpsettings']['config'] != "") { foreach($config['installedpackages']['carpsettings']['config'] as $carp) { - if($carp['synchronizerules'] <> "" and $carp['synchronizetoip'] <> "" ) { + if($carp['synchronizetoip'] <> "" ) { /* lets sync! */ $synchronizetoip = $carp['synchronizetoip']; - $current_rules_section = backup_config_section("filter"); - $current_nat_section = backup_config_section("nat"); - $current_aliases_section = backup_config_section("aliases"); - /* generate firewall rules xml */ - $fout = fopen("{$g['tmp_path']}/rules_section.txt","w"); - fwrite($fout, $current_rules_section); - fclose($fout); - /* generate nat rules xml */ - $fout = fopen("{$g['tmp_path']}/nat_section.txt","w"); - fwrite($fout, $current_nat_section); - fclose($fout); - /* generate aliases xml */ - $fout = fopen("{$g['tmp_path']}/aliases_section.txt","w"); - fwrite($fout, $current_aliases_section); - fclose($fout); + if($carp['synchronizerules'] <> "") { + $current_rules_section = backup_config_section("filter"); + /* generate firewall rules xml */ + $fout = fopen("{$g['tmp_path']}/rules_section.txt","w"); + fwrite($fout, $current_rules_section); + fclose($fout); + mwexec("/usr/bin/scp {$g['tmp_path']}/rules_section.txt root@{$synchronizetoip}:/tmp/"); + unlink("{$g['tmp_path']}/rules_section.txt"); + } + if($carp['synchronizenat'] <> "") { + $current_nat_section = backup_config_section("nat"); + /* generate nat rules xml */ + $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"); + } + if($carp['synchronizealiases'] <> "") { + $current_aliases_section = backup_config_section("aliases"); + /* generate aliases xml */ + $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"); + } + if($carp['synchronizetrafficshaper'] <> "") { + $current_trafficshaper_section = backup_config_section("shaper"); + /* generate aliases xml */ + $fout = fopen("{$g['tmp_path']}/trafficshaper_section.txt","w"); + fwrite($fout, $current_trafficshaper_section); + fclose($fout); + mwexec("/usr/bin/scp {$g['tmp_path']}/trafficshaper_section.txt root@{$synchronizetoip}:/tmp/"); + unlink("{$g['tmp_path']}/trafficshaper_section.txt"); + } /* copy configuration to remote host */ - mwexec("/usr/bin/scp {$g['tmp_path']}/rules_section.txt root@{$synchronizetoip}:/tmp/"); - mwexec("/usr/bin/scp {$g['tmp_path']}/aliases_section.txt root@{$synchronizetoip}:/tmp/"); - mwexec("/usr/bin/scp {$g['tmp_path']}/nat_section.txt root@{$synchronizetoip}:/tmp/"); mwexec("/usr/bin/ssh {$synchronizetoip} /usr/local/pkg/carp_sync_server.php"); - unlink("{$g['tmp_path']}/rules_section.txt"); - unlink("{$g['tmp_path']}/aliases_section.txt"); - unlink("{$g['tmp_path']}/nat_section.txt"); } } } |