summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorslioch <slioch@eng-140.vyatta.com>2009-05-15 15:29:44 -0700
committerslioch <slioch@eng-140.vyatta.com>2009-05-15 15:29:44 -0700
commitdeb86bf2b27631f66e5ffd849ba45db895dbd091 (patch)
treefd3e5ac07686e42d89f966ec6cffefc764682e98 /scripts
parent902df9b3d0e06f506c4fd26835658f7ead6d7bd0 (diff)
downloadvyatta-cfg-deb86bf2b27631f66e5ffd849ba45db895dbd091.tar.gz
vyatta-cfg-deb86bf2b27631f66e5ffd849ba45db895dbd091.zip
merge option added to load script. "load [configfile] --merge" adds configuration to current
running configuration.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-load-config.pl40
1 files changed, 27 insertions, 13 deletions
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl
index 5c73eb1..4073905 100755
--- a/scripts/vyatta-load-config.pl
+++ b/scripts/vyatta-load-config.pl
@@ -25,6 +25,7 @@ use strict;
use lib "/opt/vyatta/share/perl5/";
use POSIX;
use IO::Prompt;
+use Getopt::Long;
use Sys::Syslog qw(:standard :macros);
use Vyatta::ConfigLoad;
@@ -36,9 +37,20 @@ my $bootpath = $etcdir . "/config";
my $load_file = $bootpath . "/config.boot";
my $url_tmp_file = $bootpath . "/config.boot.$$";
-if ( $#ARGV > 0 ) {
- print "Usage: load <config_file_name>\n";
- exit 1;
+
+sub usage() {
+ print "Usage: $0 --merge=<root>\n";
+ exit 0;
+}
+
+my $merge;
+GetOptions(
+ "merge:s" => \$merge,
+ ) or usage();
+
+my $merge_mode = 'false';
+if (defined $merge) {
+ $merge_mode = 'true';
}
my $mode = 'local';
@@ -164,18 +176,20 @@ if ( scalar( keys %cfg_hier ) == 0 ) {
}
my %cfg_diff = Vyatta::ConfigLoad::getConfigDiff( \%cfg_hier );
-
-my @delete_list = @{ $cfg_diff{'delete'} };
my @set_list = @{ $cfg_diff{'set'} };
-foreach (@delete_list) {
- my ( $cmd_ref, $rank ) = @{$_};
- my @cmd = ( "$sbindir/my_delete", @{$cmd_ref} );
- my $cmd_str = join ' ', @cmd;
- system("$cmd_str");
- if ( $? >> 8 ) {
- $cmd_str =~ s/^$sbindir\/my_//;
- print "\"$cmd_str\" failed\n";
+if ($merge_mode eq 'false') {
+ my @delete_list = @{ $cfg_diff{'delete'} };
+
+ foreach (@delete_list) {
+ my ( $cmd_ref, $rank ) = @{$_};
+ my @cmd = ( "$sbindir/my_delete", @{$cmd_ref} );
+ my $cmd_str = join ' ', @cmd;
+ system("$cmd_str");
+ if ( $? >> 8 ) {
+ $cmd_str =~ s/^$sbindir\/my_//;
+ print "\"$cmd_str\" failed\n";
+ }
}
}