From 43ab6976b70ab2247fd9899dcf4507b6b618c7df Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 25 Jul 2019 17:45:18 +0200 Subject: T1543: add source address option for commit archive host connections. --- scripts/vyatta-commit-push.pl | 11 +++++++++-- .../config-management/commit-archive/source-address/node.def | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 templates-cfg/system/config-management/commit-archive/source-address/node.def diff --git a/scripts/vyatta-commit-push.pl b/scripts/vyatta-commit-push.pl index 6edfd10..2a1f495 100755 --- a/scripts/vyatta-commit-push.pl +++ b/scripts/vyatta-commit-push.pl @@ -68,6 +68,13 @@ my $hostname = hostname(); $hostname = 'vyos' if ! defined $hostname; my $save_file = "config.boot-$hostname" . $timestamp; +my $source_addr = $config->returnEffectiveValue('source-address'); +my $src_opt = ""; +if( defined($source_addr) ) { + $src_opt = "--interface $source_addr"; + print("Using source address $source_addr\n"); +} + print "Archiving config...\n"; foreach my $uri (@uris) { my $u = URI->new($uri); @@ -100,13 +107,13 @@ foreach my $uri (@uris) { or die "Cannot open known_hosts: $!"; print $known_hosts "$rsa_key\n"; close($known_hosts); - $cmd = "curl -g -s -S -T $tmp_push_file $uri/$save_file"; + $cmd = "curl $src_opt -g -s -S -T $tmp_push_file $uri/$save_file"; $rc = system($cmd); print "\n"; } } } else { - $cmd = "curl -s -T $tmp_push_file $uri/$save_file"; + $cmd = "curl $src_opt -s -T $tmp_push_file $uri/$save_file"; $rc = system($cmd); } diff --git a/templates-cfg/system/config-management/commit-archive/source-address/node.def b/templates-cfg/system/config-management/commit-archive/source-address/node.def new file mode 100644 index 0000000..a013983 --- /dev/null +++ b/templates-cfg/system/config-management/commit-archive/source-address/node.def @@ -0,0 +1,2 @@ +type: txt +help: Source address or interface for archive server connections -- cgit v1.2.3