summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2011-05-24 15:04:08 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2011-05-24 15:04:08 -0700
commitc28add8e387cbafb5fb4774fa0f12ee5a3e5fec6 (patch)
treec3607bc1c9a513e2e540503a307f8e82c2528760
parentc77ec351d1dcb2816d3f24875c5dcc22b8f5ee10 (diff)
downloadvyatta-config-mgmt-c28add8e387cbafb5fb4774fa0f12ee5a3e5fec6.tar.gz
vyatta-config-mgmt-c28add8e387cbafb5fb4774fa0f12ee5a3e5fec6.zip
simplify commit-archive implementation
-rwxr-xr-xscripts/vyatta-config-mgmt.pl18
-rw-r--r--templates-cfg/system/config-management/commit-archive/location/node.def13
-rw-r--r--templates-cfg/system/config-management/commit-archive/node.def4
3 files changed, 8 insertions, 27 deletions
diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl
index d125e36..5ec227c 100755
--- a/scripts/vyatta-config-mgmt.pl
+++ b/scripts/vyatta-config-mgmt.pl
@@ -144,27 +144,17 @@ die "Error: no action" if ! defined $action;
my ($cmd, $rc) = ('', 1);
-if ($action eq 'add-uri') {
- print "add-uri\n" if $debug;
+if ($action eq 'update-uri') {
+ print "update-uri\n" if $debug;
my $config = new Vyatta::Config;
$config->setLevel('system config-management commit-archive');
my @uris = $config->returnValues('location');
my $link = get_link($commit_uri_script);
- if (scalar(@uris) >= 1 and ! -e $link) {
+ if (scalar(@uris) > 0 and ! -e $link) {
print "add link [$link]\n" if $debug;
$rc = system("ln -s $commit_uri_script $link");
exit $rc;
- }
- exit 0;
-}
-
-if ($action eq 'del-uri') {
- print "del-uri\n" if $debug;
- my $config = new Vyatta::Config;
- $config->setLevel('system config-management commit-archive');
- my @uris = $config->returnValues('location');
- if (scalar(@uris) <= 0) {
- my $link = get_link($commit_uri_script);
+ } elsif (scalar(@uris) < 1 and -e $link) {
print "remove link [$link]\n" if $debug;
$rc = system("rm -f $link");
exit $rc;
diff --git a/templates-cfg/system/config-management/commit-archive/location/node.def b/templates-cfg/system/config-management/commit-archive/location/node.def
index ff0d946..c58b3b1 100644
--- a/templates-cfg/system/config-management/commit-archive/location/node.def
+++ b/templates-cfg/system/config-management/commit-archive/location/node.def
@@ -1,5 +1,4 @@
multi:
-priority: 400
type: txt
help: Commit archive location
@@ -7,18 +6,8 @@ syntax:expression: exec "/opt/vyatta/sbin/vyatta-config-mgmt.pl \
--action=valid-uri \
--uri=\"$VAR(@)\" "; "Invalid URI"
-create: if [ "$COMMIT_SIBLING_POSITION" = "LAST" ] || \
- [ "$COMMIT_SIBLING_POSITION" = "FIRSTLAST" ] ; then
- sudo ${vyatta_sbindir}/vyatta-config-mgmt.pl --action=add-uri
- fi;
-
-delete: if [ "$COMMIT_SIBLING_POSITION" = "LAST" ] || \
- [ "$COMMIT_SIBLING_POSITION" = "FIRSTLAST" ] ; then
- sudo ${vyatta_sbindir}/vyatta-config-mgmt.pl --action=del-uri
- fi;
-
val_help: <uri> ; Uniform Resource Identifier
comp_help:
"scp://<user>:<passwd>@<host>/<dir>"
"ftp://<user>:<passwd>@<host>/<dir>"
- "tftp://<host>/<dir>" \ No newline at end of file
+ "tftp://<host>/<dir>"
diff --git a/templates-cfg/system/config-management/commit-archive/node.def b/templates-cfg/system/config-management/commit-archive/node.def
index f4414ab..3587517 100644
--- a/templates-cfg/system/config-management/commit-archive/node.def
+++ b/templates-cfg/system/config-management/commit-archive/node.def
@@ -1 +1,3 @@
-help: Commit archival settings \ No newline at end of file
+priority: 400
+help: Commit archival settings
+end: sudo ${vyatta_sbindir}/vyatta-config-mgmt.pl --action=update-uri