summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-05-21 10:36:47 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-05-21 10:36:47 -0700
commit6ece71ecf691431006ae1389f9ab575a1a39683e (patch)
tree613c815786c0b5057f1f98a8adb53f9e88d9b17b /scripts
parent21cbbc1a25e672f9656cb8364bd01feefcbf855e (diff)
downloadvyatta-cfg-6ece71ecf691431006ae1389f9ab575a1a39683e.tar.gz
vyatta-cfg-6ece71ecf691431006ae1389f9ab575a1a39683e.zip
Add script option to check if interface is up
Better than reading sysfs directly.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-interfaces.pl16
1 files changed, 15 insertions, 1 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index d0d8fa1..3e5beaa 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -48,7 +48,8 @@ use warnings;
my $dhcp_daemon = '/sbin/dhclient';
my ($eth_update, $eth_delete, $addr, $dev, $mac, $mac_update, $op_dhclient);
-my ($check_name, $show_names, $intf_cli_path, $vif_name, $warn_name, $show_path);
+my ($check_name, $show_names, $intf_cli_path, $vif_name, $warn_name);
+my ($check_up, $show_path);
sub usage {
print "Usage: $0 --dev=<interface> --check=<type>\n";
@@ -58,6 +59,7 @@ sub usage {
print " $0 --dev=<interface> --eth-addr-delete=<aa:aa:aa:aa:aa:aa>\n";
print " $0 --dev=<interface> --valid-addr={<a.b.c.d>|dhcp}\n";
print " $0 --dev=<interface> --path\n";
+ print " $0 --dev=<interface> --isup\n";
print " $0 --show=<type>\n";
exit 1;
}
@@ -74,6 +76,7 @@ GetOptions("eth-addr-update=s" => \$eth_update,
"vif=s" => \$vif_name,
"warn" => \$warn_name,
"path" => \$show_path,
+ "isup" => \$check_up,
) or usage();
update_eth_addrs($eth_update, $dev) if ($eth_update);
@@ -86,6 +89,7 @@ is_valid_name($check_name, $dev) if ($check_name);
exists_name($dev) if ($warn_name);
show_interfaces($show_names) if ($show_names);
show_config_path($dev) if ($show_path);
+is_up($dev) if ($check_up);
exit 0;
sub is_ip_configured {
@@ -106,6 +110,16 @@ sub is_ip_duplicate {
return is_ip_configured($intf, $ip);
}
+sub is_up {
+ my $name = shift;
+ my $intf = new Vyatta::Interface($name);
+
+ die "Unknown interface type for $name" unless $intf;
+
+ exit 0 if ($intf->up());
+ exit 1;
+}
+
sub touch {
my $file = shift;
my $t = time;