From 70ec4fb1316ea3aee172ed12408f8be06948a78d Mon Sep 17 00:00:00 2001 From: root Date: Mon, 31 Jul 2017 12:48:48 +0100 Subject: [PATCH] bin/ovh-api --- bin/ovh-api | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/ovh-api b/bin/ovh-api index 26caf009..f1a41195 100755 --- a/bin/ovh-api +++ b/bin/ovh-api @@ -55,6 +55,11 @@ init(); open STDOUT,'| (which jq > /dev/null && jq . || cat)' if $Opt{jq}; my $Api = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $KEY[0], applicationSecret => $KEY[1], consumerKey => $KEY[2]); +if ($Opt{'show-ips'}) { + print map {"$_\n"} ips(); + exit; +} + # Auth auth() if @KEY < 3; @@ -178,9 +183,9 @@ sub ip_routed { return wantarray ? @routed : \@routed; } -sub ips() { - return grep { defined } map { - /^\s*inet.*?([\d\.]+)/ and $1 ne "127.0.0.1" +sub ips { + return grep { defined $_ and $_ ne ""} map { + /^\s*inet.*?([\d]+\.[\d]+\.[\d]+\.[\d]+)/ and $1 ne "127.0.0.1" ? $1 : undef } `ip addr show || ifconfig`; @@ -590,6 +595,7 @@ $NAME - Script to query ovh's api option[ip-routed=s] Print where is routed an ip option[ip-is-routed=s] Exit 0 if ip is routed to this host, 2 if slave option[sql] Produce sql to update a database + option[show-ips] Print local ips option[verbose|v+] Verbose mode: increase the verbosity level. option[debug+] Debug mode: increase the verbosity level. -- 2.47.3