summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-cfg-cmd-wrapper26
-rwxr-xr-xscripts/vyatta-cli-expand-var.pl2
-rwxr-xr-xscripts/vyatta-config-gen-sets.pl9
-rwxr-xr-xscripts/vyatta-config-loader.pl15
-rwxr-xr-xscripts/vyatta-exists14
-rwxr-xr-xscripts/vyatta-interfaces.pl9
-rwxr-xr-xscripts/vyatta-load-config.pl2
7 files changed, 42 insertions, 35 deletions
diff --git a/scripts/vyatta-cfg-cmd-wrapper b/scripts/vyatta-cfg-cmd-wrapper
index 7496f96..53a3fcc 100755
--- a/scripts/vyatta-cfg-cmd-wrapper
+++ b/scripts/vyatta-cfg-cmd-wrapper
@@ -152,21 +152,33 @@ case "$1" in
RET_STATUS=$?
;;
load)
+ export vyatta_sysconfdir=/opt/vyatta/etc
+ export vyatta_sbindir=/opt/vyatta/sbin
/opt/vyatta/sbin/vyatta-load-config.pl "${@:2}"
RET_STATUS=$?
;;
- firewall-rule-rename)
- # this option is to be used for renaming firewall rules only
- # usage for this option specified on the next line -
- # firewall-rule-rename $firewall_ruleset rule $rule_num to rule $rename_rulenum
+ rule-rename)
+ # this option is to be used for renaming firewall and nat rules only
+ # usage for this option specified on the next two lines -
+ # rule-rename firewall $firewall_ruleset rule $rule_num to rule $rename_rulenum
+ # rule-rename nat rule $rule_num to rule $rename_rulenum
- VYATTA_TEMPLATE_LEVEL=/firewall/name/node.tag;
- VYATTA_EDIT_LEVEL="/firewall/name/$2";
+ if [ "$2" == "firewall" ]; then
+ VYATTA_TEMPLATE_LEVEL=/firewall/name/node.tag;
+ VYATTA_EDIT_LEVEL="/firewall/name/$3";
+ elif [ "$2" == "nat" ]; then
+ VYATTA_TEMPLATE_LEVEL=/service/nat;
+ VYATTA_EDIT_LEVEL=/service/nat;
+ fi
_mpath=${VYATTA_TEMP_CONFIG_DIR}/${VYATTA_EDIT_LEVEL}
_tpath=${VYATTA_CONFIG_TEMPLATE}/${VYATTA_TEMPLATE_LEVEL}
VYATTA_EDIT_LEVEL="${_mpath#$VYATTA_TEMP_CONFIG_DIR}/"
VYATTA_TEMPLATE_LEVEL="${_tpath#$VYATTA_CONFIG_TEMPLATE}/"
- mvcp rename Rename mv "${@:3}"
+ if [ $2 == "firewall" ]; then
+ mvcp rename Rename mv "${@:4}"
+ elif [ $2 == "nat" ]; then
+ mvcp rename Rename mv "${@:3}"
+ fi
RET_STATUS=$?
;;
*)
diff --git a/scripts/vyatta-cli-expand-var.pl b/scripts/vyatta-cli-expand-var.pl
index f690f0b..f3bda2d 100755
--- a/scripts/vyatta-cli-expand-var.pl
+++ b/scripts/vyatta-cli-expand-var.pl
@@ -34,7 +34,7 @@ $_ = $ARGV[0];
# basic format check:
# '(' ')' not allowed in reference.
# only allow absolute path for now.
-if (!/^\$\(\/([^()]+)\)$/) {
+if (!/^\$VAR\(\/([^()]+)\)$/) {
print STDERR "invalid variable reference (invalid format)\n";
exit 1;
}
diff --git a/scripts/vyatta-config-gen-sets.pl b/scripts/vyatta-config-gen-sets.pl
index 2fe4ac6..566570e 100755
--- a/scripts/vyatta-config-gen-sets.pl
+++ b/scripts/vyatta-config-gen-sets.pl
@@ -32,23 +32,14 @@ my $conf_file = '/opt/vyatta/etc/config/config.boot';
$conf_file = $ARGV[0] if defined $ARGV[0];
# get a list of all config statement in the startup config file
-# (sorted by rank).
my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($conf_file);
if (scalar(@all_nodes) == 0) {
# no config statements
exit 1;
}
-my $cur_rank = ${$all_nodes[0]}[1];
my $ret = 0;
-# higher-ranked statements committed before lower-ranked.
foreach (@all_nodes) {
- my ($path_ref, $rank) = @$_;
- if ($rank != $cur_rank) {
- # commit all nodes with the same rank together.
- print "commit\n";
- $cur_rank = $rank;
- }
my $cmd = "set " . (join ' ', @$path_ref);
print "$cmd\n";
}
diff --git a/scripts/vyatta-config-loader.pl b/scripts/vyatta-config-loader.pl
index a32d1fc..61eafa5 100755
--- a/scripts/vyatta-config-loader.pl
+++ b/scripts/vyatta-config-loader.pl
@@ -46,14 +46,12 @@ sub restore_fds {
}
# get a list of all config statement in the startup config file
-# (sorted by rank).
my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0]);
if (scalar(@all_nodes) == 0) {
# no config statements
restore_fds();
exit 1;
}
-my $cur_rank = ${$all_nodes[0]}[1];
# set up the config environment
my $CWRAPPER = '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper';
@@ -69,20 +67,9 @@ if ($? >> 8) {
my $commit_cmd = "$CWRAPPER commit";
my $cleanup_cmd = "$CWRAPPER cleanup";
my $ret = 0;
-# higher-ranked statements committed before lower-ranked.
+my $rank; #not used
foreach (@all_nodes) {
my ($path_ref, $rank) = @$_;
- if ($rank != $cur_rank) {
- # commit all nodes with the same rank together.
- $ret = 0; #system("$commit_cmd");
- if ($ret >> 8) {
- print OLDOUT "Commit failed at rank $cur_rank\n";
- print WARN "Commit failed at rank $cur_rank\n";
- system("$cleanup_cmd");
- # continue after cleanup (or should we abort?)
- }
- $cur_rank = $rank;
- }
my $cmd = "$CWRAPPER set " . (join ' ', @$path_ref);
# this debug file should be deleted before release
system("echo [$cmd] >> /tmp/foo");
diff --git a/scripts/vyatta-exists b/scripts/vyatta-exists
new file mode 100755
index 0000000..ef2dea3
--- /dev/null
+++ b/scripts/vyatta-exists
@@ -0,0 +1,14 @@
+#! /bin/bash
+
+# Test if given node exists in Vyatta config hierarchy
+#
+# if vyatta-exists interfaces wireless
+
+if [ -z "$VYATTA_TEMP_CONFIG_DIR" ]; then
+ echo "$0: not in configuration mode" 1>&2;
+ exit 1;
+fi
+IFS=/
+node=$*
+IFS=
+exec test -d $VYATTA_TEMP_CONFIG_DIR/$node
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 86410c1..567e3b7 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -260,10 +260,12 @@ sub update_eth_addrs {
}
if ($version == 4) {
- return system("ip addr add $addr broadcast + dev $intf");
+ exec (qw(ip addr add),$addr,qw(broadcast + dev), $intf)
+ or die "ip addr command failed: $!";
}
if ($version == 6) {
- return system("ip -6 addr add $addr dev $intf");
+ exec (qw(ip -6 addr add), $addr, 'dev', $intf)
+ or die "ip addr command failed: $!";
}
die "Error: Invalid address/prefix [$addr] for interface $intf\n";
}
@@ -316,7 +318,8 @@ sub update_mac {
system "sudo ip link set $intf up"
and die "Could not set $intf up ($!)\n";
} else {
- exec "sudo ip link set $intf address $mac";
+ system "sudo ip link set $intf address $mac"
+ and die "Could not set $intf address ($!)\n";
}
exit 0;
}
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl
index a3cf6ef..f0dbaf1 100755
--- a/scripts/vyatta-load-config.pl
+++ b/scripts/vyatta-load-config.pl
@@ -175,7 +175,7 @@ syslog( "warning", "Load config [$orig_load_file] by $login" );
# do config migration
system("$sbindir/vyatta_config_migrate.pl $load_file");
-print "Loading config file $load_file...\n";
+print "Loading configuration from '$load_file'...\n";
my %cfg_hier = Vyatta::ConfigLoad::loadConfigHierarchy($load_file,$merge);
if ( scalar( keys %cfg_hier ) == 0 ) {
print "The specified file does not contain any configuration.\n";