summaryrefslogtreecommitdiff
path: root/scripts/vyatta-config-loader.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/vyatta-config-loader.pl')
-rwxr-xr-xscripts/vyatta-config-loader.pl40
1 files changed, 34 insertions, 6 deletions
diff --git a/scripts/vyatta-config-loader.pl b/scripts/vyatta-config-loader.pl
index 7a3df2b..0aae55b 100755
--- a/scripts/vyatta-config-loader.pl
+++ b/scripts/vyatta-config-loader.pl
@@ -46,7 +46,9 @@ sub restore_fds {
}
# get a list of all config statement in the startup config file
-my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0]);
+my %cfg_hier = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0],'true');
+my @all_nodes = @{ $cfg_hier{'set'} };
+my @deactivate_nodes = @{ $cfg_hier{'deactivate'} };
if (scalar(@all_nodes) == 0) {
# no config statements
restore_fds();
@@ -72,11 +74,30 @@ foreach (@all_nodes) {
my ($path_ref, $rank) = @$_;
my @pr = @$path_ref;
- if (@pr[0] eq '!') {
- @pr = @pr[1..$#pr];
- my $deactivate_cmd = "$CWRAPPER deactivate " . (join ' ', @pr) . " 1>/dev/null";
- system("$deactivate_cmd");
- #ignore these errors due to nesting warnings.
+ 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;
}
my $cmd = "$CWRAPPER set " . (join ' ', @pr);
@@ -90,6 +111,13 @@ foreach (@all_nodes) {
# continue after set failure (or should we abort?)
}
}
+
+# Now deactivate these nodes
+for (@deactivate_nodes) {
+ my $cmd = "$CWRAPPER deactivate " . $_ . " 1>/dev/null";
+ system("$cmd");
+}
+
$ret = system("$commit_cmd");
if ($ret >> 8) {
print OLDOUT "Commit failed at boot\n";