From 7ab0b09d138d17571523dba4177e70b98c9001d0 Mon Sep 17 00:00:00 2001 From: Alex Harpin Date: Sat, 17 Oct 2015 18:06:01 +0100 Subject: vyatta-cfg-system: add scripts/is_port_available.pl for port checking Add scripts/is_available.pl to enable checking for available ports during configuration, in connection with Bug #43. The scripts checks to see if the port is currently in use by attempting to bind to it on INADDR_ANY. --- scripts/is_port_available.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 scripts/is_port_available.pl (limited to 'scripts') diff --git a/scripts/is_port_available.pl b/scripts/is_port_available.pl new file mode 100755 index 00000000..52a5ad0f --- /dev/null +++ b/scripts/is_port_available.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl +# Check to see if the supplied IPv4 or IPv6 address is an existing local address + +use strict; +use lib "/opt/vyatta/share/perl5"; +use Vyatta::Misc; + +my $ip = $ARGV[0]; +my $port = $ARGV[1]; + +if(!defined($ip) || !defined($port) || !is_port_available($ip, $port)) { + exit 1; +} else { + exit 0; +} \ No newline at end of file -- cgit v1.2.3