]> git.nbdom.net Git - nb.git/commitdiff
Option ip-is-routed
authorDevops <sys@15gifts.com>
Mon, 3 Jul 2017 15:46:05 +0000 (16:46 +0100)
committerDevops <sys@15gifts.com>
Mon, 3 Jul 2017 15:46:05 +0000 (16:46 +0100)
bin/ovh-api

index 7691e27854264227521375538d7b076082a66cea..6100e8b46a434e4dde4a0cb4e48d46cfbeed78d6 100755 (executable)
@@ -59,9 +59,17 @@ ip_move($Opt{'ip-move'}) if $Opt{'ip-move'};
 if ($Opt{'ip-routed'}) {
   my @routed = ip_routed($Opt{'ip-routed'});
   print JSON::encode_json(\@routed);
+  require Sys::Hostname;
+  my $localhost = Sys::Hostname::hostname();
   exit 0;
 }
 
+if ($Opt{'ip-is-routed'}) {
+  my @routed = ip_routed($Opt{'ip-is-routed'});
+  require Sys::Hostname;
+  my $localhost = Sys::Hostname::hostname();
+  exit ! grep {$_ eq $localhost} @routed;
+}
 
 # Query
 help() unless @ARGV;
@@ -552,6 +560,7 @@ $NAME - Script to query ovh's api
 
  option[ip-move=s]   Move IP to local
  option[ip-routed=s] Print where is routed an ip
+ option[ip-is-routed=s] Exit 0 if ip is routed to this host
  option[sql]         Produce sql to update a database
 
  option[verbose|v+] Verbose mode: increase the verbosity level.