summaryrefslogtreecommitdiff
path: root/scripts
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
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')
-rwxr-xr-xscripts/vyatta-commit-push.pl18
-rwxr-xr-xscripts/vyatta-commit-revs.pl8
-rwxr-xr-xscripts/vyatta-config-mgmt.pl6
3 files changed, 26 insertions, 6 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;
diff --git a/scripts/vyatta-commit-revs.pl b/scripts/vyatta-commit-revs.pl
index edf0845..7749a52 100755
--- a/scripts/vyatta-commit-revs.pl
+++ b/scripts/vyatta-commit-revs.pl
@@ -35,6 +35,7 @@ use lib '/opt/vyatta/share/perl5/';
use Vyatta::Config;
use Vyatta::ConfigMgmt;
use File::Compare;
+use File::Copy;
#
# main
@@ -48,13 +49,14 @@ my $tmp_config_file = "/tmp/config.boot.$$";
if (! -d $archive_dir) {
system("sudo mkdir $archive_dir");
+ system("sudo chown vyatta:vyattacfg $archive_dir");
}
-
-system("/opt/vyatta/sbin/vyatta-save-config.pl $tmp_config_file > /dev/null");
+my $cmd = 'cli-shell-api showCfg --show-active-only';
+system("$cmd > $tmp_config_file");
if (compare($tmp_config_file, $last_commit_file) == 0) {
exit 0;
}
-system("sudo mv $tmp_config_file $archive_dir/config.boot");
+move($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 94b9b57..d9e5052 100755
--- a/scripts/vyatta-config-mgmt.pl
+++ b/scripts/vyatta-config-mgmt.pl
@@ -151,6 +151,12 @@ if ($action eq 'update-revs') {
$lr_conf .= "\t copy \n";
$lr_conf .= "}\n";
cm_write_file($lr_conf_file, $lr_conf);
+ my $num_revs = cm_get_num_revs();
+ if ($num_revs == 0) {
+ # store a baseline config
+ system("$commit_revs_script baseline config.boot");
+ system("sudo chown vyatta:vyattacfg $archive_dir/*");
+ }
exit 0;
}
exit 0;