summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/bash_completion.d/20vyatta-cfg15
-rw-r--r--scripts/VyattaConfig.pm7
-rwxr-xr-xscripts/VyattaConfigOutput.pm18
-rwxr-xr-xscripts/vyatta-output-config.pl4
-rwxr-xr-xscripts/vyatta-save-config.pl4
5 files changed, 38 insertions, 10 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg
index b4449c8..26a4e72 100644
--- a/etc/bash_completion.d/20vyatta-cfg
+++ b/etc/bash_completion.d/20vyatta-cfg
@@ -45,13 +45,22 @@ done
show ()
{
- eval "${vyatta_sbindir}/vyatta-output-config.pl \
- \${VYATTA_EDIT_LEVEL//\// } $@"
+ local show_all=''
+ local -a args=()
+ for arg in "$@"; do
+ if [ "$arg" == "-all" ]; then
+ show_all='-all'
+ else
+ args[${#args[@]}]="$arg"
+ fi
+ done
+ eval "${vyatta_sbindir}/vyatta-output-config.pl ${show_all}\
+ \${VYATTA_EDIT_LEVEL//\// } ${args[@]}"
}
save ()
{
- eval "${vyatta_sbindir}/vyatta-save-config.pl $@"
+ eval "sudo ${vyatta_sbindir}/vyatta-save-config.pl $@"
}
declare vyatta_cfg_prompt_level=''
diff --git a/scripts/VyattaConfig.pm b/scripts/VyattaConfig.pm
index e9a1f97..1645be6 100644
--- a/scripts/VyattaConfig.pm
+++ b/scripts/VyattaConfig.pm
@@ -463,7 +463,7 @@ sub hasTmplChildren {
sub parseTmpl {
my $self = shift;
my $cfg_path_ref = shift;
- my ($is_multi, $is_text) = (0, 0);
+ my ($is_multi, $is_text, $default) = (0, 0, undef);
my $tpath = $self->getTmplPath($cfg_path_ref);
if (! -r "$tpath/node.def") {
return ($is_multi, $is_text);
@@ -476,9 +476,12 @@ sub parseTmpl {
if (/^type:\s+txt\s*$/) {
$is_text = 1;
}
+ if (/^default:\s+(\S+)\s*$/) {
+ $default = $1;
+ }
}
close TMPL;
- return ($is_multi, $is_text);
+ return ($is_multi, $is_text, $default);
}
###### misc functions ######
diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm
index 874ed55..f16007d 100755
--- a/scripts/VyattaConfigOutput.pm
+++ b/scripts/VyattaConfigOutput.pm
@@ -13,6 +13,14 @@ use strict;
use lib '/opt/vyatta/share/perl5/';
use VyattaConfig;
+# whether to show default values
+my $show_all = 0;
+sub set_show_all {
+ if (shift) {
+ $show_all = 1;
+ }
+}
+
my $config = undef;
# $0: array ref for path
@@ -25,7 +33,7 @@ sub displayValues {
my $prefix = $_[1];
my $name = $_[2];
my $simple_show = $_[3];
- my ($is_multi, $is_text) = $config->parseTmpl(\@cur_path);
+ my ($is_multi, $is_text, $default) = $config->parseTmpl(\@cur_path);
$config->setLevel(join ' ', @cur_path);
if ($is_multi) {
my @ovals = $config->returnOrigValues('');
@@ -74,7 +82,9 @@ sub displayValues {
}
}
if (defined($simple_show)) {
- print "$prefix$name: $oval\n";
+ if (!defined($default) || $default ne $oval || $show_all) {
+ print "$prefix$name: $oval\n";
+ }
return;
}
my $value = $nval;
@@ -90,7 +100,9 @@ sub displayValues {
$diff = '>';
}
}
- print "$diff$prefix$name: $value\n";
+ if (!defined($default) || $default ne $value || $show_all) {
+ print "$diff$prefix$name: $value\n";
+ }
}
}
diff --git a/scripts/vyatta-output-config.pl b/scripts/vyatta-output-config.pl
index 7f3ea83..8b25ec2 100755
--- a/scripts/vyatta-output-config.pl
+++ b/scripts/vyatta-output-config.pl
@@ -4,6 +4,10 @@ use strict;
use lib "/opt/vyatta/share/perl5/";
use VyattaConfigOutput;
+if ($ARGV[0] eq '-all') {
+ shift;
+ VyattaConfigOutput::set_show_all(1);
+}
VyattaConfigOutput::outputNewConfig(@ARGV);
exit 0;
diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl
index 300a5fe..26b8eec 100755
--- a/scripts/vyatta-save-config.pl
+++ b/scripts/vyatta-save-config.pl
@@ -4,8 +4,7 @@ use strict;
use lib "/opt/vyatta/share/perl5/";
use VyattaConfigOutput;
-my $sbindir = $ENV{vyatta_sbindir};
-my $etcdir = $ENV{vyatta_sysconfdir};
+my $etcdir = "/opt/vyatta/etc";
my $bootfile = '';
if (-r "$etcdir/bootfile_path") {
$bootfile = `cat $etcdir/bootfile_path`;
@@ -35,6 +34,7 @@ if (! open(SAVE, ">$save_file")) {
print "Saving configuration to '$save_file'...";
select SAVE;
+VyattaConfigOutput::set_show_all(1);
VyattaConfigOutput::outputActiveConfig();
my $version_str = `/opt/vyatta/sbin/vyatta_current_conf_ver.pl`;
print SAVE $version_str;