summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Vyatta/ConfigMgmt.pm2
-rwxr-xr-xscripts/vyatta-commit-revs.pl3
-rwxr-xr-xscripts/vyatta-config-mgmt.pl13
3 files changed, 13 insertions, 5 deletions
diff --git a/lib/Vyatta/ConfigMgmt.pm b/lib/Vyatta/ConfigMgmt.pm
index 1120fa4..60fce44 100644
--- a/lib/Vyatta/ConfigMgmt.pm
+++ b/lib/Vyatta/ConfigMgmt.pm
@@ -30,7 +30,7 @@ our @EXPORT = qw(cm_commit_add_log cm_commit_get_log cm_get_archive_dir
cm_get_lr_conf_file cm_get_lr_state_file
cm_get_commit_hook_dir cm_write_file cm_read_file
cm_commit_get_file cm_commit_get_file_name
- cm_get_num_revs cm_get_last_commit_file
+ cm_get_max_revs cm_get_num_revs cm_get_last_commit_file
cm_get_last_push_file);
use base qw(Exporter);
diff --git a/scripts/vyatta-commit-revs.pl b/scripts/vyatta-commit-revs.pl
index 7749a52..76937d1 100755
--- a/scripts/vyatta-commit-revs.pl
+++ b/scripts/vyatta-commit-revs.pl
@@ -35,7 +35,6 @@ use lib '/opt/vyatta/share/perl5/';
use Vyatta::Config;
use Vyatta::ConfigMgmt;
use File::Compare;
-use File::Copy;
#
# main
@@ -56,7 +55,7 @@ system("$cmd > $tmp_config_file");
if (compare($tmp_config_file, $last_commit_file) == 0) {
exit 0;
}
-move($tmp_config_file, "$archive_dir/config.boot");
+system("sudo mv $tmp_config_file $archive_dir/config.boot");
system("sudo logrotate -f -s $lr_state_file $lr_conf_file");
my ($user) = getpwuid($<);
cm_commit_add_log($user, 'cli', $ARGV[0]);
diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl
index d9e5052..c616fdb 100755
--- a/scripts/vyatta-config-mgmt.pl
+++ b/scripts/vyatta-config-mgmt.pl
@@ -142,7 +142,8 @@ if ($action eq 'update-revs') {
}
if (! -e $archive_dir) {
system("sudo mkdir $archive_dir");
- system("sudo chown vyatta:vyattacfg $archive_dir");
+ system("sudo chgrp vyattacfg $archive_dir");
+ system("sudo chmod 775 $archive_dir");
}
my $lr_conf = "$config_file {\n";
$lr_conf .= "\t rotate $revs\n";
@@ -154,9 +155,12 @@ if ($action eq 'update-revs') {
my $num_revs = cm_get_num_revs();
if ($num_revs == 0) {
# store a baseline config
+ system("sudo touch $archive_dir/commits");
+ system("sudo chgrp vyattacfg $archive_dir/commits");
+ system("sudo chmod 664 $archive_dir/commits");
system("$commit_revs_script baseline config.boot");
- system("sudo chown vyatta:vyattacfg $archive_dir/*");
}
+ print "done\n";
exit 0;
}
exit 0;
@@ -164,6 +168,10 @@ if ($action eq 'update-revs') {
if ($action eq 'show-commit-log') {
print "show-commit-log\n" if $debug;
+ my $max_revs = cm_get_max_revs();
+ if (!defined $max_revs or $max_revs <= 0) {
+ print "commit-revisions is not configured.\n\n";
+ }
my @log = cm_commit_get_log();
foreach my $line (@log) {
print $line;
@@ -174,6 +182,7 @@ if ($action eq 'show-commit-log') {
if ($action eq 'show-commit-file') {
die "Error: no revnum" if ! defined $revnum;
print "show-commit-file [$revnum]\n" if $debug;
+ check_valid_rev($revnum);
my $file = cm_commit_get_file($revnum);
print $file;
}