summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@uffda.(none)>2007-10-17 20:27:11 -0700
committerStig Thormodsrud <stig@uffda.(none)>2007-10-17 20:27:11 -0700
commit70ad82f7cd762ddfd34534197ca1a4c1d7ee5b6c (patch)
tree45a2450617fb109d338a42c361bbc324e7db381d
parent281fcfb8dad9b66f027c39476a05aa5eff89fce1 (diff)
downloadvyatta-cfg-quagga-70ad82f7cd762ddfd34534197ca1a4c1d7ee5b6c.tar.gz
vyatta-cfg-quagga-70ad82f7cd762ddfd34534197ca1a4c1d7ee5b6c.zip
Add missing vyatta_quagga_utils.pl.
-rw-r--r--Makefile.am1
-rw-r--r--scripts/vyatta_quagga_utils.pl54
2 files changed, 55 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 955226bc..f6966c4a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,7 @@ cfgdir = $(datadir)/vyatta-cfg/templates
sbin_SCRIPTS = scripts/bgp/vyatta-bgp.pl
sbin_SCRIPTS += scripts/policy/vyatta-policy.pl
+sbin_SCRIPTS += scripts/vyatta_quagga_utils.pl
cpiop = find . ! -regex '\(.*~\|.*\.bak\|.*\.swp\|.*\#.*\#\)' -print0 | \
cpio -0pd
diff --git a/scripts/vyatta_quagga_utils.pl b/scripts/vyatta_quagga_utils.pl
new file mode 100644
index 00000000..2b5b05ac
--- /dev/null
+++ b/scripts/vyatta_quagga_utils.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+use lib "/opt/vyatta/share/perl5/";
+use VyattaConfig;
+use VyattaMisc;
+use NetAddr::IP;
+use Getopt::Long;
+
+GetOptions("check-prefix-boundry=s" => \$prefix,
+ "not-exists=s" => \$notexists,
+ "exists=s" => \$exists,
+);
+
+if (defined $prefix) { check_prefix_boundry($prefix); }
+if (defined $notexists) { check_not_exists($notexists); }
+if (defined $exists) { check_exists($exists); }
+
+exit 0;
+
+sub check_prefix_boundry() {
+ my $prefix = shift;
+ my $net, $cidr;
+
+ $net = new NetAddr::IP $prefix;
+ $cidr = $net->network();
+ if ( "$cidr" ne "$prefix" ) {
+ print "Your prefix must fall on a natural network boundry. Did you mean $cidr?\n";
+ exit 1;
+ }
+
+ exit 0;
+}
+
+sub check_exists() {
+ my $node = shift;
+ my $config = new VyattaConfig;
+
+ if ( $config->exists("$node") ) {
+ exit 0;
+ }
+
+ exit 1;
+}
+
+sub check_not_exists() {
+ my $node = shift;
+ my $config = new VyattaConfig;
+
+ if (! $config->exists("$node") ) {
+ exit 0;
+ }
+
+ exit 1;
+}
+