diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2010-11-18 18:11:43 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2010-11-18 18:11:43 -0800 |
commit | 3468d4f8812b7a2003d845f6f1fda7dfb127617d (patch) | |
tree | a749452aa09773b53924586d66da5a459ae5361d /scripts/vyatta-config-mgmt.pl | |
parent | d9d4044510cd9810c68522ceae26ce011b12dc2c (diff) | |
download | vyatta-config-mgmt-3468d4f8812b7a2003d845f6f1fda7dfb127617d.tar.gz vyatta-config-mgmt-3468d4f8812b7a2003d845f6f1fda7dfb127617d.zip |
Change "compare" command to use cfgShow --show-working-only.
Diffstat (limited to 'scripts/vyatta-config-mgmt.pl')
-rwxr-xr-x | scripts/vyatta-config-mgmt.pl | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl index 95abdb1..440371a 100755 --- a/scripts/vyatta-config-mgmt.pl +++ b/scripts/vyatta-config-mgmt.pl @@ -192,7 +192,6 @@ if ($action eq 'update-revs') { my $cmd = "$commit_revs_script baseline config.boot"; system("sudo sg vyattacfg \"$cmd\""); } - print "done\n"; exit 0; } exit 0; @@ -235,20 +234,31 @@ if ($action eq 'diff') { print "diff\n" if $debug; my $args = $#ARGV; if ($args < 0) { - my $tmp_config_file = "/tmp/config.boot.$$"; + my $tmp_config_file = "/tmp/config.boot.$$"; my $tmp_config_file2 = "/tmp/config.boot2.$$"; - system("cli-shell-api showCfg --show-active-only> $tmp_config_file"); - system("cli-shell-api showCfg > $tmp_config_file2"); - my $diff = `diff -u -w $tmp_config_file2 $tmp_config_file`; - print $diff; + system("cli-shell-api showCfg --show-active-only > $tmp_config_file"); + system("cli-shell-api showCfg --show-working-only > $tmp_config_file2"); + my $diff = `diff -u -w $tmp_config_file $tmp_config_file2`; + if (defined $diff and length($diff) > 0) { + print $diff; + } else { + print "No changes between working and active configurations\n"; + } system("rm $tmp_config_file $tmp_config_file2"); } elsif ($args eq 0) { my $rev1 = $ARGV[0]; check_valid_rev($rev1); - my $filename = cm_commit_get_file_name(0); - my $filename2 = cm_commit_get_file_name($rev1); - my $diff = `zdiff -u $filename2 $filename`; - print $diff; + my $tmp_config_file = "/tmp/config.boot.$$"; + system("cli-shell-api showCfg --show-working-only > $tmp_config_file"); + my $filename1 = cm_commit_get_file_name($rev1); + my $diff = `zdiff -u $filename1 $tmp_config_file`; + if (defined $diff and length($diff) > 0) { + print $diff; + } else { + print "No changes between working and " + . "revision $rev1 configurations\n"; + } + system("rm $tmp_config_file"); } elsif ($args eq 1) { my $rev1 = $ARGV[0]; my $rev2 = $ARGV[1]; |