diff options
| author | Stig Thormodsrud <stig@vyatta.com> | 2010-11-10 16:42:08 -0800 |
|---|---|---|
| committer | Stig Thormodsrud <stig@vyatta.com> | 2010-11-10 16:42:08 -0800 |
| commit | 4d00261f1e05335a14ec873c99c869c9e9c1374b (patch) | |
| tree | 980f105536f57d99516c14f5d90c5ffdee2a55d9 /scripts/vyatta-commit-revs.pl | |
| parent | 54e206593bbc8aeaa4e49641c4406510ceeee476 (diff) | |
| download | vyatta-config-mgmt-4d00261f1e05335a14ec873c99c869c9e9c1374b.tar.gz vyatta-config-mgmt-4d00261f1e05335a14ec873c99c869c9e9c1374b.zip | |
Fix rollback such that it also goes throught the revisioning.
Diffstat (limited to 'scripts/vyatta-commit-revs.pl')
| -rwxr-xr-x | scripts/vyatta-commit-revs.pl | 22 |
1 files changed, 17 insertions, 5 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]); |
