summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2010-11-02 17:39:29 -0700
committerStig Thormodsrud <stig@vyatta.com>2010-11-02 17:39:29 -0700
commit8d874b22fd50dc3cfcd971c3d85804ffccb18789 (patch)
tree18caae2b79952cf56845578f8f9fc37a68447387 /scripts
parent0d5c217313f8ac47944bd50d800c2bd44b4a833b (diff)
downloadvyatta-config-mgmt-8d874b22fd50dc3cfcd971c3d85804ffccb18789.tar.gz
vyatta-config-mgmt-8d874b22fd50dc3cfcd971c3d85804ffccb18789.zip
Add revision compare functionality
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-config-mgmt.pl40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl
index c074793..46d57e9 100755
--- a/scripts/vyatta-config-mgmt.pl
+++ b/scripts/vyatta-config-mgmt.pl
@@ -55,12 +55,21 @@ sub get_link {
return $link;
}
+sub check_valid_rev {
+ my ($rev) = @_;
+
+ my $num_revs = cm_get_num_revs();
+ return 1 if $rev <= $num_revs;
+ print "Invalid revision [$rev]\n";
+ exit 1;
+}
#
# main
#
my ($action, $uri, $revs, $revnum);
+Getopt::Long::Configure('pass_through');
GetOptions("action=s" => \$action,
"uri=s" => \$uri,
"revs=i" => \$revs,
@@ -136,6 +145,7 @@ if ($action eq 'update-revs') {
}
my $lr_conf = "$config_file {\n";
$lr_conf .= "\t rotate $revs\n";
+ $lr_conf .= "\t start 0\n";
$lr_conf .= "\t compress \n";
$lr_conf .= "}\n";
cm_write_file($lr_conf_file, $lr_conf);
@@ -160,6 +170,36 @@ if ($action eq 'show-commit-file') {
print $file;
}
+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_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("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;
+ } elsif ($args eq 1) {
+ my $rev1 = $ARGV[0];
+ my $rev2 = $ARGV[1];
+ check_valid_rev($rev1);
+ check_valid_rev($rev2);
+ my $filename = cm_commit_get_file_name($rev1);
+ my $filename2 = cm_commit_get_file_name($rev2);
+ my $diff = `zdiff -u $filename2 $filename`;
+ print $diff;
+ }
+}
+
exit $rc;
# end of file