getIp 1.20.1

This commit is contained in:
kyodev 2017-12-18 22:23:06 +01:00
parent 136de39898
commit 8bf1fafb99
2 changed files with 18 additions and 10 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=1.20.0
date="14/12/2017"
version=1.20.1
date="15/12/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getIp"
@ -372,7 +372,7 @@ fi_ip_pub(){ #v 14/12/2017
}
# $1=-4|-6, assigne $fg_ip, $fg_gws6, $fg_ifn, $fg_mac
figet_ip(){ # 14/12/2017
figet_ip(){ # 15/12/2017
local target ifn
x_ip=1
@ -407,9 +407,10 @@ figet_ip(){ # 14/12/2017
# interface sortante
if [ "$proto" == "-6" ]; then
target=$( gawk '/proto ra / { print $1; exit}' <<< $( ip $proto -o route ) )
fg_ifn_prior=$( ip $proto route get $target | sed -En 's/.*dev (.*) proto.*src ([0-9a-f:]+).*/\1/p' )
fg_ifn_prior=$( ip $proto route get $target )
fg_ifn_prior=$( ip $proto route get $target | sed -En 's/.*dev (.*) proto.*src ([0-9a-f:]+).*/\1 (\2)/p' )
else
fg_ifn_prior=$( ip $proto route get 255.255.255.255 | sed -En 's/.*dev (.*) src ([0-9.]+) .*/\1 \2/p' )
fg_ifn_prior=$( ip $proto route get 255.255.255.255 | sed -En 's/.*dev (.*) src ([0-9.]+) .*/\1 (\2)/p' )
fi
# ifnames & mac
fg_ifn="" fg_mac=""
@ -671,10 +672,11 @@ fscript_update(){ # 6/12/2017
rm -rf "$dirTemp/"
}
print_local(){ #v 11/12/2017
local text
print_local(){ #v 15/12/2017
local ifn_p4 text
figet_ip "-4" || f__error "iproute2 doit être installé" "il remplace net-tools qui n'est plus développé"
ifn_p4="$fg_ifn_prior"
f_pr titre1 "IPv4"
f_pr l2 "$fg_ip"
f_pr
@ -684,12 +686,14 @@ print_local(){ #v 11/12/2017
figet_ip "-6"
f_pr titre1 "IPv6"
f_pr l2 "$fg_ip"
f_pr
[ "$(f__wcv "-w" "$fg_ifn_prior")" -gt 1 ] && pluriel="s" || unset pluriel
f_pr l2 "interface"$pluriel" sortante"$pluriel": $fg_ifn_prior" '[ "$fg_ifn_prior" ]'
f_pr
[ "$(f__wcv "-l" "$fg_gws")" -gt 1 ] && pluriel="s" || unset pluriel
f_pr l2 "passerelle"$pluriel": ${fg_gws//$'\n'/ ⊗ }"
f_pr
[ "$(f__wcv "-w" "$fg_ifn_prior")" -gt 1 ] && pluriel="s" || unset pluriel
f_pr l2 "interface"$pluriel" sortante"$pluriel" ipv6: $fg_ifn_prior" '[ "$fg_ifn_prior" ]'
[ "$(f__wcv "-w" "$ifn_p4")" -gt 1 ] && pluriel="s" || unset pluriel
f_pr l2 "interface"$pluriel" sortante"$pluriel" ipv4: $ifn_p4" '[ "$ifn_p4" ]'
f_pr
[ "$(f__wcv "-l" "$fg_mac")" -gt 1 ] && pluriel="s" || unset pluriel
f_pr titre1 "adresse"$pluriel" Mac:"

View File

@ -1,6 +1,10 @@
# changelog getIp
## getIp 1.20.1 15/12/2017
* révision: affichage interface sortie ipv4 & ipv6
## getIp 1.20.0 14/12/2017
* révision: figer_ip + f__dir