summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2010-11-10 16:42:08 -0800
committerStig Thormodsrud <stig@vyatta.com>2010-11-10 16:42:08 -0800
commit4d00261f1e05335a14ec873c99c869c9e9c1374b (patch)
tree980f105536f57d99516c14f5d90c5ffdee2a55d9 /scripts
parent54e206593bbc8aeaa4e49641c4406510ceeee476 (diff)
downloadvyatta-config-mgmt-4d00261f1e05335a14ec873c99c869c9e9c1374b.tar.gz
vyatta-config-mgmt-4d00261f1e05335a14ec873c99c869c9e9c1374b.zip
Fix rollback such that it also goes throught the revisioning.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-commit-revs.pl22
-rwxr-xr-xscripts/vyatta-config-mgmt.pl8
2 files changed, 22 insertions, 8 deletions
diff --git a/scripts/vyatta-commit-revs.pl b/scripts/vyatta-commit-revs.pl
index 9630f5a..3f522b5 100755
--- a/scripts/vyatta-commit-revs.pl
+++ b/scripts/vyatta-commit-revs.pl
@@ -35,11 +35,17 @@ use lib '/opt/vyatta/share/perl5/';
use Vyatta::Config;
use Vyatta::ConfigMgmt;
use File::Compare;
+use Getopt::Long;
#
# main
#
+my $rollback;
+Getopt::Long::Configure('pass_through');
+GetOptions("rollback=s" => \$rollback,
+ );
+
my $archive_dir = cm_get_archive_dir();
my $lr_state_file = cm_get_lr_state_file();
my $lr_conf_file = cm_get_lr_conf_file();
@@ -50,12 +56,18 @@ if (! -d $archive_dir) {
system("sudo mkdir $archive_dir");
system("sudo chown vyatta:vyattacfg $archive_dir");
}
-my $cmd = '/opt/vyatta/sbin/vyatta-save-config.pl';
-system("$cmd $tmp_config_file > /dev/null");
-if (compare($tmp_config_file, $last_commit_file) == 0) {
- exit 0;
+if (! defined $rollback) {
+ my $cmd = '/opt/vyatta/sbin/vyatta-save-config.pl';
+ system("$cmd $tmp_config_file > /dev/null");
+ if (compare($tmp_config_file, $last_commit_file) == 0) {
+ exit 0;
+ }
+ system("sudo mv $tmp_config_file $archive_dir/config.boot");
+} else {
+ my $boot_config_file = cm_get_boot_config_file();
+ system("sudo cp $boot_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 a28942a..31ccca9 100755
--- a/scripts/vyatta-config-mgmt.pl
+++ b/scripts/vyatta-config-mgmt.pl
@@ -328,20 +328,22 @@ if ($action eq 'rollback') {
# called internally. If we later expose this to cli
# we'll need to prompt for confirmation.
my @lines = cm_read_file($filename);
- $rollback_config = join("\n", @lines);
+ $rollback_config = join("\n", @lines);
+ $rollback_config .= "\n";
}
if (!defined $method) {
die "Error: must define either revnum or file";
}
my ($user) = getpwuid($<);
- cm_commit_add_log($user, 'rollback', '');
my $boot_config_file = cm_get_boot_config_file();
my $archive_dir = cm_get_archive_dir();
my $last_commit_file = cm_get_last_commit_file();
- system("sudo mv $boot_config_file $archive_dir/config.boot-prerollback");
+ system("sudo cp $boot_config_file $archive_dir/config.boot-prerollback");
cm_write_file($boot_config_file, $rollback_config);
cm_write_file($last_commit_file, $rollback_config); # white lie
+ my $cmd = "$commit_revs_script --rollback=1 rollback/reboot";
+ system("sudo sg vyattacfg \"$cmd\"");
openlog($0, "", LOG_USER);
my $login = getpwuid($<) || "unknown";
syslog("warning", "Rollback reboot requested by $login");