diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-02 17:01:43 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-02 17:01:43 -0700 |
commit | 902f98e233479bb9e8fffa9d158d14739714d48a (patch) | |
tree | d5684cf1dc78d05218b1c8e2a5f522919b9bf2a1 /scripts | |
parent | 0d97c5e0f56a22577abb0a38fec10a06e9b618e8 (diff) | |
download | vyatta-cfg-902f98e233479bb9e8fffa9d158d14739714d48a.tar.gz vyatta-cfg-902f98e233479bb9e8fffa9d158d14739714d48a.zip |
* config-mode "show" command now hides default values.
* add "show -all" command to display all values.
* "save" command saves all values.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/VyattaConfig.pm | 7 | ||||
-rwxr-xr-x | scripts/VyattaConfigOutput.pm | 18 | ||||
-rwxr-xr-x | scripts/vyatta-output-config.pl | 4 | ||||
-rwxr-xr-x | scripts/vyatta-save-config.pl | 4 |
4 files changed, 26 insertions, 7 deletions
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; |