diff options
author | Michael Larson <slioch@slioch.vyatta.com> | 2010-05-14 13:47:21 -0700 |
---|---|---|
committer | Michael Larson <slioch@slioch.vyatta.com> | 2010-05-14 13:47:21 -0700 |
commit | d36d0a6ea76d443c5e4072401eaa9dbf563c74bd (patch) | |
tree | 9daed3e19d3d5b8231a9894891ac00d4df9b9c3a /scripts/vyatta-config-loader.pl | |
parent | 91bb77e328c9cad994609aeeccb33971eca1486f (diff) | |
download | vyatta-cfg-d36d0a6ea76d443c5e4072401eaa9dbf563c74bd.tar.gz vyatta-cfg-d36d0a6ea76d443c5e4072401eaa9dbf563c74bd.zip |
initial checkin of comment feature for cli.
/* to create a comment */
> comment [PATH-TO-NODE] "my comments"
/* to delete a comment */
> comment [PATH-TO-NODE] ""
Diffstat (limited to 'scripts/vyatta-config-loader.pl')
-rwxr-xr-x | scripts/vyatta-config-loader.pl | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/scripts/vyatta-config-loader.pl b/scripts/vyatta-config-loader.pl index 7a3df2b..b8e594e 100755 --- a/scripts/vyatta-config-loader.pl +++ b/scripts/vyatta-config-loader.pl @@ -46,7 +46,7 @@ sub restore_fds { } # get a list of all config statement in the startup config file -my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0]); +my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0],'true'); if (scalar(@all_nodes) == 0) { # no config statements restore_fds(); @@ -72,6 +72,32 @@ foreach (@all_nodes) { my ($path_ref, $rank) = @$_; my @pr = @$path_ref; + if (@pr[0] =~ /^comment$/) { + my $ct = 0; + my $rel_path; + foreach my $rp (@pr[1..$#pr]) { + $ct++; + my $tmp_path = $rel_path . "/" . $rp; + my $node_path = "/opt/vyatta/share/vyatta-cfg/templates/" . $tmp_path . "/node.def"; + if ($rp eq '"') { + last; + } + elsif ($rp eq '""') { + last; + } + elsif (!-e $node_path) { + #pop this element + delete @pr[$ct]; + last; + } + $rel_path = $tmp_path; + } + + my $comment_cmd = "$CWRAPPER " . join(" ",@pr) ; + `$comment_cmd`; + next; + } + if (@pr[0] eq '!') { @pr = @pr[1..$#pr]; my $deactivate_cmd = "$CWRAPPER deactivate " . (join ' ', @pr) . " 1>/dev/null"; |