This commit is contained in:
kyodev 2018-06-18 13:16:22 +02:00
parent 4ad102da2e
commit 88ccc1100b
2 changed files with 194 additions and 169 deletions

View File

@ -1,6 +1,6 @@
# getInfo
![version: 4.7.0](https://img.shields.io/badge/version-4.7.0-blue.svg?longCache=true&style=for-the-badge)
![version: 4.8.0](https://img.shields.io/badge/version-4.8.0-blue.svg?longCache=true&style=for-the-badge)
![bash langage](https://img.shields.io/badge/bash-4-brightgreen.svg?longCache=true&style=for-the-badge)
![license LPRAB / WTFPL](https://img.shields.io/badge/license-LPRAB%20%2F%20WTFPL-blue.svg?longCache=true&style=for-the-badge)

View File

@ -1,14 +1,12 @@
#!/bin/bash
# shellcheck disable=SC1117,SC2016,SC2009
# shellcheck disable=SC2207
# SC1117 Backslash is literal in "\n". Prefer explicit escaping: "\\n"
# SC2016 Expressions don't expand in single quotes
# SC2009 Consider using pgrep instead of grepping ps output
# SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
version=4.7.0
date="16/06/2018"
version=4.8.0
date="18/06/2018"
script="getInfo"
contact="IRC freenode.net ##sdeb@freenode.net ou https://framagit.org/sdeb/getInfo/issues"
@ -35,49 +33,6 @@ f__architecture(){ # 14/O6/2018
esac
}
# test connexion, [$1=-4|-6] protocole -4 par défaut, return 0|1
f__cnx(){ # 15/06/2018-2
local proto="-4" cmds cmd ip servers
if [[ "$1" == '-6' || "$1" == '6' ]]; then
proto="-6"
servers=(
2606:4700:4700::1111 # cloudfare
2001:7fd::1 # root K RIPE
2001:500:a8::e # root E nasa
2001:4860:4860::8888 # google
)
else
servers=(
1.1.1.1 # cloudfare
193.0.14.129 # root K RIPE
192.203.230.10 # root E nasa
195.135.221.140 # conncheck.opensuse.org
80.67.169.12 # ns0.fdn.fr
8.8.8.8 # google
)
fi
type -p ping &>/dev/null && cmds+=( "ping -c1 -w1 -U " )
type -p fping &>/dev/null && cmds+=( "fping --retry=0 --elapsed --stats " )
if (( ${#cmds[@]} == 0 )); then
echo "f__cnx(): no available commands" >&2
return
fi
for cmd in "${cmds[@]}"; do
for ip in "${servers[@]}" ; do
$cmd "$proto" "$ip" &>/dev/null && return 0
done
done
if nc -4 -h &>/dev/null; then # pris en charge par netcat-openbsd
for ip in "${servers[@]}" ; do
nc "$proto" -z -w1 "$ip" 53 &>/dev/null && return 0 # paquet netcat-traditional debian obsolete, ne gere pas protocoles
done
fi
return 1
}
# shellcheck disable=SC2034
f__color(){ # 29/05/2018
@ -141,59 +96,6 @@ f__dialog_oui_non(){ # 14/06/2018
fi
}
# use dig or drill according to availability, options: hostname [@server|type|nostd|host], display ip | n/a (equivalent + short)
# if option --host, diplay hostname: ip
# dig has priority over dril if the two command are presents
# type : aaaa | a | txt | soa | any | mx | AAAA | A | TXT | SOA | ANY | MX
# option nostd for dig only: +timeout=1 +retry=1
f__dig(){ # 16/06/2018
local ini options type host server hostname dig ip domain ttl class typ ipx z
ini=$( shopt -p nocasematch )
if (( $# == 0 )); then
echo "f__dig: argument manquant"
return 1
fi
shopt -s nocasematch
while (( $# )) ; do
case "$1" in
nostd ) options+=( '+timeout=1' '+retry=1' ) ;;
aaaa | a | txt | soa | any | mx ) type="$1" ;;
host ) host='yes' ;;
@* ) server=( "$1" ) ;;
* ) hostname="$1" ;;
esac
shift
done
type="${type:=A}"
if type -p dig &>/dev/null; then
dig=$( dig "${options[@]}" "$hostname" "${server[@]}" "$type" )
elif type -p drill &>/dev/null; then
dig=$( drill "$hostname" "${server[@]}" "${type[@]}" )
else
echo "dig or drill command unavailable"
eval "$ini"
return 1
fi
if [[ $dig =~ answer:\ 0 ]]; then
dig='n/a'
elif [[ $dig =~ answer:\ 1 ]]; then
# shellcheck disable=SC2034
while read -r domain ttl class typ ipx z; do
if [[ $domain$class$typ == ${hostname}\.IN$type ]]; then
ip+="$ipx "
fi
done <<< "$dig"
dig="$ip"
fi
[ "$host" ] && echo -n "$hostname: "
echo "$dig"
eval "$ini"
if [ "$dig" == "n/a" ]; then
return 1
fi
}
# $1=-c|-l|-lc, $2 répertoire, [$3] motif exclusion sur nom fichier, affiche 0|null si répertoire inexistant
# -c: compte du nombre de fichiers dans un répertoire
# -l: liste inline des noms de fichiers seuls (sans chemin) (similaire ls)
@ -268,14 +170,14 @@ f__log(){ # 05/03/2018
}
# $1=bas-haut (ex: 0-5), nombre aléatoire entre bas & haut inclus, si [$2=seq] liste avec départ aléatoire
f__random(){ # 02/06/2018
f__random(){ # 17/06/2018
local bas haut max rand start sequence xyz
[ "${1//*-*}" ] && return 1 # bad format, no -
bas=${1%-*}
bas=${1%%-*}
haut=${1#*-}
max=$(( 32768 / ( haut + 1 ) * ( haut + 1 ) ))
while (( (rand=RANDOM) >= max )); do : ; done
(( bas < 0 || haut < 0 )) && return 1
max=$(( 32768 / ( haut + 1 ) * ( haut + 1 ) ))
while (( (rand=RANDOM) >= max )); do : ; done
if [ "$2" == "seq" ]; then
start=$(( bas + ( rand % (haut+1-bas) ) ))
for (( xyz=start; xyz <= haut; xyz++ )); do echo "$xyz"; done
@ -705,8 +607,8 @@ f_help(){ # 16/06/2018
}
# $1 [-4|-6], par défaut -4, affiche ip pub, return 1 on failure
# requiert f__cnx & f_ip_validate & f__random & f__log & f__dig
f_ip_pub(){ # 16/06/2018-2
# requiert f_n_cnx & f_ip_validate & f__random & f__log & f_n_dig
f_ip_pub(){ # 17/06/2018
local proto="-4" ip_pub base_size cmd sequence xyz server user_agent="Mozilla/5.0 Firefox"
declare -a base cmds raw4 raw6 dns4 dns6
@ -721,26 +623,26 @@ f_ip_pub(){ # 16/06/2018-2
ipecho.net/plain # raw ip4 only
ipinfo.io/ip # raw ip4 only
eth0.me # raw ip4 only
# checkip.amazonaws.com # raw ip4 only lent O4/2018
#~ ifconfig.me/ip # raw ip4 only pas fiable
# checkip.amazonaws.com # raw ip4 only lent O4/2018
#~ ifconfig.me/ip # raw ip4 only pas fiable
)
raw6=(
v6.ident.me # raw, ip6 defaut
ipv6.whatismyip.akamai.com # raw, ip6 defaut
canhazip.com # raw, ip6 defaut
ip.tyk.nu # raw, ip6 defaut
myexternalip.com/raw # raw, ip6 defaut parfois ip4
smart-ip.net/myip # raw, ip6 defaut ! requiert user-agent
myexternalip.com/raw # raw, ip6 defaut parfois ip4
smart-ip.net/myip # raw, ip6 defaut ! requiert user-agent
diagnostic.opendns.com/myip # raw, ip6 defaut
icanhazip.com # raw, ip6 defaut
wgetip.com # raw, ip6 defaut
wtfismyip.com/text # raw, ip6 defaut
l2.io/ip # raw, ip6 defaut
tnx.nl/ip # raw, ip6 defaut
bot.whatismyipaddress.com # raw, ip6 defaut pb parfois sort ip4
#~ ipof.in/txt # raw, ip6 defaut NRP
#~ ident.me # raw, ip6 defaut
# canhazip.com # raw, ip6 defaut ne raccourcit pas les ip
# wgetip.com # raw, ip6 defaut ne raccourcit pas les ip
# bot.whatismyipaddress.com # raw, ip6 defaut pb parfois sort ip4
# ipof.in/txt # raw, ip6 defaut NRP
# ident.me # raw, ip6 defaut
)
dns4=(
@ -757,22 +659,20 @@ f_ip_pub(){ # 16/06/2018-2
"TXT o-o.myaddr.l.google.com @ns1.google.com"
)
}
[[ "$1" == '-6' || "$1" == '6' ]] && proto="-6"
type -p host &>/dev/null && cmds+=( "host -R0 -W1 -t " ) # deprecated
type -p dig &>/dev/null || type -p drill &>/dev/null && cmds+=( "f__dig nostd " )
type -p wget &>/dev/null && cmds+=( "wget --user-agent=$user_agent --quiet --timeout=1 --tries=1 -o /dev/null -O - " )
type -p curl &>/dev/null && cmds+=( "curl --silent --location --retry 0 --max-time 1 " )
[[ "$1" == @(-4|4) ]] && proto="-4"
[[ "$1" == @(-6|6) ]] && proto="-6"
type -p host &>>/dev/null && cmds+=( "f_n_host nostd " ) # deprecated
#~ type -p dig &>/dev/null || type -p drill &>/dev/null && cmds+=( "f_n_dig nostd" )
#~ type -p wget &>/dev/null && cmds+=( "wget --user-agent=$user_agent --quiet --timeout=1 --tries=1 -o /dev/null -O -" )
#~ type -p curl &>/dev/null && cmds+=( "curl --silent --location --retry 0 --max-time 1" )
if (( ${#cmds[@]} == 0 )); then
echo "f_ip_pub(): no available commands (host|dig|drill|wget|curl)" >&2
return
return 1
fi
for cmd in "${cmds[@]}"; do
if [[ "$proto" == '-4' && "$cmd" =~ ^(host|f__dig) ]] ; then
if [[ "$proto" == '-4' && "$cmd" =~ ^(f_n_host|f_n_dig) ]] ; then
base=( "${dns4[@]}" )
elif [[ "$proto" == '-6' && "$cmd" =~ ^(host|f__dig) ]] ; then
elif [[ "$proto" == '-6' && "$cmd" =~ ^(f_n_host|f_n_dig) ]] ; then
base=( "${dns6[@]}" )
elif [[ "$proto" == '-4' && "$cmd" =~ ^(wget|curl) ]] ; then
base=( "${raw4[@]}" )
@ -783,18 +683,13 @@ f_ip_pub(){ # 16/06/2018-2
sequence=$( f__random "0-$base_size" seq ) # range: 0 to base_size
for ii in $sequence; do
read -r -a server <<< "${base[$ii]}"
[[ $cmd =~ ^host ]] && server=( "${server[@]//@}" )
[[ $cmd =~ ^host ]] && server=( "${server[@]#@}" )
ip_pub=$( $cmd "${server[@]}" )
ip_pub=${ip_pub##*has address } # extraction command host
ip_pub=${ip_pub##*has IPv6 address } # extraction command host
ip_pub=${ip_pub#*\"} # extraction o-o.myaddr.l.google.com
ip_pub=${ip_pub%\"*} # extraction o-o.myaddr.l.google.com
f_ip_validate "$1" "$ip_pub" || unset ip_pub
[ "$ip_pub" ] && break 2 # exit if valid ip
f_ip_validate "$ip_pub" && break 2 # exit if valid ip
done
done
if [ -z "$ip_pub" ]; then
if type -t f__log &>/dev/null && ! f__cnx "$proto" ; then # f__log() exists & no connection
if type -t f__log &>/dev/null && ! f_n_cnx "$proto" ; then # f__log() exists & no connection
f__log --error "f_ip_pub(): no connection"
fi
return 1
@ -802,30 +697,27 @@ f_ip_pub(){ # 16/06/2018-2
echo "$ip_pub"
}
# [-4|-6] protocole par défaut -4, IP, return 0|1|2, 1 ip invalide, 2 ipv4 privée
f_ip_validate(){ # 17/05/2018
local proto="-4" ip reg regex regex_priv="zzz" #ip6: https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses ()https://stackoverflow.com/a/17871737/9580455)
# $1=ip, test si ip = ipv4 ou ipv6, return 0|1
f_ip_validate(){ # 17/06/2018
# ip6: https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses ()https://stackoverflow.com/a/17871737/9580455)
local proto reg regex result
while (( $# )) ; do
case "$1" in
-6 | 6 ) proto='-6' ;;
-4 | 4 ) proto='-4' ;;
* ) ip="$1" ;;
esac
shift
for proto in -4 -6; do
if [[ "$proto" == "-6" ]]; then
regex="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$"
else
reg="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])"
regex="^$reg\\.$reg\\.$reg\\.$reg$"
# regex_priv="^(127\\.$reg|10\\.$reg|172\\.(1[6-9]|2[0-9]|3[0-1])|192\\.168)\\.$reg\\.$reg$"
fi
if [[ "$1" =~ $regex ]]; then
unset result
break
else
result="fail"
fi
done
if [[ "$proto" == "-6" ]]; then
regex="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$"
proto="-6"
else
reg="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])"
regex="^$reg\\.$reg\\.$reg\\.$reg$"
regex_priv="^(127\\.$reg|10\\.$reg|172\\.(1[6-9]|2[0-9]|3[0-1])|192\\.168)\\.$reg\\.$reg$"
fi
if [[ "$ip" =~ $regex_priv ]]; then
return 2
elif [[ ! "$ip" =~ $regex ]]; then
if [ "$result" ]; then
return 1
fi
}
@ -866,6 +758,140 @@ f_lifting(){ # 08/02/2018
echo "$text"
}
# test connexion, [$1=-4|-6] protocole -4 par défaut, return 0|1
f_n_cnx(){ # 17/06/2018
local proto="-4" cmds cmd ip servers
if [[ "$1" == '-6' || "$1" == '6' ]]; then
proto="-6"
servers=(
2606:4700:4700::1111 # cloudfare
2001:7fd::1 # root K RIPE
2001:500:a8::e # root E nasa
2001:4860:4860::8888 # google
)
else
servers=(
1.1.1.1 # cloudfare
193.0.14.129 # root K RIPE
192.203.230.10 # root E nasa
195.135.221.140 # conncheck.opensuse.org
80.67.169.12 # ns0.fdn.fr
8.8.8.8 # google
)
fi
type -p ping &>/dev/null && cmds+=( "ping -c1 -w1 -U " )
type -p fping &>/dev/null && cmds+=( "fping --retry=0 --elapsed --stats " )
if (( ${#cmds[@]} == 0 )); then
echo "f_n_cnx(): no available commands (ping|fping)" >&2
return 1
fi
for cmd in "${cmds[@]}"; do
for ip in "${servers[@]}" ; do
$cmd "$proto" "$ip" &>/dev/null && return 0
done
done
if nc -4 -h &>/dev/null; then # pris en charge par netcat-openbsd
for ip in "${servers[@]}" ; do
nc "$proto" -z -w1 "$ip" 53 &>/dev/null && return 0 # paquet netcat-traditional debian obsolète, ne gère pas protocoles
done
fi
return 1
}
# use dig or drill according to availability, options: hostname [@server|type|nostd], display ip | n/a (equivalent + short), return 0|1
# dig has priority over drill if the two command are presents
# type : aaaa | a | txt | soa | mx | AAAA | A | TXT | SOA | MX , A by default
# option nostd, for dig only: +timeout=1 +retry=1
f_n_dig(){ # 17/06/2018
local ini options type='A' server hostname cmd line ip
! type -p dig &>/dev/null && ! type -p drill &>/dev/null && return 1
(( $# == 0 )) && return
ini=$( shopt -p nocasematch )
shopt -s nocasematch
while (( $# )) ; do
case "$1" in
nostd ) options+=( '+timeout=1' '+retry=1' ) ;;
aaaa | a | txt | soa | mx ) type="$1" ;;
@* ) server="$1" ;;
* ) hostname="$1" ;;
esac
shift
done
if type -p dig &>/dev/null; then
cmd=$( LC_ALL=C dig "${options[@]}" "$hostname" "${server[@]}" "${type[@]}" )
elif type -p drill &>/dev/null; then
cmd=$( LC_ALL=C drill "$hostname" "${server[@]}" "${type[@]}" )
fi
if [[ $cmd =~ answer:\ 0 ]]; then
ip='n/a'
elif [[ $cmd =~ answer:\ [1-9] ]]; then
while read -r -a line; do
if [[ ${line[0]}${line[2]}${line[3]} == ${hostname}\.IN$type ]]; then
ip+="${line[(( ${#line[@]} - 1 ))]%\.} "
if [[ "$type" == @(SOA|TXT) ]]; then
ip="${line[4]}"
fi
fi
done <<< "$cmd"
ip="${ip% }"
fi
if [[ "$type" == @(SOA|TXT) ]]; then
#~ ip=${ip%.} # soa
ip=${ip%\"} # txt
ip=${ip#\"} # txt
fi
eval "$ini"
echo "$ip"
if [ "$ip" == "n/a" ]; then
return 1
fi
}
# options: hostname [@server|type|nostd], display ip | n/a (equivalent to dig + short), return 0|1
# type : aaaa | a | txt | soa | mx | AAAA | A | TXT | SOA | MX , A by default
# option nostd: -R1 -W1
f_n_host(){ # 17/06/2018
local ini type='A' options server hostname ip line
! type -p host &>/dev/null && return 1
(( $# == 0 )) && return
ini=$( shopt -p nocasematch )
shopt -s nocasematch
while (( $# )) ; do
case "$1" in
aaaa | a | txt | soa | mx ) type="$1" ;;
nostd ) options+=( '-R1' '-W1' ) ;;
@* ) server="${1#@}" ;;
* ) hostname="$1" ;;
esac
shift
done
while read -r -a line; do
if (( ${#line[@]} > 3 )); then
ip+="${line[(( ${#line[@]} - 1 ))]%\.} " # last field
#~ if [[ "$type" == @(SOA|TXT) ]]; then
if [[ "$type" == SOA ]]; then
ip="${line[4]}"
fi
fi
done <<< "$( LC_ALL=C host "${options[@]}" -t "${type[@]}" "$hostname" "${server[@]}" )"
ip="${ip% }"
[[ $ip =~ not\ found ]] && ip='not found'
[[ $ip =~ has\ no\ $type\ record ]] && ip='no record'
ip=${ip%\"} # txt
ip=${ip#\"} # txt
eval "$ini"
echo "$ip"
if [[ "$ip" == 'not found' || "$ip" == 'no record' ]]; then
return 1
fi
}
# $1=preferences|sources, affiche fichiers ignorés par apt
f_policy(){ # 27/01/2018
local policy
@ -1566,7 +1592,7 @@ fi_hw(){ # 14/12/2017
f_prnt flush
}
fi_ip_pub(){ # 16/06/2018 SPÉCIFIQUE
fi_ip_pub(){ # 18/06/2018 SPÉCIFIQUE
local itest ippub
echo " ${BLUE}ip publique(s)$STD"
@ -1944,9 +1970,7 @@ fi_packagers(){ # 23/11/2017
fi
}
# shellcheck disable=SC2034
# SC2034 foo appears unused. Verify it or export it.
fi_pkg_apt(){ # 14/06/2018
fi_pkg_apt(){ # 18/06/2018
local dateMaj nb_packages ifile info_update text pluriel
local sources cmt_sources cmd_sources result
local apt_v apt_version apt_prefs cmt_apt_prefs cmd_apt_prefs alert_non_pref
@ -1986,7 +2010,7 @@ fi_pkg_apt(){ # 14/06/2018
# essai confOnly
if [ "$1" == "confOnly" ]; then
local apt_unUpgrd cmd_unUpgrd cmd_apt_history essai
local apt_unUpgrd cmd_unUpgrd # cmd_apt_history essai
# apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/!(*.save)" "comment//" )
apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/50unattended-upgrades" "comment//" )
cmd_unUpgrd="grep -Erv '^//|^$' /etc/apt/apt.conf.d/50unattended-upgrades"
@ -2043,7 +2067,7 @@ fi_pkg_apt(){ # 14/06/2018
# extraction qte ugrade, full-upgrade
stck_upgd=$( LC_ALL=C apt-get upgrade --simulate 2>/dev/null )
# $1 upgraded, $6 to remove, $10 not upgraded # => qte_upgradable [0]=upgraded, [1]=notUpgraded
qte_upgradable=( $( awk '/ newly installed/{print $1" "$10}' <<< "$stck_upgd" ) ) # tableau
read -r -a qte_upgradable <<< "$( awk '/ newly installed/{print $1" "$10}' <<< "$stck_upgd" )"
[ "${qte_upgradable[0]}" ] || qte_upgradable=("-1" "-1") # si erreur
# upgrade
if [ $(( qte_upgradable[0] )) -gt 1 ]; then pluriel="s"; else unset pluriel; fi
@ -3622,7 +3646,7 @@ figet_de(){ # 06/03/2018 # thanks neofetch
# shellcheck disable=SC2046,SC2086
# SC2046 Quote this to prevent word splitting
# SC2086 Double quote to prevent globbing and word splitting
figet_disk(){ # 08/03/2018
figet_disk(){ # 18/06/2018
local idisk size type rev type_disk vendor model serial lsblk
declare -a disk_ls disk_lsblk
x_disk=1
@ -3634,12 +3658,12 @@ figet_disk(){ # 08/03/2018
fg_disk_serial="$( printf '%-5s %-10s %-18s %-24s' "disk" "vendeur" "modèle " " n° série" )"$'\n'
for idisk in /sys/block/* ; do # /sys/block/sda ...
idisk=${idisk##*/}
disk_lsblk=( $( lsblk -d -no SIZE,HOTPLUG,REV "/dev/$idisk" ) )
read -r -a disk_lsblk <<< "$( lsblk -d -no SIZE,HOTPLUG,REV "/dev/$idisk" )"
size=${disk_lsblk[0]:-n/a}
type=${disk_lsblk[1]:-n/a}
rev=${disk_lsblk[2]:-n/a}
# ata HITACHI HTS723232A7A364 E3834563HWLWBN
disk_ls=( $( stat -c %N "/dev/disk/by-id/"* | awk -F'/dev/disk/by-id/|-|_' '/'"$idisk"'\047$/ && !/-part/ && !/wwn-/ {gsub(/\047/,"");print $2,$3,$4,$5}' ) )
read -r -a disk_ls <<< \
"$( stat -c %N "/dev/disk/by-id/"* | awk -F'/dev/disk/by-id/|-|_' '/'"$idisk"'\047$/ && !/-part/ && !/wwn-/ {gsub(/\047/,"");print $2,$3,$4,$5}' )"
type_disk=${disk_ls[0]:-n/a}
vendor=${disk_ls[1]:-n/a}
model=${disk_ls[2]:-n/a}
@ -4921,7 +4945,8 @@ for i in "${!options[@]}"; do
# fi_efi fi_locale fi_conf fi_vrms fi_packagers
# fi_reseau fi_nm
# fi_system_analyse fi_journal_xorg fi_journal
fi_system
#~ fi_system
fi_disk
echo
if [ "$DISPLAY" ]; then f_prnt_md "$file_output"; else pager "$file_output"; fi ;;
-c ) exec "$0" "menu" ;; # menu catégorie