diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2010-11-05 15:19:21 -0700 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2010-11-05 15:19:21 -0700 |
commit | a60321f3b38c93b200ff2705eebd4d274cda895d (patch) | |
tree | 86b3d04e5f6f983dce8f6f2a1059a278632bb9b1 /scripts | |
parent | 9f32a72037fdc5cb3abbfa97adb4f612920847dc (diff) | |
download | vyatta-config-mgmt-a60321f3b38c93b200ff2705eebd4d274cda895d.tar.gz vyatta-config-mgmt-a60321f3b38c93b200ff2705eebd4d274cda895d.zip |
Don't save a rev if the file hasn't changed.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-commit-revs.pl | 13 | ||||
-rwxr-xr-x | scripts/vyatta-config-mgmt.pl | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/scripts/vyatta-commit-revs.pl b/scripts/vyatta-commit-revs.pl index 7ae34ad..edf0845 100755 --- a/scripts/vyatta-commit-revs.pl +++ b/scripts/vyatta-commit-revs.pl @@ -34,21 +34,26 @@ use lib '/opt/vyatta/share/perl5/'; use Vyatta::Config; use Vyatta::ConfigMgmt; +use File::Compare; # # main # -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(); +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(); +my $last_commit_file = cm_get_last_commit_file(); +my $tmp_config_file = "/tmp/config.boot.$$"; if (! -d $archive_dir) { system("sudo mkdir $archive_dir"); } -my $tmp_config_file = "/tmp/config.boot.$$"; system("/opt/vyatta/sbin/vyatta-save-config.pl $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"); system("sudo logrotate -f -s $lr_state_file $lr_conf_file"); my ($user) = getpwuid($<); diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl index 46d57e9..94b9b57 100755 --- a/scripts/vyatta-config-mgmt.pl +++ b/scripts/vyatta-config-mgmt.pl @@ -142,11 +142,13 @@ if ($action eq 'update-revs') { } if (! -e $archive_dir) { system("sudo mkdir $archive_dir"); + system("sudo chown vyatta:vyattacfg $archive_dir"); } 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 .= "\t copy \n"; $lr_conf .= "}\n"; cm_write_file($lr_conf_file, $lr_conf); exit 0; |