summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-08-11 18:39:24 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-08-11 18:39:24 -0700
commit588492cf8a9ddf438b649c6db4986bcab9c22435 (patch)
tree20d85b8887a806be272c39e317cfef0baba95777 /scripts
parentf2d03803e6f10a430c1dc17436abd18f74b87a4d (diff)
downloadvyatta-cfg-quagga-588492cf8a9ddf438b649c6db4986bcab9c22435.tar.gz
vyatta-cfg-quagga-588492cf8a9ddf438b649c6db4986bcab9c22435.zip
Replace vyatta-vtysh with vtysh
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/policy/vyatta-policy.pl2
-rw-r--r--scripts/vyatta-policy-action-verify.pl4
-rw-r--r--scripts/vyatta-vtysh.pl129
3 files changed, 4 insertions, 131 deletions
diff --git a/scripts/policy/vyatta-policy.pl b/scripts/policy/vyatta-policy.pl
index 8fd94843..a3c19232 100755
--- a/scripts/policy/vyatta-policy.pl
+++ b/scripts/policy/vyatta-policy.pl
@@ -4,7 +4,7 @@ use VyattaConfig;
use VyattaMisc;
use Getopt::Long;
-my $VTYSH='/usr/bin/vyatta-vtysh';
+my $VTYSH='/usr/bin/vtysh';
GetOptions("update-access-list=s" => \$accesslist,
"update-aspath-list=s" => \$aspathlist,
diff --git a/scripts/vyatta-policy-action-verify.pl b/scripts/vyatta-policy-action-verify.pl
index 5ddd2974..1154f5c7 100644
--- a/scripts/vyatta-policy-action-verify.pl
+++ b/scripts/vyatta-policy-action-verify.pl
@@ -31,6 +31,8 @@ use strict;
use POSIX;
use File::Copy;
+my $VTYSH='/usr/bin/vtysh';
+
#solution: put a commit statement in the rule node that does the action test and squirt out delete hook in rule node on a delete.
my $route_map = shift;
@@ -55,5 +57,5 @@ foreach my $qualifiers (@qualifiers) {
#need to get a count of what's left and if action is deleted, but other nodes are present then reject
if (-e "/tmp/delete-policy-route-map-$route_map-rule-$rule") {
- system "/usr/bin/vyatta-vtysh -c \"configure terminal\" -c \"no route-map $route_map $action $rule\"";
+ system "$VTYSH -c \"configure terminal\" -c \"no route-map $route_map $action $rule\"";
}
diff --git a/scripts/vyatta-vtysh.pl b/scripts/vyatta-vtysh.pl
deleted file mode 100644
index a98083c6..00000000
--- a/scripts/vyatta-vtysh.pl
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Module: vyatta-vtysh.pl
-#
-# **** License ****
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2007 Vyatta, Inc.
-# All Rights Reserved.
-#
-# Author: Stig Thormodsrud
-# Date: December 2007
-# Description: Wrapper script between vyatta cfg templates and vtysh
-#
-# **** End License ****
-#
-
-use warnings;
-use strict;
-use POSIX;
-
-my $vtysh;
-
-if ( -x '/usr/bin/vyatta-vtysh' && -S '/var/run/vyatta/quagga/zebra.vty' ) {
- $vtysh = '/usr/bin/vyatta-vtysh';
-} else {
- $vtysh = '/usr/bin/vtysh';
-}
-
-my $logfile = '/tmp/vtysh.log';
-
-my $ignore_error = 0;
-
-sub log_it {
- my ($cmdline) = @_;
-
- if (substr($cmdline,0,2) eq "-c" and $ignore_error) {
- $cmdline = "-n $cmdline";
- }
- my $timestamp = strftime("%Y%m%d-%H:%M.%S", localtime);
- my $user = $ENV{'USER'};
- $user = "boot" if !defined $user;
- my $rc = open(my $fh, ">>", $logfile);
- if (!defined $rc) {
- print "Can't open $logfile: [$!]\n";
- return;
- }
- print $fh "$timestamp:$user [$cmdline]\n";
- close($fh);
-}
-
-sub parse_cmdline {
- my $cmdline = "";
-
- foreach my $arg (@ARGV) {
- if (substr($arg, 0, 2) eq "-n") {
- $ignore_error = 1;
- next;
- }
- if (substr($arg,0, 2) eq "-c") {
- #
- # This script expects a space between the -c and the command,
- # but try to handle it anyway
- #
- if ($arg ne "-c") {
- my $tmp = substr($arg,2);
- $cmdline .= "-c \"$tmp\" ";
- next;
- }
- } else {
- $arg = " \"$arg\" ";
- }
- $cmdline .= $arg;
- }
- return $cmdline
-}
-
-#
-# Send the config to quagga
-#
-# Note: Quagga never exits with an error code, but it does print an
-# error message to stdout. So if there is output, print it and
-# exit with an error. Certain error messages we dont' care about
-# such as issuing a "no <foo>" when foo doesn't exist. In those
-# cases it is up to the template file whether or not to fail on
-# the error code.
-#
-sub send_cmds_to_quagga {
- my ($cmdline) = @_;
-
- my $output = `$vtysh $cmdline`;
- if (defined $output && $output ne "") {
- if ($ignore_error) {
- log_it("Ignoring: $output");
- return 0;
- }
- log_it("Error: $output");
- print "%$output\n";
- return 1;
- }
- return 0;
-}
-
-sub usage {
- print "usage: $0 [-n] -c \"<quagga command>\"\n";
-}
-
-#
-# main
-#
-my ($cmdline, $rc);
-$cmdline = parse_cmdline();
-log_it($cmdline);
-if (! defined($cmdline) or $cmdline eq "") {
- usage();
- exit 1;
-}
-$rc = send_cmds_to_quagga($cmdline);
-exit $rc
-
-#end of file