getInfo 2.21.0

This commit is contained in:
kyodev 2017-10-30 07:41:12 +01:00
parent 66ba75f211
commit e276817974
2 changed files with 98 additions and 48 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.20.3
date="29/10/2017"
version=2.21.0
date="30/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -302,14 +302,14 @@ f__wget_test(){ # 17/10/2017
exit 0
}
# f_display: $1 variable à afficher, $2=var|cmd|sans (type titrage) [$3 titrage] [$4 commentaire titrage en gras si cmd]
# f_display: $1 variable à afficher, $2=var|cmd|sans|-- (type titrage) [$3 titrage] [$4 commentaire en gras si cmd]
# f_display "variable" "type" "titrage" "titrage_commentaire"
f_display(){ # 25/10/2017
f_display(){ # 30/10/2017
[ "$text" ] && echo -en "$text" >> "$fileOutput" # flush avant fonction de text parent
unset text
local display=""
[[ "$2" == "sans" || "$2" == "var" || "$2" == "cmd" ]] || display="erreur script \$2 ($1 $2 $3)"
[ "$2" == "var" ] && display="**$3** \n"
[[ "$2" == "sans" ||"$2" == "--" || "$2" == "var" || "$2" == "cmd" ]] || display="erreur script \$2 ($1 $2 $3)"
[ "$2" == "var" ] && display="*-*$3** \n"
[ "$2" == "cmd" ] && display="\`$3\` \n"
#echo $(sed -En 's/[^/]*(\/.*)$/\1/p' <<< "$3")
[[ "$2" == "cmd" && "$4" ]] && display="\`$3\` **$4** \n"
@ -358,16 +358,12 @@ cat << 'EOF'
-p : (paste) exporte le rapport markdown existant, durée standard du paste 7 jours
-tn : durée du paste de n jour(s)
-us : upgrade spécial du script (pas de mise à jour auto, maj du script en place)
--ip : affiche ip publique (ipv4/ipv6), infos confidentielles, pas de rapport markdown
--mac : affiche les adresses Mac, infos confidentielles, pas de rapport markdown
--ssid : affiche configurations ssid, infos confidentielles, pas de rapport markdown,
root et NetworkManager requis
--debug-batt : scan valeurs power_supply et rapport markdown
--debug-hw : scan valeurs hwmon et rapport markdown
--debug-dmi : scan valeurs dmi et rapport markdown
-i, --install : installation du script dans le système, root requis
-r, --remove : suppression du script dans le système, root requis
-u, --upgrade : upgrade script installé si maj possible
@ -532,42 +528,54 @@ fi_dmesg(){ # 25/10/2017
unset text
}
fi_graph(){ # 29/10/2017
local slots cards cmd alert_hybrid alert_3D providers preferred current openGl resolutions modules ig text
fi_graph(){ # 30/10/2017
local slots cards prefix_cmd cmd alert_hybrid alert_3D providers preferred current openGl resolutions text
local ig modules glx_dev glx_temp
# cardsManuel="$(lspci -nnk | grep -EiA 3 'vga|display|3d')" # -nn: textual and numeric ID's, k kernel
# cardsManuel="$(lspci -nnv | grep -iEA11 'vga|display|3d)" # v=verbose
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )" si plusieurs devices possibles??
#debug: slots="$(cat tests/lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1)"
# lspci
# slots pci video
slots="$(lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1)"
if [ $(f__cmd_exist optirun) ]; then
for ig in $slots; do
cards+="$(optirun lspci -nnv -s $ig)"$'\n'
done
cmd="optirun lspci -nnv | grep -iEA11 'vga|display|3d'"
else
for ig in $slots; do
cards+="$(DRI_PRIME=1 lspci -nnv -s $ig)"$'\n'
done
cmd="DRI_PRIME=1 lspci -nnv | grep -iEA11 'vga|display|3d'"
# si mult-cartes
[ "$fg_nb_cpu" ] || figet_gpu
if [ "$fg_nb_cpu" -gt 1 ]; then
if [ $(f__cmd_exist optirun) ]; then
prefix_cmd="optirun "
else
prefix_cmd="DRI_PRIME=1 "
fi
cards=${cards::-1} # suppression dernier $'\n'
fi
cards=${cards::-1} # suppression dernier $'\n'
# lspci
for ig in $slots; do
cards+="$($prefix_cmd lspci -nnv -s $ig)"$'\n'
done
cmd="$prefix_cmd lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport
if [ $(grep -c 'Unknown header type 7f' <<< "$cards") -gt 0 ]; then
alert_hybrid="Une carte graphique est désactivée actuellement, lspci n'est pas complet. \n"
alert_hybrid+="Voir DRI_PRIME, vga-switcheroo, Bumbledee...? \n"
fi
# openGl
# openGl / glxinfo
if [ $(f__cmd_exist glxinfo) ]; then
openGl=$( glxinfo | grep -i 'direct rendering' )$'\n'
# devices
glx_dev="$(glxinfo | grep 'Device: ' | xargs)"
if [ "$fg_nb_cpu" -gt 1 ]; then
glx_temp="$(DRI_PRIME=1 glxinfo | grep 'Device: ' | xargs)"
[ $(f__cmd_exist optirun) ] && glx_temp="$(optirun glxinfo | grep 'Device: ' | xargs)"
[ "$glx_dev" != "$glx_temp" ] && glx_dev="$glx_dev"$'\n'"$glx_temp"
fi
openGl=$( glxinfo | grep -i 'direct rendering' ) # variable rectclée plus tard
alert_3D=$(grep -i 'no' <<< $openGl )
openGl+="$( glxinfo | grep 'OpenGL vendor' )"$'\n'
[ "$alert_3D" ] && alert_3D="l'accélération 3D n'est pas active \n\n"
glx_dev+="\n${openGl^}"
# openGL
openGl="$( glxinfo | grep 'OpenGL vendor' )"$'\n'
openGl+="$( glxinfo | grep 'OpenGL renderer' )"$'\n'
openGl+="$( glxinfo | grep 'OpenGL version' )"$'\n'
openGl+="$( glxinfo | grep 'OpenGL shading language version' )"$'\n'
openGl+="$( glxinfo | grep 'OpenGL extensions' )"$'\n'
openGl="$( sed 's/ string//g' <<< "$openGl" )"
fi
[ "$alert_3D" ] && alert_3D="l'accélération 3D n'est pas active \n\n"
# xrandr: résolutions & providers & preferred & current
[ $(f__cmd_exist xrandr) ] && resolutions="$( xrandr --query | grep -A11 'Screen [0-9]' )"
[ $(f__cmd_exist xrandr) ] && providers="$( xrandr --listproviders )"
@ -576,20 +584,21 @@ fi_graph(){ # 29/10/2017
# modules
modules="$(lsmod | grep -Ei 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')"
# fonctions externes
[ "$fget_gpu" ] || figet_gpu
[ "$fg_gpu" ] || figet_gpu
[ "$fget_resolution" ] || figet_screen
###
text="## graphisme \n\n"
[ "$(xargs <<< $fg_gpu)" ] && text="## graphisme \n\n" || text="## graphisme (incomplet) \n\n"
# cartes graphiques
text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fget_gpu) \n\n"
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n"
# nb écran & résolution(s) active(s)
text+="nombre d'écrans: **$fget_nb_screen** \n"
text+="résolution: **$fget_resolution** \n\n"
# lspci
f_display "cards" "cmd" "$cmd"
[ "$cards" ] && f_display "cards" "cmd" "$cmd"
[ "$alert_hybrid" ] && text+="$alert_hybrid \n\n"
# openGl
[ "$openGl" ] && f_display "openGl" "cmd" "glxinfo | grep 'OpenGL"
[ "$glx_dev" ] && f_display "glx_dev" "--"
[ "$openGl" ] && f_display "openGl" "cmd" "glxinfo"
[ "$alert_3D" ] && text+="**$alert_3D** \n"
# liste providers, preferred, current,
[ "$current" ] && f_display "current" "cmd" "xrandr --verbose | grep -A2 '*current'"
@ -1065,7 +1074,7 @@ fi_systeme(){ # 29/10/2017
text+="* CPU \n"
text+=" * **$(sed -n '1p' <<< $fget_cpu)** \n"
text+="* GPU \n"
text+="$(sed -E 's/(.*)/ \* \*\*\1\*\*/' <<<$fget_gpu) \n"
text+="$(sed -E 's/(.*)/ \* \*\*\1\*\*/' <<<$fg_gpu) \n"
text+="* boot **$mbr** \n"
text+="* distribution **$fg_distrib** \n\n"
text+='``` \n'
@ -1426,14 +1435,14 @@ figet_dmi(){ # 29/10/2017
# done
}
# assigne $fget_gpu, bug, expurgé rapidement en attendant ré-écriture
figet_gpu(){ # thanks neofetch, assigne $fget_gpu # 29/10/2017
local gpu="$(lspci -mm | gawk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')"
# debug: gpu="$(cat tests/lspci | gawk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')"
gpu="${gpu//'Corporation'}"
gpu="${gpu//'Advanced Micro Devices, Inc.'/AMD}"
gpu="${gpu// / }"
fget_gpu="$gpu"
# assigne $fg_gpu, fg_nb_cpu
figet_gpu(){ # 30/10/2017
local lspci="$(lspci -mm)"
# debug: lspci="$(< tests/lspci)"
fg_gpu="$(gawk -F' "|" "|" -' ' /"Display|"3D|"VGA/ {
sub(/ Corporation/,"",$3); sub(/Advanced Micro Devices, Inc. /,"",$3); sub(/ /," ",$3);
print $3": "$4}' <<< $lspci)"
fg_nb_cpu=$(echo "$fg_gpu" | wc -l)
}
# infos température et fan via acpi, assigne $fget_hw
@ -1691,13 +1700,13 @@ figet_screen(){ #v2 26/10/2017
fget_resolution="n/a"
[ "$ENV_SSH" ] && fget_resolution+=" (ssh)"
[ "$ENV_SSH" ] && return 0
# xrandr & et xdpyinfo ne retourne pas de nombre écrans correct (multiplex? hybrid?)
# xrandr & et xdpyinfo ne retourne pas de nombre écrans correct (multiplex? hybrid?)
if [ $(f__cmd_exist xrandr) ]; then
resolution=$( gawk '/[0-9]\*/ {gsub(/\*\+/,"",$2); printf "%s pixels (%dHz), ", $1, $2}' <<< $( xrandr --query ) )
elif [ $(f__cmd_exist xdpyinfo) ]; then
resolution=$( gawk '/dimensions/ { print $2, $3 ", " }' <<< $(xdpyinfo) )
fi
resolution="${resolution%,*}"
resolution="${resolution%,*}" # suppression ',*'
fget_resolution="$resolution"
fget_nb_screen=$( grep -o 'pixels' <<< $fget_resolution | grep -c . )
}
@ -1775,6 +1784,15 @@ figet_test_dmi(){ # 21/10/2017
f_display "fget_dmi" "var" "figet_dmi"
}
figet_test_gpu(){ # 30/10/2017
local lspci="$(lspci -mm)"
figet_dmi
f_display "fget_dmi" "var" "gpu test"
f_display "lspci" "cmd" "lspci -mm"
figet_gpu
f_display "fg_gpu" "var" "fg_gpu"
}
figet_test_hw(){ # 22/10/2017
local text var_temp
# matériel
@ -2203,7 +2221,9 @@ for j in $options; do
--debug-all )
prg_1 "$*"
figet_test_batt
figet_test_distrib
figet_test_dmi
figet_test_gpu
figet_test_hw
prg_3
exit ;; # test batterie, dmi, hwmon
@ -2222,6 +2242,11 @@ for j in $options; do
figet_test_dmi
prg_3
exit ;; # test dmi avec affichage /sys/class/dmi/id/
--debug-gpu )
prg_1 "$*"
figet_test_gpu
prg_3
exit ;; # test gpu
--debug-hw )
prg_1 "$*"
figet_test_hw

View File

@ -5,13 +5,24 @@
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
* réseau réviser, interface name: virbr0, docker0
* revoir modules réseau
* revoir modules réseau, ipv6 préfixes
* réviser alert_
* finir révision vrms
* figet_gpu à revoir
* ajouter openrc: OpenRC's built-in init is /usr/bin/openrc-init (tester aussi /usr/bin/init-openrc)
The /etc/openrc/
* défaut affichage alpine linux
---
## 2.21.0 30/10/2017
* nouveau: figet_gpu
* suppression: figet_gpu neofetch
* révision: fi_graph, lspci, cmd & affichage cmd selon nb gpu
## 2.20.3 29/10/2017
* nouveau: figet_distrib
@ -30,6 +41,7 @@
* fix: figet_dmi, markdown
* figet_batt: s/n sur dell i5
## 2.19.1 27/10/2017
* nouveau: option update spécial, script en place
@ -43,6 +55,7 @@
* fix: fi_reseau, détection slot pci, bug sur un pc sour arch
* fix: figet_batt formatage 0 en décimale si unité batterie en W
## 2.18.6 26/10/2017
* nouveau: figet_screen (nb écrans & résolutions)
@ -54,6 +67,7 @@
* fix: suppression s/n batterie si champs rempli d'espace vide
* fix: figet_screen, fix nombre d'écrans
## 2.17.4 25/10/2017
* nouveau: nombre d'écrans
@ -64,6 +78,7 @@
* fix: f_display, affichage sur --debug-*
* fix: correction newlines
## 2.15.0 24/10/2017
* nouveau: début support Bumblebee
@ -81,6 +96,7 @@
* fix: fi_systeme, fi_graph: bug affichage gpu si 2 cartes graphiques
* fix: figet_batt, return meilleur si pas de batterie
## 2.14.0 22/10/2017
* nouveau: détection connexion ssh
@ -96,6 +112,7 @@
* fix: fi_hw, by-pass si pas d'info acpi
* fix: fi_reseau, fi_graph, avertissement modules vide
## 2.13.1 22/10/2017
* f__cmd_exist: nouveau émule et remplace which debian
@ -103,6 +120,7 @@
* révision affichage avec f_display, fin pour tous les fi_
* pluriel sur titrages markdown
## 2.12.1 21/10/2017
* nouveau: ré-écriture figet_cpu (sans température)
@ -110,11 +128,13 @@
* révision: fi_cpu
* révision affichage avec f_display
## 2.11.1 20/10/2017
* révision: figet_hw v2, name, label et filtrage 0°C
* révision: figet_hw_test, figet_test_batt, figet_test_dmi
## 2.10.3 19/10/2017
* nouveau: fi_journal, journaux kernel et non-kernel via journalctl, dmesg en fallback, x premières lignes
@ -129,11 +149,13 @@
* fix: fi_dmesg, niveau emergency & alerte oublié
* fix: partitions en liste
## 2.9.1 18/10/2017
* révision: réécriture figet_disk, renommage variables publiques
* fix: dmesg, variable locale
## 2.8.8 17/10/2017
* nouveau: figet_hw_test, acpi -V si disponible, tests (temporaires) sur
@ -148,6 +170,7 @@
* révision: figet_cpu, suppression affichage température core en attendant mieux
* fix: sr0 compté en disque hotplug (et non fixe)
## 2.7.0 16/10/2017
* f__error f__info f__requis f__wget_test: mineur
@ -156,10 +179,12 @@
* fix: figet_batt, n° de série
* fix: figet_ip, erreur possible entre lo/certain ifn
## 2.6.4 15/10/2017
* révison & fix: f__scandir
## 2.6.3 14/10/2017
* révision: figet_batt: +batt_volt_now, réécriture avec gawk majoritaire, alertes batterie