diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-03-27 15:33:21 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-03-27 15:33:21 -0700 |
commit | 453bbafd1ef8569ead7f342ed604c834772fd6e2 (patch) | |
tree | 6563623cb58b9ddeee9bf5bc80daa54e4cd7ec08 /scripts/policy/vyatta-policy.pl | |
parent | fdab0c39026d3631515030ba41993654f14aef81 (diff) | |
download | vyatta-cfg-quagga-453bbafd1ef8569ead7f342ed604c834772fd6e2.tar.gz vyatta-cfg-quagga-453bbafd1ef8569ead7f342ed604c834772fd6e2.zip |
Fix some possible issues with policy script
Change to closure would not allow exit to work correctly.
Go back to old way using variables.
Use grep -c to count instances
Also rerun through tidy.
Diffstat (limited to 'scripts/policy/vyatta-policy.pl')
-rwxr-xr-x | scripts/policy/vyatta-policy.pl | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/scripts/policy/vyatta-policy.pl b/scripts/policy/vyatta-policy.pl index 91a73d0f..2ce6a2aa 100755 --- a/scripts/policy/vyatta-policy.pl +++ b/scripts/policy/vyatta-policy.pl @@ -7,15 +7,24 @@ use Getopt::Long; my $VTYSH = '/usr/bin/vyatta-vtysh'; +my ( $accesslist, $aspathlist, $communitylist, $peer ); +my ( $routemap, $deleteroutemap ); + GetOptions( - "update-access-list=s" => sub { update_access_list( $_[1] ); }, - "update-aspath-list=s" => sub { update_as_path( $_[1] ); }, - "update-community-list=s" => sub { update_community_list( $_[1] ); }, - "check-peer-syntax=s" => sub { check_peer_syntax( $_[1] ); }, - "check-routemap-action=s" => sub { check_routemap_action( $_[1] ); }, - "check-delete-routemap-action=s" => - sub { check_delete_routemap_action( $_[1] ); }, -); + "update-access-list=s" => \$accesslist, + "update-aspath-list=s" => \$aspathlist, + "update-community-list=s" => \$communitylist, + "check-peer-syntax=s" => \$peer, + "check-routemap-action=s" => \$routemap, + "check-delete-routemap-action=s" => \$deleteroutemap, +) or exit 1; + +update_access_list($accesslist) if ($accesslist); +update_as_path($aspathlist) if ($aspathlist); +update_community_list($communitylist) if ($communitylist); +check_peer_syntax($peer) if ($peer); +check_routemap_action($routemap) if ($routemap); +check_delete_routemap_action($deleteroutemap) if ($deleteroutemap); exit 0; @@ -33,8 +42,7 @@ sub check_peer_syntax { sub is_community_list { my $list = shift; - my $count = - `$VTYSH -c \"show ip community-list $list\" | grep $list | wc -l`; + my $count = `$VTYSH -c \"show ip community-list $list\" | grep -c $list`; if ( $count > 0 ) { return 1; } @@ -83,7 +91,7 @@ sub is_as_path_list { my $list = shift; my $count = - `$VTYSH -c \"show ip as-path-access-list $list\" | grep $list | wc -l`; + `$VTYSH -c \"show ip as-path-access-list $list\" | grep -c $list`; if ( $count > 0 ) { return 1; } @@ -129,7 +137,7 @@ sub update_as_path { sub is_access_list { my $list = shift; - my $count = `$VTYSH -c \"show ip access-list $list\" | grep $list | wc -l`; + my $count = `$VTYSH -c \"show ip access-list $list\" | grep -c $list`; return ( $count > 0 ); } |