mirror of https://framagit.org/kyodev/kyopages.git
getInfo 2.64.0
This commit is contained in:
parent
d3696ed13b
commit
76f3e5b446
138
scripts/getInfo
138
scripts/getInfo
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=2.63.0
|
||||
date="12/12/2017"
|
||||
version=2.64.0
|
||||
date="13/12/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getInfo"
|
||||
|
@ -595,10 +595,30 @@ f_prnt_md(){ # 12/12/2017
|
|||
echo -e "$display2"
|
||||
}
|
||||
|
||||
# $1=modules [$2=repertoire spécifique de recherche], affiche emplacements et modules trouvés
|
||||
f_search_ko(){ # 13/12/2017
|
||||
local dir="/lib/modules/$(uname -r)" motif emplacement imod mod_ko
|
||||
|
||||
[ "$1" ] && motif="$1" || return 1
|
||||
[ "$2" ] && dir="$2"
|
||||
motif="($motif|${motif//_/-})\.ko"
|
||||
emplacement=$( du -a "$dir" | grep -Ew "$motif" )
|
||||
if [ "$emplacement" ]; then
|
||||
IFS=$'\n'
|
||||
for imod in $emplacement; do
|
||||
imod=${imod#*$dir}
|
||||
mod_ko+=" => $imod"$'\n'
|
||||
done
|
||||
IFS="$IFS_INI"
|
||||
mod_ko=${mod_ko%[[:cntrl:]]} # suppression \n final
|
||||
fi
|
||||
echo -e "$mod_ko"
|
||||
}
|
||||
|
||||
# [$1=silent], assigne fe_nb_audio, fe_cards_audio
|
||||
fi_audio(){ # 8/12/2017
|
||||
fi_audio(){ # 13/12/2017
|
||||
local cardsAudio cmd_cards version_alsa card_alsa cmd_card_alsa cmt_card_alsa pluriel text
|
||||
local mod_alsa cmd_mod_alsa cmt_mod_alsa mod cmd_mod cmt_mod
|
||||
local mod_alsa cmd_mod_alsa cmt_mod_alsa modAudio cmd_modAudio cmt_modAudio
|
||||
local alert_alsa
|
||||
|
||||
# devices
|
||||
|
@ -607,6 +627,7 @@ fi_audio(){ # 8/12/2017
|
|||
[ "$1" == "silent" ] && return 0 # pas d"affichage
|
||||
[ "$fe_nb_audio" -eq 0 ] && return 0
|
||||
###
|
||||
|
||||
# lspci
|
||||
cardsAudio=$( figet_lspci "audio" "raw" )
|
||||
cmd_cards="lspci -nnv | grep -EiA6 'Audio device|Audio controller'"
|
||||
|
@ -632,11 +653,11 @@ fi_audio(){ # 8/12/2017
|
|||
cmd_mod_alsa="cat /proc/asound/modules"
|
||||
cmt_mod_alsa="module"$pluriel" alsa"
|
||||
# modules kernel
|
||||
figet_modules "audio" "$mod_alsa"
|
||||
mod="$fg_modules" # modules chargés
|
||||
cmd_mod="lsmod | grep -Ew '$fg_srch_mod'"
|
||||
[ "$( f__wcv -l "$mod" )" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
cmt_mod="$( f__wcv -l "$mod" ) module"$pluriel" utilisé"$pluriel
|
||||
figet_lspci "audio" "module" &>/dev/null # obtention module utilisé
|
||||
modAudio="$fg_modules_lp"
|
||||
cmd_modAudio="lsmod | grep -Ew '$fg_srch_mod_lp'"
|
||||
[ "$( f__wcv -wv "$modAudio" "^[[:alnum:]]" )" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
cmt_modAudio="$( f__wcv -wv "$modAudio" "^[[:alnum:]]" ) module"$pluriel" utilisé"$pluriel
|
||||
fi
|
||||
###
|
||||
f_prnt titre2 "audio"
|
||||
|
@ -648,7 +669,7 @@ fi_audio(){ # 8/12/2017
|
|||
f_dspl cmd "$version_alsa" "/proc/asound/version" "driver alsa (Advanced Linux Sound Architecture)"
|
||||
f_dspl cmd "$card_alsa" "$cmd_card_alsa" "$cmt_card_alsa"
|
||||
f_dspl cmd "$mod_alsa" "$cmd_card_alsa" "$cmt_card_alsa"
|
||||
f_dspl cmd "$mod" "$cmd_mod" "$cmt_mod"
|
||||
f_dspl cmd "$modAudio" "$cmd_modAudio" "$cmt_modAudio"
|
||||
}
|
||||
|
||||
fi_batt(){ # 9/12/2017
|
||||
|
@ -663,27 +684,23 @@ fi_batt(){ # 9/12/2017
|
|||
}
|
||||
|
||||
# [$1=silent] (pas d'affichage), assigne $fe_nb_bluez, $fe_cards_bluez
|
||||
fi_bluez(){ # 8/12/2017
|
||||
fi_bluez(){ # 13/12/2017
|
||||
local bluez cmd_bluez cmt_bluez mod cmd_mod cmt_mod pluriel text
|
||||
local alert_na
|
||||
|
||||
if [ $( f__which hciconfig ) ]; then
|
||||
fe_nb_bluez=$( hciconfig name 2>/dev/null ) || alert_na="PB" # stck tempo du retour hciconfig
|
||||
if hcitool scan &>/dev/null && [[ $( f__which hciconfig ) ]]; then
|
||||
fe_nb_bluez=$( hciconfig name 2>/dev/null )
|
||||
fe_cards_bluez=$( grep -Eo '^hci[0-9]+' <<< $fe_nb_bluez )
|
||||
fe_nb_bluez=$( grep -c '^hci[0-9].*$' <<< $fe_nb_bluez )
|
||||
fe_cards_bluez=${fe_cards_bluez//[[:cntrl:]]/ }
|
||||
fe_cards_bluez=${fe_cards_bluez//[[:cntrl:]]/ } # mise en liste inline
|
||||
else
|
||||
fe_nb_bluez=0
|
||||
fi
|
||||
[ "$1" == "silent" ] && return 0
|
||||
###
|
||||
[ "$alert_na" ] && alert_na="Bluetooth inaccessible"
|
||||
f_dspl_alrt "$alert_na" "alert"
|
||||
[ "$fe_nb_bluez" -eq 0 ] && return 0
|
||||
[[ "$1" == "silent" || "$fe_nb_bluez" -eq 0 ]] && return 0
|
||||
|
||||
###
|
||||
# état
|
||||
bluez=$( hciconfig -a )
|
||||
[ "$( grep -c '^hci[0-9]' <<< "$card_alsa" )" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
[ "$( grep -c '^hci[0-9]' <<< "$bluez" )" -gt 1 ] && pluriel="s" || unset pluriel
|
||||
cmd_bluez="hciconfig -a"
|
||||
cmt_bluez="état périphérique"$pluriel
|
||||
# modules
|
||||
|
@ -700,12 +717,15 @@ fi_bluez(){ # 8/12/2017
|
|||
[ "$mod" ] || f_dspl sans "$fg_mod_motif" "" "pas de modules en mémoire parmi:"
|
||||
}
|
||||
|
||||
fi_conf(){ # 3/12/2017
|
||||
fi_conf(){ # 13/12/2017
|
||||
local confs toScrut=(
|
||||
'/etc/default/grub'
|
||||
# '/boot/grub/grub.cfg' # pour info
|
||||
# '/etc/grub.d/' # pour info
|
||||
'/etc/sysctl.conf'
|
||||
'/etc/sysctl.d/*.conf'
|
||||
'/etc/hostname' # debian
|
||||
'/etc/sysconfig/network' # fedora?
|
||||
'/etc/sysconfig/network' # fedora?
|
||||
'/etc/HOSTNAME' # suse
|
||||
# /etc/os-release # nouveau standard systemd/freedesktop
|
||||
'/etc/vconsole.conf'
|
||||
|
@ -715,8 +735,9 @@ fi_conf(){ # 3/12/2017
|
|||
# /etc/machine-id # voir fi-serial
|
||||
'/etc/modules-load.d/*.conf' #modules to load at boot time
|
||||
'/etc/machine-info'
|
||||
'/etc/modprobe.d/*.conf' # blacklist modules
|
||||
'/etc/modprobe.d/*.conf' # blacklist modules
|
||||
'/etc/systemd/system/*/override.conf' # éditions services
|
||||
'/etc/discover-modprobe.conf'
|
||||
)
|
||||
|
||||
confs=$( f_grep_file "${toScrut[*]}" "noinexist" )
|
||||
|
@ -1353,22 +1374,22 @@ fi_mem(){ # 5/12/2017
|
|||
}
|
||||
|
||||
# [$1=silent], assigne fe_nb_reseau, fe_cards_reseau
|
||||
fi_net(){ # 8/12/2017 ( matériel )
|
||||
fi_net(){ # 13/12/2017 ( matériel )
|
||||
local cards cmd_cards modEth cmd_modEth cmt_modEth modWln cmd_modWln cmt_modWln pluriel text
|
||||
local alert_wlx
|
||||
|
||||
# devices
|
||||
fe_cards_reseau=$( figet_lspci "net" "name" )
|
||||
fe_nb_reseau=$(f__wcv -l "$fe_cards_reseau")
|
||||
fe_cards_reseau=$( figet_lspci "net" "name" ) # noms des cartes réseau détectées, mix ethernet/wifi
|
||||
fe_nb_reseau=$(f__wcv -l "$fe_cards_reseau") # nombre de cartes réseau détectées, mix ethernet/wifi
|
||||
[ "$1" == "silent" ] && return
|
||||
[ "$fe_nb_reseau" -eq 0 ] && return 0 # pas de cartes réseau, rien à voir (en attendant usb ou autre)
|
||||
###
|
||||
# lspci
|
||||
cards=$( figet_lspci "net" "raw" )
|
||||
cmd_cards="lspci -nnv | grep -EiA 15 'network|ethernet'"
|
||||
# cardsManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')"
|
||||
# cardsManuel="$(lspci -nnv | grep -EiA 15 'network|ethernet')"
|
||||
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'network|ethernet' | cut -d" " -f1 )" si devices plusieurs slots???
|
||||
# lspci -nnk | grep -EiA 3 'network|ethernet'
|
||||
# lspci -nnv -s $( lspci | grep -Ei 'network' | cut -d" " -f1 )
|
||||
# lspci -nnv -s $( lspci | grep -Ei 'ethernet' | cut -d" " -f1 )
|
||||
|
||||
#modules ethernet
|
||||
figet_lspci "ethernet" "module" &>/dev/null # obtention module utilisé
|
||||
|
@ -3303,8 +3324,8 @@ figet_ip_pub(){ # 20/11/2017
|
|||
# $1=audio|video|net & audio|ethernet|wireless, $2 objet raw|name|module, $3=[graph] (optirun, DRI),
|
||||
# affiche device (name), lspci détail (raw)
|
||||
# pour module (module kernel), video|ethernet|wireless, assigne $fg_modules_lp $fg_srch_mod_lp
|
||||
figet_lspci(){ # 12/12/2017
|
||||
local motif slots lspci display='' prefixCmd modLspci dir modules mod_emplac imod mod_ko
|
||||
figet_lspci(){ # 13/12/2017
|
||||
local motif slots lspci display='' prefixCmd modLspci mod_file
|
||||
|
||||
if [ "$1" = "audio" ]; then
|
||||
motif="Audio device|Audio controller|Multimedia audio controller"
|
||||
|
@ -3337,11 +3358,12 @@ figet_lspci(){ # 12/12/2017
|
|||
display+="$lspci "$'\n'
|
||||
done <<< $( lspci | grep -Ei "$motif" )
|
||||
|
||||
# lspci détaillé
|
||||
# lspci détaillé RAW || MODULE
|
||||
elif [[ "$2" == "raw" || "$2" == "module" ]]; then
|
||||
slots=$( lspci | grep -Ei "$motif" | cut -d" " -f1 )
|
||||
if ! lspci -nnv &>/dev/null ; then # commande/option indisponible
|
||||
display="lspci -nnv -s <device> non disponible"
|
||||
return 1
|
||||
else
|
||||
for lspci in $slots; do
|
||||
if [[ "$3" == "graph" && "$( f__which optirun )" ]]; then
|
||||
|
@ -3360,6 +3382,7 @@ figet_lspci(){ # 12/12/2017
|
|||
# module kernel
|
||||
if [ "$2" == "module" ]; then
|
||||
fg_modules_lp=''
|
||||
[ "$lspci" ] || return 1
|
||||
# module utilisé
|
||||
modLspci=$( gawk -F ': ' '
|
||||
/Kernel modules/ {print $2}
|
||||
|
@ -3368,18 +3391,11 @@ figet_lspci(){ # 12/12/2017
|
|||
modLspci=${modLspci%|} # si | final
|
||||
modLspci=${modLspci#|} # si | au début
|
||||
# modules et emplacement
|
||||
dir="/lib/modules/$(uname -r)"
|
||||
fg_modules_lp=$( lsmod | grep -Ew "$modLspci" )
|
||||
mod_emplac=$( du -a "$dir" | grep -Ew "$modLspci\.ko" ) # emplacement
|
||||
if [ "$mod_emplac" ]; then
|
||||
IFS=$'\n'
|
||||
for imod in $mod_emplac; do
|
||||
imod=${imod#*$dir}
|
||||
mod_ko+=" => $imod"$'\n'
|
||||
done
|
||||
IFS="$IFS_INI"
|
||||
mod_ko=${mod_ko%[[:cntrl:]]}
|
||||
fg_modules_lp="$fg_modules_lp\n\n$mod_ko"
|
||||
|
||||
mod_file=$( f_search_ko "$modLspci" )
|
||||
if [ "$mod_file" ]; then
|
||||
fg_modules_lp="$fg_modules_lp\n\n$mod_file"
|
||||
fi
|
||||
fg_srch_mod_lp="$modLspci"
|
||||
return
|
||||
|
@ -3459,9 +3475,9 @@ figet_mem(){ # 9/12/2017
|
|||
[ "$fg_mem" ] && fg_mem=${fg_mem::-1} # suppression dernier $'\n'
|
||||
}
|
||||
|
||||
# $1=bluetooth|audio [$2=moduleAChercher(audio)], assigne $fg_modules, $fg_mod_motif, fg_srch_mod
|
||||
figet_modules(){ # 12/12/2017
|
||||
local modules dir separator mod_emplac imod mod_ko
|
||||
# $1=bluetooth, assigne $fg_modules, $fg_mod_motif, fg_srch_mod
|
||||
figet_modules(){ # 13/12/2017
|
||||
local modules dir separator mod_ko
|
||||
|
||||
if [ "$1" == "bluetooth" ]; then
|
||||
dir="/lib/modules/$(uname -r)/kernel/drivers/bluetooth" # répertoire à scruter
|
||||
|
@ -3474,12 +3490,8 @@ figet_modules(){ # 12/12/2017
|
|||
modules=${modules//$separator/$'\n'}
|
||||
modules=$( sort <<< $modules )
|
||||
modules=${modules//$'\n'/$separator}
|
||||
elif [ "$1" == "audio" ]; then
|
||||
dir="/lib/modules/$(uname -r)"
|
||||
modules=$( sort -u <<< "$2" )
|
||||
modules=${modules//$'\n'/$separator}
|
||||
modules=${modules%$separator} # suppression dernier séparateur
|
||||
fi
|
||||
modules=${modules%$separator} # suppression dernier séparateur
|
||||
# recherche modules chargés
|
||||
fg_modules="$( lsmod | grep -Ew "$modules" )"
|
||||
# motif de recherche des modules trouvés dans le kernel
|
||||
|
@ -3491,16 +3503,8 @@ figet_modules(){ # 12/12/2017
|
|||
# extraction 1ère lignes modules chargés = module kernel
|
||||
fg_srch_mod=$( gawk '{ print $1; exit }' <<< $fg_modules )
|
||||
# recherche emplacement modules
|
||||
mod_emplac=$( du -a "$dir" | grep -Ew "$fg_srch_mod\.ko" ) # emplacement
|
||||
if [ "$mod_emplac" ]; then
|
||||
IFS=$'\n'
|
||||
dir="/lib/modules/$(uname -r)"
|
||||
for imod in $mod_emplac; do # si $mod_emplac sort plusieurs lignes
|
||||
imod=${imod#*$dir}
|
||||
mod_ko+=" => $imod"$'\n'
|
||||
done
|
||||
IFS="$IFS_INI"
|
||||
mod_ko=${mod_ko%[[:cntrl:]]}
|
||||
mod_ko=$( f_search_ko "$fg_srch_mod" )
|
||||
if [ "$mod_ko" ]; then
|
||||
fg_modules="$fg_modules\n\n$mod_ko"
|
||||
fi
|
||||
}
|
||||
|
@ -3563,7 +3567,7 @@ figet_shell(){ #v2 25/11/2017 # thanks neofetch
|
|||
}
|
||||
|
||||
# debian indépendant, assigne $fg_ucode (commentaire), $ucode (paquet deb) & return O|1 (1 si pas d'installation)
|
||||
figet_ucode(){ # 29/11/2017
|
||||
figet_ucode(){ # 13/12/2017
|
||||
local flagRep xfile xfileTest=""
|
||||
# recherche flags cpu rep_good (besoin réel?)
|
||||
[ "$( grep -cm1 'flags.*rep_good ' /proc/cpuinfo )" -ge 1 ] && flagRep="rep_good ⟷ rep microcode works well"
|
||||
|
@ -3571,11 +3575,6 @@ figet_ucode(){ # 29/11/2017
|
|||
[ "$fg_cpu" ] || figet_cpu
|
||||
[ "${fg_vendor,,}" == "amd" ] && ucode="amd64-microcode" # si $ucode, µmicorcode possible (amd|intel)
|
||||
[ "${fg_vendor,,}" == "intel" ] && ucode="intel-microcode"
|
||||
# version debian, à supprimer à terme après essai sur autre distrib
|
||||
# if [ "$ENV_DEBIAN" ]; then # debian ?
|
||||
# f__requis "$ucode" "debOnly"
|
||||
# [ "$debOnlyAbsent" == "$ucode" ] && return 1 || return 0
|
||||
# fi
|
||||
# test emplacements possibles
|
||||
amd64=(
|
||||
/etc/default/amd64-microcode
|
||||
|
@ -4069,7 +4068,8 @@ for j in $options; do
|
|||
ORIGIN='test'
|
||||
prg_1 "$*"
|
||||
echo -n "•"
|
||||
fi_hw
|
||||
fi_bluez
|
||||
fi_net
|
||||
echo; f_prnt_md "$fileOutput"
|
||||
exit ;; # test
|
||||
-c* | all )
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
# changelog getInfo
|
||||
|
||||
f__dialog_oui_non, f__dir
|
||||
|
||||
|
||||
## getInfo 2.64.0 13/12/2017
|
||||
|
||||
* révision: fi_bluez, détection device
|
||||
* révision: fi_conf, nouveau fichiers
|
||||
* révision: fi_audio, figet_lspci, figet_modules, détection modules par figet_lspci
|
||||
* révision: figet_lspci, figet_modules, détection commune fichier f_search_ko
|
||||
* ménage: figet_ucode
|
||||
* fix majeur: figet_lspci, détection erronée si interface manquante
|
||||
|
||||
## getInfo 2.63.0 12/12/2017
|
||||
|
||||
|
|
Loading…
Reference in New Issue