summaryrefslogtreecommitdiff
path: root/scripts/vyatta-commit-push.pl
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2010-11-05 17:56:37 -0700
committerStig Thormodsrud <stig@vyatta.com>2010-11-05 17:56:37 -0700
commit266ae832374d6231a0a662776c30ec597c6925aa (patch)
tree9b46ef4260cb4319eb13b21fdf56ca5af4c1fd7b /scripts/vyatta-commit-push.pl
parenta60321f3b38c93b200ff2705eebd4d274cda895d (diff)
downloadvyatta-config-mgmt-266ae832374d6231a0a662776c30ec597c6925aa.tar.gz
vyatta-config-mgmt-266ae832374d6231a0a662776c30ec597c6925aa.zip
Fixes for config-mgmt.
- fix permission problems - remove link on disable of commit-revisions. - don't push if file hasn't changed or on boot - save a baseline config when 1st starting the feature.
Diffstat (limited to 'scripts/vyatta-commit-push.pl')
-rwxr-xr-xscripts/vyatta-commit-push.pl18
1 files changed, 15 insertions, 3 deletions
diff --git a/scripts/vyatta-commit-push.pl b/scripts/vyatta-commit-push.pl
index da6c29e..c375f27 100755
--- a/scripts/vyatta-commit-push.pl
+++ b/scripts/vyatta-commit-push.pl
@@ -33,8 +33,11 @@ use warnings;
use lib '/opt/vyatta/share/perl5/';
use Vyatta::Config;
+use Vyatta::ConfigMgmt;
use POSIX;
use File::Basename;
+use File::Compare;
+use File::Copy;
use URI;
use WWW::Curl::Easy;
@@ -50,10 +53,18 @@ if (scalar(@uris) < 1) {
exit 0;
}
-my $upload_file = '/opt/vyatta/etc/config/config.boot';
+my $last_push_file = cm_get_last_push_file();
+my $tmp_push_file = "/tmp/config.boot-push.$$";
+
+my $cmd = 'cli-shell-api showCfg --show-active-only';
+system("$cmd > $tmp_push_file");
+
+if (-e $last_push_file and compare($last_push_file, $tmp_push_file) == 0) {
+ exit 0;
+}
my $timestamp = strftime("_%Y%m%d_%H%M%S", localtime);
-my $save_file = basename($upload_file) . $timestamp;
+my $save_file = basename($tmp_push_file) . $timestamp;
print "Archiving config...\n";
foreach my $uri (@uris) {
@@ -70,7 +81,7 @@ foreach my $uri (@uris) {
$remote .= "$scheme://$host";
$remote .= "$path" if defined $path;
print " $remote ";
- open(my $FILE, '<', $upload_file) or die "Error: read $!";
+ open(my $FILE, '<', $tmp_push_file) or die "Error: read $!";
my $curl = new WWW::Curl::Easy;
$curl->setopt(CURLOPT_NOPROGRESS, 1);
$curl->setopt(CURLOPT_URL, "$uri/$save_file");
@@ -84,5 +95,6 @@ foreach my $uri (@uris) {
print "Failed: " . $curl->strerror($retcode) . "\n";
}
}
+move($tmp_push_file, $last_push_file);
exit 0;