diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/VyattaConfigOutput.pm | 43 | ||||
-rwxr-xr-x | scripts/vyatta-load-config.pl | 13 |
2 files changed, 46 insertions, 10 deletions
diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm index 2766b64..5358c21 100755 --- a/scripts/VyattaConfigOutput.pm +++ b/scripts/VyattaConfigOutput.pm @@ -133,8 +133,12 @@ sub displayValues { $nval = "\"$nval\""; } } + + my %cnodes = $config->listNodeStatus(); + my @cnames = sort keys %cnodes; + if (defined($simple_show)) { - if (!defined($default) || $default ne $oval || $show_all) { + if (!$cnodes{'def'} || $show_all) { if ($is_password && $hide_password) { $oval = $HIDE_PASSWORD; } @@ -155,7 +159,7 @@ sub displayValues { $diff = '>'; } } - if (!defined($default) || $default ne $value || $show_all) { + if (!$cnodes{'def'} || $show_all) { if ($is_password && $hide_password) { $value = $HIDE_PASSWORD; } @@ -186,9 +190,12 @@ sub displayDeletedOrigChildren { my $is_tag = $config->isTagNode([ @cur_path, $child ]); $config->setLevel(join ' ', (@cur_path, $child)); my @cnames = sort $config->listOrigNodes(); - if ($#cnames == 0 && $cnames[0] eq 'node.val') { + + if ($cnames[0] eq 'node.val') { displayValues([ @cur_path, $child ], $prefix, $child, $dont_show_as_deleted); + } elsif ($cnames[0] eq 'def') { + #ignore } elsif (scalar($#cnames) >= 0) { if ($is_tag) { @cnames = sort versioncmp @cnames; @@ -242,7 +249,20 @@ sub displayChildren { $config->setLevel(join ' ', (@cur_path, $child)); my %cnodes = $config->listNodeStatus(); my @cnames = sort keys %cnodes; - if ($#cnames == 0 && $cnames[0] eq 'node.val') { + + #if node.val exists and ct == 0 w/o def or ct ==1 w/ def + my $leaf = 0; + if ($cnodes{'def'}) { + if ($#cnames == 1 && $cnodes{'node.val'}) { + $leaf = 1; + } + } else { + if ($#cnames == 0 && $cnodes{'node.val'}) { + $leaf = 1; + } + } + + if ($leaf == 1) { displayValues([ @cur_path, $child ], $prefix, $child); } elsif (scalar($#cnames) >= 0) { if ($is_tag) { @@ -309,7 +329,20 @@ sub outputNewConfig { my %rnodes = $config->listNodeStatus(); if (scalar(keys %rnodes) > 0) { my @rn = keys %rnodes; - if ($#rn == 0 && $rn[0] eq 'node.val') { + + #if node.val exists and ct == 0 w/o def or ct ==1 w/ def + my $leaf = 0; + if ($rnodes{'def'}) { + if ($#rn == 1 && $rnodes{'node.val'}) { + $leaf = 1; + } + } else { + if ($#rn == 0 && $rnodes{'node.val'}) { + $leaf = 1; + } + } + + if ($leaf == 1) { # this is a leaf value-node displayValues([ @_ ], '', $_[$#_]); } else { diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl index 05323e3..9513ffa 100755 --- a/scripts/vyatta-load-config.pl +++ b/scripts/vyatta-load-config.pl @@ -28,16 +28,19 @@ use VyattaConfigLoad; my $etcdir = $ENV{vyatta_sysconfdir}; my $sbindir = $ENV{vyatta_sbindir}; my $bootpath = $etcdir . "/config"; +my $load_file = $bootpath . "/config.boot"; -if ($#ARGV != 0) { +if ($#ARGV > 0) { print "Usage: load <config_file_name>\n"; exit 1; } -my $load_file = $ARGV[0]; -if (!($load_file =~ /^\//)) { - # relative path - $load_file = "$bootpath/$load_file"; +if (defined($ARGV[0])) { + $load_file = $ARGV[0]; + if (!($load_file =~ /^\//)) { + # relative path + $load_file = "$bootpath/$load_file"; + } } if (!open(CFG, "<$load_file")) { |