getInfo 2.29.0

This commit is contained in:
kyodev 2017-11-10 12:47:20 +01:00
parent fa0d125f1b
commit c521955148
2 changed files with 222 additions and 172 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.28.0
date="09/11/2017"
version=2.29.0
date="10/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -130,11 +130,11 @@ f__log(){ # 27/10/2017
}
# test dépendances/paquets, $1 liste commande[>paquet] (ex: killall>psmisc)
# si manque, SORTIE & info commandes manquantes, si debian, SORTIE & proposition paquet à installer
# si manque, return 1 & info commandes manquantes, si debian proposition paquet à installer
# si $2=debOnly et si paquets manquants: return 1 et $debOnlyPackages ( $1=liste paquets )
# si $2=debOnly et si paquets présent: return 0 et $debOnlyPresents ( $1=liste paquets )
# attention priorité $debOnlyPackages sur $debOnlyPresents
f__requis(){ # 22/10/2017
f__requis(){ # 10/11/2017
local dependsMissing packagesMissing command package ireq compteur pluriel
unset debOnlyPackages debOnlyPresents
for ireq in $1; do
@ -160,19 +160,20 @@ f__requis(){ # 22/10/2017
compteur="$(wc -w <<< $dependsMissing)"
[ "$compteur" -gt "1" ] && pluriel="s" || unset pluriel
if [ -e /etc/debian_version ]; then
f__error "$compteur paquet$pluriel manquant$pluriel: $STD$BOLD$dependsMissing" \
f__info "$RED""erreur critique: $compteur paquet"$pluriel" manquant"$pluriel": $STD$BOLD$dependsMissing" \
"\n vous devriez exécuter:$GREEN apt install $packagesMissing"
else
f__error "$compteur commande$pluriel manquante$pluriel: $STD$BOLD$dependsMissing";
f__info "$RED""erreur critique: $compteur commande"$pluriel" manquante"$pluriel": $STD$BOLD$dependsMissing"
fi
return 1
fi
}
# $1=rep à scanner [$2=profondeur max|4 défaut] [$3=profondeur encours|0 défaut]
# affichage stdout si $fileOutput non définis, /usr/bin/strings (binutils) requis
f__scandir(){ # 17/10/2017
f__scandir(){ # 10/11/2017
[ -d "$1" ] || f__error "erreur sur le répertoire à scanner"
f__requis "strings>binutils" # requis pour fonctionnement programme
f__requis "strings>binutils" || exit 1
local repToScan irep rc text prof prof_max tempo
[ "${1: -1}" == "/" ] && repToScan="$1" || repToScan="$1/" # ajout / final si besoin
[ "$2" ] && prof_max="$2" || prof_max=4 # profondeur max par défaut si besoin
@ -258,13 +259,13 @@ f__user(){ # 09/10/2017
}
# $1='-l' comptage ligne dans variable $2, affiche quantité
# $1='-w' comptage mots dans variable $2, affiche quantité /!\ pas d'espace final (comptage espaces)
# $1='-wv' comptage mots $3 dans variable $2, affiche quantité
# $1='-w' comptage dans variable $2 des mots
# $1='-wv' comptage dans variable $2, des mots $3, affiche quantité
# f__wcv -l $var ; f__wcv -w $var ; f__wcv -wv $var "mot"
f__wcv(){ # 04/11/2017
f__wcv(){ # 09/11/2017
[[ "$1" =~ -l|-wv|-w ]] || display="erreur f__wcv \$1 ($1) incorrect \n"
[ "$1" == "-l" ] && echo "$2" | grep -cEv '^[[:space:]]*$' # (wc -l compterait 1 pour une variable vide)
[ "$1" == "-w" ] && echo "$2 " | grep -o " " | grep -c . # echo $(( $(grep -c .)+1 ))
[ "$1" == "-w" ] && echo "$(xargs <<< $2) " | grep -o " " | grep -c . # echo $(( $(grep -c .)+1 ))
[ "$1" == "-wv" ] && echo "$2" | grep -o "$3" | grep -c .
}
@ -317,16 +318,18 @@ f__wget_test(){ # 06/11/2017
exit 0
}
# f_display: $1 variable à afficher, $2=var|cmd|sans (type titre) [$3 titre] [$4 commentaire en gras si cmd]
# f_display "variable" "type" "titrage" "titrage_commentaire"
# $1 variable à afficher, $2=var|cmd|sans (type titre) [$3 titre] [$4 commentaire en gras si cmd]
# $2: cmd->`titre`, var->**titre**, sans: pas de titre
f_display(){ # 08/11/2017
# un test si variable $1 est vide ou non est fait
# f_display "variable" "type" "titrage" "titrage_commentaire"
f_display(){ # 10/11/2017
# flush, avant fonction, de text parent
[ "$text" ] && echo -en "$text" >> "$fileOutput"
unset text
# coeur fonction
local display=""
[[ "$2" =~ sans|var|cmd ]] || display="erreur script \$2 ($1 $2 $3) \n" # test $2 valide
[ "${!1}" ] || return 0 # test si contenu dans $1
[[ "$2" =~ sans|var|cmd ]] || display=" **⚡ erreur f_display \$2 ($1 $2 $3) ⚡** \n" # test $2 valide
[ "$2" == "var" ] && display="**$3**" # type var, titre en gras
[ "$2" == "cmd" ] && display="\`$3\`" # type cms, titre entre `
[ "$4" ] && display+=$'\xc2\xa0'$'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0'" ($4)" # +$4 en gras avec 5 espaces insécables avant
@ -337,42 +340,32 @@ f_display(){ # 08/11/2017
echo -en "$display \n" >> "$fileOutput" # flush fonction
}
# f_dspl_alert: $1 variable à afficher en alerte/info
f_dspl_alert(){ # 09/11/2017
# $1 variable à afficher en alerte/info, [$2 alert|info] type de message, alert par défaut
# un test si variable $1 est vide ou non est fait
f_dspl_alert(){ # 10/11/2017
# flush, avant fonction, de text parent
[ "$text" ] && echo -en "$text" >> "$fileOutput"
unset text
# coeur fonction
[ "${!1}" ] && text+="> ${!1} \n\n"
local display type
[ "${!1}" ] || return 0 # test si contenu dans $1
[[ "$2" =~ alert|info ]] && type="$2" || type="alert"
[ "$type" == "alert" ] && display="\n> ❗ ${!1} \n\n"
[ "$type" == "info" ] && display="\n ☛ ${!1} \n\n"
echo -en "$display \n" >> "$fileOutput" # flush fonction
}
# $1 fichier testé
f_dspl_file_ko(){ # 03/11/2017
f_dspl_file_KO(){ # 03/11/2017
echo -e "* fichier **$1** non trouvé ou absent \n" >> "$fileOutput"
}
# $$=liste fichiers à greper, [$2] largeur 1ere colonne
f_dspl_grep(){ # 07/11/2017
local file var_temp
for file in $1; do
var_temp="$(grep -Ersv '^#|^[[:space:]]*$' $file)"
[ "$var_temp" ] && echo " $file"
if [ "$2" ]; then
gawk -v "larg=$2" '{printf "%-"larg"s",$1; s1=""; printf "%s\n",$0}' <<< "$var_temp"
else
echo "$var_temp"
fi
echo
done
}
# $1 file à parser
# epure markdown pour affichage en console, $1 file à parser
# tout en bash pour regex par défaut non-greedy (non gourmand) comme sed ou gawk
# contrainte markdown:
# l'italique avec _ ou * n'est pas géré, trop d'interférences potentielles
# liste niveau2: 3 ou 4 caractères, niveau3: 6 ou 8 caractères, puce * ou -
f_dspl_md(){ # 09/11/2017
f_dspl_md(){ # 10/11/2017
local display display2 ifs_origin
if [ ! -f "$1" ]; then
f__info "pas de rapport à afficher, vous devez lancer une analyse auparavant:" \
@ -380,7 +373,7 @@ f_dspl_md(){ # 09/11/2017
return 0
fi
display=$(< $1)
display=${display//\`\`\`/--} # transforme ``` en --, plus visibles
display=${display//\`\`\`/---} # transforme ``` en ---, plus visibles
# traitement par lignes, ala sed, obligatoire pour les titres #
# plus simple pour les multi-patterns, sinon matches multilignes délicats à gérer en cas d'impairage
ifs_origin="$IFS"
@ -394,6 +387,10 @@ f_dspl_md(){ # 09/11/2017
[[ "$ligne" =~ ^(#{3}[^#].*)$ ]] && ligne="\x1B[32m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# #### TITRE 4 yellow
[[ "$ligne" =~ ^(#{4}[^#].*)$ ]] && ligne="\x1B[33m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# interne message alert, red
[[ "$ligne" =~ ( ❗ .*)$ ]] && ligne="\x1B[31m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# interne message indo, blue
[[ "$ligne" =~ ( ☛ .*)$ ]] && ligne="\x1B[34m"${BASH_REMATCH[1]}"\x1B(B\x1B[m"
# **gras**
while [[ "$ligne" =~ (.*)\*{2}(.*)\*{2}(.*) ]]; do
ligne=${BASH_REMATCH[1]}'\x1B[1m'${BASH_REMATCH[2]}'\x1B(B\x1B[m'${BASH_REMATCH[3]}
@ -435,6 +432,21 @@ f_dspl_scandir(){ # 21/10/2017
echo -e "$text" >> "$fileOutput" # flush fonction
}
# $1=liste fichier(s) à greper, [$2]: largeur 1ere colonne | file si un seul fichier
f_grep_file(){ # 07/11/2017
local file var_temp
for file in $1; do
var_temp="$(grep -Ersv '^[[:blank:]]*#|^[[:blank:]]*$' $file)"
[[ "$2" != "file" && "$var_temp" ]] && echo " $file"
if [[ "$2" =~ [0-9] ]]; then
gawk -v "larg=$2" '{printf "%-"larg"s",$1; s1=""; printf "%s\n",$0}' <<< "$var_temp"
else
echo "$var_temp"
fi
echo
done
}
f_help(){ # 06/11/2017
printf "$BLUE"
cat << 'EOF'
@ -761,42 +773,48 @@ SMCA ⟷ Scalable MCA
}
fi_disk(){ # 09/11/2017
local disk_lsblk disk_df disk_df_i fstab resume idResume idSwap dd_temp tempodd idisk text pluriel
local alert_uuidResume alert_dd_temp
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
disk_df="$(df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
disk_df_i="$(df -i --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
fstab="$(grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/fstab)"
resume="$(grep -Evs '^[[:blank:]]*#|^[[:space:]]*$' /etc/initramfs-tools/conf.d/resume)"
if [ -z "$resume" ]; then
# alert resume absent
resume="Pas de fichier _resume_ dans /etc/initramfs-tools/conf.d/ \n"
resume+="Ce n'est pas (forcément) une erreur. \n"
resume+="La plus grosse partition swap est choisie dans ce cas. \n"
resume+="À investiguer si erreur au boot ou boot très long. "
fi
idResume="$(grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p')"
idSwap="$(grep -Ev '^[[:blank:]]*#|^$' /etc/fstab | sed -En 's/UUID=([0-9a-Z-]*).*swap.*$/\1/p')"
if [ "$idSwap" ] && [ "$idResume" ] && [ "$idSwap" != "$idResume" ]; then
alert_uuidResume+="id swap : $idSwap \nid resume: $idResume\n"
alert_uuidResume+="**vérifier la config resume**, l'UUID ne correspond pas à celui du swap. \n"
alert_uuidResume+="vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_, voir supprimer ce fichier"
fi
[ "$fg_nb_disk" ] || figet_disk
local dd_temp="" disk_df disk_df_i disk_lsblk fstab resume idResume idSwap idisk text pluriel
local alert_dd_temp="" alert_file_resume alert_uuidResume
# éventuellement hddtemp
if [ "$(f__cmd_exist hddtemp)" ]; then
unset dd_temp alert_dd_temp
for idisk in $fg_disk_fixe; do
[ -r "/dev/$idisk" ] || continue
tempodd="$(LC_ALL=C hddtemp /dev/$idisk | cut -d ':' -f3 | sed 's/[^0-9]*//g; /not available/d')"
dd_temp+="$idisk: $tempodd °C"$'\n'
[ "$tempodd" -ge 50 ] && alert_dd_temp+="/!\ $idisk: température > 50°C) "$'\n'
dd_temp="$(LC_ALL=C hddtemp /dev/$idisk | cut -d ':' -f3 | sed 's/[^0-9]*//g; /not available/d')"
[ "$dd_temp" -ge 50 ] && alert_dd_temp+="$idisk: température > 50°C"$'\n'
dd_temp+="$idisk: $dd_temp °C"$'\n'
done
[ "$dd_temp" ] && dd_temp=${dd_temp::-1} # suppression dernier $'\n'
[ "$alert_dd_temp" ] && alert_dd_temp=${alert_dd_temp::-1} # suppression dernier $'\n'
fi
# df, espaces des partitions montées seules
disk_df="$(df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
# df -i, inoeuds
disk_df_i="$(df -i --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
# lsblk répertoire disques & partitions
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
# fstab
fstab="$(f_grep_file "/etc/fstab" "file")"
# resume
resume="$(f_grep_file "/etc/initramfs-tools/conf.d/resume" "file")"
if [ -z "$resume" ]; then
# alert resume absent
alert_file_resume="Pas de fichier _resume_ dans /etc/initramfs-tools/conf.d/ \n"
alert_file_resume+="Ce n'est pas (forcément) une erreur, la plus grosse partition swap est "
alert_file_resume+="choisie dans ce cas. \n"
alert_file_resume+="À investiguer si erreur au boot ou boot très long."
fi
idResume="$(grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p')"
idSwap="$(grep -Ev '^[[:blank:]]*#|^$' /etc/fstab | sed -En 's/UUID=([0-9a-Z-]*).*swap.*$/\1/p')"
if [ "$idSwap" ] && [ "$idResume" ] && [ "$idSwap" != "$idResume" ]; then
alert_uuidResume+="vérifier la config resume, l'UUID ne correspond pas à celui du swap. \n"
alert_uuidResume+="id swap : $idSwap \nid resume: $idResume\n"
alert_uuidResume+="vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_, voir supprimer ce fichier"
fi
[ "$fg_nb_disk" ] || figet_disk
###
[ "$fg_nb_disk" -gt 1 ] && pluriel="s" || unset pluriel
text="## disque$pluriel \n\n"
text="## disque"$pluriel" \n\n"
# espace des partitions fixes montées
text+="* $(gawk -F': ' '{print $1": **"$2"**"}' <<< $fg_disk_part_fix_tot) \n\n"
text+='``` \n'
@ -826,27 +844,23 @@ fi_disk(){ # 09/11/2017
text+="| $fg_disk_ata | $fg_disk_usb | $fg_disk_mmc | $fg_disk_nvme | \n\n"
# éventuellement hddtemp
[ "$dd_temp" ] && f_display "dd_temp" "cmd" "hddtemp /dev/sd?" "température disques"
if [ "$alert_dd_temp" ]; then
text+="$alert_dd_temp \n"
text+="$alert_dd_temp_text \n\n"
fi
# df, espaces des partitions montées seules
f_dspl_alert "alert_dd_temp" "info"
# df, espaces des partitions montées seules
f_display "disk_df" "cmd" \
"df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs" \
"utilisation disques"
# df -i, inoeuds
f_display "disk_df_i" "cmd" "df -i --exclude=tmpfs --exclude=devtmpfs" "utilisation inoeuds"
# lsblk
[ "$disk_lsblk" ] && f_display "disk_lsblk" "cmd" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" \
# lsblk répertoire disques & partitions
f_display "disk_lsblk" "cmd" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" \
"disques & partitions"
# fstab
f_display "fstab" "cmd" "grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/fstab" "fstab"
f_display "fstab" "cmd" "grep -Ev '^#|^$' /etc/fstab" "fstab"
# resume
f_display "resume" "cmd" "grep -Evs '^[[:blank:]]*#|^[[:space:]]*$' /etc/initramfs-tools/conf.d/resume" \
f_display "resume" "cmd" "grep -Evs '^#|^$' /etc/initramfs-tools/conf.d/resume" \
"resume"
if [ "$alert_uuidResume" ]; then
text+="$alert_uuidResume \n\n"
fi
f_dspl_alert "alert_file_resume" "info"
f_dspl_alert "alert_uuidResume" "alert"
printf "$text\n" >> "$fileOutput"
unset text
}
@ -892,28 +906,28 @@ fi_dmesg(){ # 08/11/2017
unset text
}
fi_graph(){ # 08/11/2017
local slots cmd alert_hybrid alert_3D providers preferred current openGl resolutions text
local ig modules glx_dev glx_temp cards
fi_graph(){ # 10/11/2017
local slots ig cmd cards glx_dev glx_dev_temp test_3D openGl providers resolutions pluriel modules text
local alert_hybrid alert_3D
# 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??
{
[ "$fg_nb_gpu" ] || figet_gpu
[ "$fg_nb_gpu" -eq 0 ] && return 0 # pas de gpu, rien à voir
# bus slots pci video
slots="$(lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1)"
# lspci
cmd="lspci -nnv | grep -iEA11 'vga|display|3d'" # commande par défaut à afficher dans le rapport
if ! lspci -nnv &>/dev/null ; then # commande/option indisponible
cards="lspci -nnv non disponible"$'\n'
elif [ "$fg_nb_gpu" -eq 0 ]; then # 0 cartes
cards="pas de carte graphique"$'\n'
elif [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, essai optirun et prime
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'" # commande à afficher dans le rapport
else
else # DRI
for ig in $slots; do
cards+="$(DRI_PRIME=1 lspci -nnv -s $ig)"$'\n'
done
@ -926,62 +940,71 @@ fi_graph(){ # 08/11/2017
fi
cards=${cards::-1} # suppression dernier $'\n'
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
alert_hybrid="Une carte graphique semble désactivée actuellement, lspci n'est pas complet. \n"
alert_hybrid+="Voir DRI_PRIME, vga-switcheroo, Bumbledee...?"
fi
# openGl / glxinfo
if [ $(f__cmd_exist glxinfo) ]; then
# devices
glx_dev="$(glxinfo | grep 'Device: ' | xargs)"
if [ "$fg_nb_gpu" -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"
test_3D=$( glxinfo | grep -i 'direct rendering' )
if [ "$(grep -i 'no' <<< $test_openGl )" ]; then
alert_3D="l'accélération 3D n'est pas activée"
fi
openGl=$( glxinfo | grep -i 'direct rendering' ) # variable recyclée plus tard
alert_3D=$(grep -i 'no' <<< $openGl )
[ "$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_graph_openGl(){
local iogl
for iogl in 'vendor' 'renderer' 'version' 'shading language version' 'extensions'; do
iogl="OpenGL $iogl"
[ "$1" == "dri" ] && openGl+=$(DRI_PRIME=1 glxinfo | grep "$iogl")$'\n'
[ "$1" == "opt" ] && openGl+=$(optirun glxinfo | grep "$iogl")$'\n' || \
openGl+=$(glxinfo | grep "$iogl")$'\n' # commande par défaut
done
}
fi_graph_openGl # openGl pour une carte ou gpu de base
if [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, essai optirun et prime
if [ $(f__cmd_exist optirun) ]; then
glx_dev_temp="$(optirun glxinfo | grep 'Device: ' | xargs)"
fi_graph_openGl "opt" # ajout à $openGl existant, à voir si infos sorties redondantes
else # DRI
glx_dev_temp="$(DRI_PRIME=1 glxinfo | grep 'Device: ' | xargs)"
fi_graph_openGl "dri" # ajout à $openGl existant, à voir si infos sorties redondantes
fi
[ "$glx_dev_temp" != "$glx_dev" ] && glx_dev+="\n $glx_dev_temp"
fi
openGl=${openGl/ string:/:} # suppression chaîne ' string'
openGl=${openGl::-1} # suppression dernier $'\n'
fi
# xrandr: résolutions & providers & preferred & current
# 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 )"
[ $(f__cmd_exist xrandr) ] && current="$( xrandr --verbose | grep -A2 '*current' )"
[ $(f__cmd_exist xrandr) ] && preferred="$( xrandr --verbose | grep -A2 '+preferred' )"
[ $(f__cmd_exist xrandr) ] && providers="$( xrandr --listproviders )" # DRI: ok, sort 2 fournisseurs
[ $(f__cmd_exist xrandr) ] && current_preferred="$( xrandr --verbose | grep -EA2 'current|preferred' )"
# modules
modules="$(lsmod | grep -Ei 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')"
# fonctions externes
[ "$fg_resolution" ] || figet_screen
}
###
[[ ! "$fg_gpu" =~ lspci ]] && text="## graphisme \n\n" || text="## graphisme (incomplet) \n\n"
# cartes graphiques
[[ ! "$fg_gpu" =~ lspci ]] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n" || text+="* $fg_gpu \n\n"
text="## graphisme \n\n"
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n"
# nb écran & résolution(s) active(s)
text+="nombre d'écrans: **$fg_nb_screen** \n"
text+="résolution: **$fg_resolution** \n\n"
[ "$(f__wcv "-wv" "$fg_resolution" "pixels")" -gt 1 ] && pluriel="s" || unset pluriel
text+="résolution"$pluriel" active"$pluriel": **$fg_resolution** \n\n"
# lspci -nnv
f_display "cards" "cmd" "$cmd"
[ "$alert_hybrid" ] && text+="$alert_hybrid \n\n"
f_dspl_alert "alert_hybrid" "alert"
# openGl
[ "$glx_dev" ] && f_display "glx_dev" "sans"
[ "$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'"
[ "$preferred" ] && f_display "preferred" "cmd" "xrandr --verbose | grep -A2 '+preferred'"
[ "$providers" ] && f_display "providers" "cmd" "xrandr --listproviders"
f_display "glx_dev" "var" "" "devices OpenGl"
f_dspl_alert "alert_3D" "info"
f_display "openGl" "cmd" "glxinfo" "OpenGl"
# liste providers, preferred & current
f_display "current_preferred" "cmd" "xrandr --verbose | grep -EA2 'current|*preferred'" \
"résolution courante et préférée"
f_display "providers" "cmd" "xrandr --listproviders"
# résolutions possibles, pas d'affichage si mode (ssh) ou xrandr pas accessible
if [ "$resolutions" ]; then
f_display "resolutions" "cmd" "xrandr --query | grep -A11 'Screen [0-9]'" \
f_display "resolutions" "cmd" "xrandr --query | grep -A11 'Screen [0-9]'" \
"10 premières résolutions possibles"
fi
# modules vidéo
text+="### modules video \n\n"
if [ "$modules" ]; then
@ -1004,7 +1027,7 @@ fi_hw(){ # 03/11/2017
unset text
}
fi_journal(){ # 09/11/2017
fi_journal(){ # 10/11/2017
local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_size file
local jctl_persist alert_jctl_persist text nb_lignes=25
[ "$(f__cmd_exist journalctl)" ] || fi_dmesg # pas systemd, appel dmesg
@ -1050,7 +1073,7 @@ fi_journal(){ # 09/11/2017
###
# kernel
text="## journalctl kernel (emergency, alert, erreur, warning ou critique) \n\n"
f_dspl_alert "alert_jctl_persist"
f_dspl_alert "alert_jctl_persist" "info"
text+="* $jctl_boot \n\n"
f_display "jctl_alert_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 1" \
"kernel emergency 0 & alerte 1, $nb_lignes premières lignes"
@ -1077,14 +1100,14 @@ fi_journal(){ # 09/11/2017
unset text
}
fi_locale(){ # 30/10/2017
fi_locale(){ # 09/11/2017
local locale localectl timezone timedatectl
local xKeyboardMap keyboard alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
# locale
locale="$(f_dspl_grep "/etc/default/locale* /etc/locale.conf")"
locale="$(f_grep_file "/etc/default/locale* /etc/locale.conf")"
[ "$(f__cmd_exist localectl)" ] && localectl=$(localectl --no-pager status)
# timezone
timezone="$(f_dspl_grep "/etc/timezone*")"
timezone="$(f_grep_file "/etc/timezone*")"
if [ "$(f__cmd_exist timedatectl)" ]; then
timedatectl="$(timedatectl status --no-pager)"
grep -q 'RTC in local TZ: yes' <<< "$timedatectl" && alert_Rtc="Attention RTC in local TZ"
@ -1097,22 +1120,22 @@ activer le service: timedatectl set-ntp true
et/ou installer le démon Ntp: apt install ntp \n"
fi
# keyboard layout
keyboard="$(f_dspl_grep "/etc/default/keyboard*")"
keyboard="$(f_grep_file "/etc/default/keyboard*")"
[ "$(f__cmd_exist setxkbmap)" ] && xKeyboardMap="$(setxkbmap -query)"
###
text="## localisation \n\n"
# locale
[ "$locale" ] && f_display "locale" "cmd" "grep -Esv '#|^[[:space:]]*$' /etc/default/locale* /etc/locale.conf"
[ "$locale" ] && f_display "locale" "cmd" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
[ "$localectl" ] && f_display "localectl" "cmd" "localectl --no-pager status"
# timezone
[ "$timezone" ] && f_display "timezone" "cmd" "grep -EHsv '#|^[[:space:]]*$' /etc/timezone*"
[ "$timezone" ] || f_dspl_file_ko "/etc/timezone*"
[ "$timezone" ] && f_display "timezone" "cmd" "grep -EHsv '#|^$' /etc/timezone*"
[ "$timezone" ] || f_dspl_file_KO "/etc/timezone*"
[ "$timedatectl" ] && f_display "timedatectl" "cmd" "timedatectl status --no-pager"
[ "$alert_Rtc" ] && text+="$alert_Rtc_info \n"
[ "$alert_Ntp" ] && text+="$alert_Ntp_info \n"
# keyboard layout
[ "$keyboard" ] && f_display "keyboard" "cmd" "grep -EHv '#|^[[:space:]]*$' /etc/default/keyboard*"
[ "$keyboard" ] || f_dspl_file_ko "/etc/default/keyboard"
[ "$keyboard" ] && f_display "keyboard" "cmd" "grep -EHv '#|^$' /etc/default/keyboard*"
[ "$keyboard" ] || f_dspl_file_KO "/etc/default/keyboard"
[ "$xKeyboardMap" ] && f_display "xKeyboardMap" "cmd" "setxkbmap -query"
printf "$text\n" >> "$fileOutput"
unset text
@ -1168,19 +1191,19 @@ fi_mem(){ # 08/11/2017
unset text
}
fi_nm(){ # 29/10/2017
fi_nm(){ # 09/11/2017
[ "$(f__cmd_exist nmcli)" ] || return 0
local nm_etat nm_conf nm_wifis nm_connected text
nm_etat=$(grep -Esv '#|^[[:space:]]*$' /var/lib/NetworkManager/NetworkManager.state)
nm_conf=$(grep -Esv '#|^[[:space:]]*$' /etc/NetworkManager/NetworkManager.conf)
nm_etat=$(f_grep_file "/var/lib/NetworkManager/NetworkManager.state" "file")
nm_conf=$(f_grep_file "/etc/NetworkManager/NetworkManager.conf" "file")
nm_wifis=$(nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15)
nm_connected=$(LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | gawk '/yes[[:space:]]+\*/ {print $1}')
###
text="## NetworkManager \n\n"
[ "$nm_etat" ] && f_display "nm_etat" "cmd" "grep -Ev '#|^[[:space:]]*$' /var/lib/NetworkManager/NetworkManager.state"
[ "$nm_etat" ] || f_dspl_file_ko "/var/lib/NetworkManager/NetworkManager.state"
[ "$nm_conf" ] && f_display "nm_conf" "cmd" "grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/NetworkManager.conf"
[ "$nm_conf" ] || f_dspl_file_ko "/etc/NetworkManager/NetworkManager.conf"
[ "$nm_etat" ] && f_display "nm_etat" "cmd" "grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"
[ "$nm_etat" ] || f_dspl_file_KO "/var/lib/NetworkManager/NetworkManager.state"
[ "$nm_conf" ] && f_display "nm_conf" "cmd" "grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf"
[ "$nm_conf" ] || f_dspl_file_KO "/etc/NetworkManager/NetworkManager.conf"
if [ "$nm_wifis" ]; then
text+="## wifis à proximité \n\n"
f_display "nm_wifis" "cmd" "nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15"
@ -1189,7 +1212,7 @@ fi_nm(){ # 29/10/2017
unset text
}
fi_reseau(){ # 08/11/2017
fi_reseau(){ # 09/11/2017
local slots cards ip_a iwconfig interfaces route resolv canal_wifi ifx alert_wlx text pluriel
# cardsManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')"
# cardsManuel="$(lspci -nnv | grep -EiA 15 'network|ethernet')"
@ -1207,9 +1230,9 @@ fi_reseau(){ # 08/11/2017
ip_a="$(sed '/inet6.*/d' <<< $ip_a)" # filtre sur inet6)
route="$(ip route show)"
# interfaces & resolv
interfaces="$(f_dspl_grep "/etc/network/interfaces*")"
interfaces="$(f_grep_file "/etc/network/interfaces*")"
interfaces="$(sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )"
resolv="$(grep -Esv '#|^[[:space:]]*$' /etc/resolv.conf)"
resolv="$(f_grep_file "/etc/resolv.conf" file)"
# iwconfig
if [ $(f__cmd_exist iwconfig) ]; then #paquet wireless-tools requis
iwconfig="$(iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^[[:space:]]*$')"
@ -1251,10 +1274,10 @@ fi_reseau(){ # 08/11/2017
# ip a & route & interface & resolv
f_display "ip_a" "cmd" "ip address" "sans ipV6 et sans adresses MAC"
f_display "route" "cmd" "ip route show"
[ "$interfaces" ] && f_display "interfaces" "cmd" "grep -EHrsv '#|^[[:space:]]*$' /etc/network/interfaces*"
[ "$interfaces" ] || f_dspl_file_ko "/etc/network/interfaces*"
[ "$interfaces" ] && f_display "interfaces" "cmd" "grep -EHrsv '#|^$' /etc/network/interfaces*"
[ "$interfaces" ] || f_dspl_file_KO "/etc/network/interfaces*"
[ "$resolv" ] && f_display "resolv" "cmd" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés"
[ "$resolv" ] || f_dspl_file_ko "/etc/resolv.conf"
[ "$resolv" ] || f_dspl_file_KO "/etc/resolv.conf"
# iwconfig & iwlist
[ "$iwconfig" ] && f_display "iwconfig" "cmd" "iwconfig" "état carte wifi"
if [ "$canal_wifi" ]; then
@ -1306,13 +1329,13 @@ fi_serial(){ # 06/11/2017
unset text
}
fi_sources(){ #v2 07/11/2017
fi_sources(){ #v2 09/11/2017
[ "$(f__cmd_exist dpkg)" ] || return 0
local sources dateMaj nb_packages upgrade upgrade_qte remove remove_qte non_ii_qte text pluriel
local alert_httpredir alert_upgrade alert_full_upgrade alert_upgrade_titre
local alert_remove alert_remove_titre alert_non_ii alert_non_ii_titre
# sources & divers
sources=$(f_dspl_grep "/etc/apt/sources.list /etc/apt/sources.list.d/*.list" 8)
sources=$(f_grep_file "/etc/apt/sources.list /etc/apt/sources.list.d/*.list" 8)
dateMaj="$(date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z')" # /var/lib/dpkg/
nb_packages="$(dpkg -l | grep -c '^ii')"
if [ $(grep -c 'httpredir' <<< $sources) -ne 0 ]; then
@ -1378,7 +1401,7 @@ fi_sources(){ #v2 07/11/2017
fi
###
text="## gestion de paquets DPKG \n\n"
f_display "sources" "cmd" "grep -Ersv '^#|^[[:space:]]*$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"
f_display "sources" "cmd" "grep -Ersv '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"
text+="* nombre de paquets installés: **$nb_packages** \n"
text+="* dernière mise à jour apt: **$dateMaj** \n\n"
[ "$alert_httpredir" ] && f_display "alert_httpredir" "var" "httpredir obsolète"
@ -1390,12 +1413,12 @@ fi_sources(){ #v2 07/11/2017
unset text
}
fi_ssid(){ # 06/11/2017
fi_ssid(){ # 09/11/2017
[ "$(f__cmd_exist nmcli)" ] || f__error "NetworkManager requis"
local nm_ssid file="/tmp/$$-$RANDOM-fi_ssid" text
# nm_ssid="$(grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/system-connections/*)"
# nm_ssid="$(grep -Ev '#|^$' /etc/NetworkManager/system-connections/*)"
[ "$EUID" -eq 0 ] || echo
f__sudo "grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/system-connections/* > $file ; \
f__sudo "grep -Ev '^[[:blank:]]*#|^[[:blank:]]*$' /etc/NetworkManager/system-connections/* > $file ; \
chown $user_: $file"
if [ "$?" != "0" ]; then
f__info "\n la consultation des connections NetworkManager$RED a échoué$BLUE (droits root requis, échec authentification?)"
@ -1406,7 +1429,7 @@ fi_ssid(){ # 06/11/2017
###
f__info "la$RED clé du réseau wifi étant visible$STD, aucun rapport n'a été créé"
text="$BOLD configuration(s) ssid networkmanager \n\n"
text+="$GREEN""grep -Ehv '#|^[[:space:]]*$' /etc/NetworkManager/system-connections/*$STD \n\n"
text+="$GREEN""grep -Ehv '#|^$' /etc/NetworkManager/system-connections/*$STD \n\n"
text+="$nm_ssid \n\n"
echo -e "$text"
unset text
@ -1428,7 +1451,7 @@ fi_system_analyse(){ # 08/11/2017
unset text
}
fi_systeme(){ # 07/11/2017
fi_systeme(){ # 10/11/2017
local mbr uname bootImage initDaemon xorg shells lastboot uptime charge pluriel text
local alim_total alimentation
[ -d /sys/firmware/efi ] && mbr="EFI" || mbr="Legacy (mbr)"
@ -1440,7 +1463,7 @@ fi_systeme(){ # 07/11/2017
if [ -z "$xorg" ]; then
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && xorg="wayland" || xorg="indéterminé"
fi
shells="$(grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/shells | sed 's/\/bin\///' | tr '\n' ' ')"
shells="$(f_grep_file "/etc/shells" "file" | tr '\n' ' ')"
if [ $(grep -c 'AC' <<< $(ls /sys/class/power_supply/ 2>/dev/null)) -gt 0 ]; then
alim_total=$(grep -cs . <<< $(ls /sys/class/power_supply/AC*/online))
alimentation=$( gawk -v "alim_total=$alim_total" '
@ -1476,7 +1499,8 @@ fi_systeme(){ # 07/11/2017
text+="* CPU \n"
text+=" * **$(sed -n '1p' <<< $fg_cpu)** \n"
text+="* GPU \n"
[[ ! "$fg_gpu" =~ lspci ]] && text+="$(sed -E 's/(.*)/ * **\1**/' <<<$fg_gpu) \n" || text+=" * n/a \n"
[ "$fg_nb_gpu" -eq 0 ] && text+=" * **pas de carte graphique détectée** \n" # pas de gpu
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/ * **\1**/' <<<$fg_gpu) \n" || text+=" * n/a \n"
text+="* boot **$mbr** \n"
text+="* distribution **$fg_distrib** \n\n"
text+='``` \n'
@ -1487,7 +1511,8 @@ fi_systeme(){ # 07/11/2017
text+="démon d'initialisation: $initDaemon \n"
text+="serveur d'affichage: $xorg \n"
text+="nombre d'écrans: $fg_nb_screen \n"
text+="résolution: $fg_resolution \n"
[ "$(f__wcv "-wv" "$fg_resolution" "pixels")" -gt 1 ] && pluriel="s" || unset pluriel
text+="résolution"$pluriel": $fg_resolution \n"
text+="desktop (DE): $fg_de \n"
text+="window manager: $fg_wm \n"
text+="shell actif: $fg_shell \n"
@ -2026,15 +2051,25 @@ figet_dmi(){ #v2 06/11/2017
[ "$bios" ] && fg_dmi+=$(printf "%s : %s" "bios" "$bios")
}
# assigne $fg_gpu (liste des gpu), $fg_nb_gpu peut retourner -1 si détection impossible (lspci -mm en erreur?)
figet_gpu(){ #v2 31/10/2017
fg_gpu="lspci -mm non disponible" fg_nb_gpu=-1
local lspci="$(lspci -mm)"
[ "$?" -gt 0 ] && return 1
# 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)"
# assigne $fg_gpu (liste des gpu), $fg_nb_gpu
# requis: f__wcv
figet_gpu(){ #v3 10/11/2017
local lspci field1
lspci="$(lspci -mm 2>/dev/null)"
if [ "$?" -eq 0 ]; then
# 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)"
else # lspci -mm en erreur, utilisation lspci (dans les requis)
read field1 lspci <<< $(IFS=':' lspci | grep -E 'Display |3D |VGA ') # lspci==VGA compatible controller: Intel Corporation System ...
fg_gpu=${lspci/*:/} # lspci==Intel Corporation System Controller ...
fg_gpu=${fg_gpu/ Corporation} # suppression ' Corporation'
fg_gpu=${fg_gpu/Advanced Micro Devices, Inc. } # suppression 'Advanced Micro Devices, Inc. '
fg_gpu=${fg_gpu/ / } # remplacement espace double par simple
fg_gpu=${fg_gpu## } # suppression du plus nombre d'espaces au début
fg_gpu=${fg_gpu%% } # suppression du plus nombre d'espaces à la fin
fi
fg_nb_gpu=$(f__wcv -l "$fg_gpu")
}
@ -2101,7 +2136,7 @@ figet_hw(){ #v2 31/10/2017
}
# assigne $fg_ip, $fg_ip_tp, $fg_gws, $fg_gws_tp, $fg_ifn_prior, $fg_ifn, $fg_mac, fg_mac_tp
figet_ip(){ # 31/10/2017
figet_ip(){ # 09/11/2017
local ifn
[ "$(f__cmd_exist ip)" ] || return 1
fg_ip="$(sed '/[[:digit:]]:[[:blank:]]lo.*inet/d; /inet6.*scope/d' <<< $(ip -o a) | gawk '{print " ",$4,"(",$2,")"}')"
@ -2114,8 +2149,8 @@ figet_ip(){ # 31/10/2017
[ "$ifn" != "lo" ] && fg_ifn+=" $ifn"$'\n'
[ "$ifn" != "lo" ] && fg_mac+=" $ifn: $(< /sys/class/net/$ifn/address)"$'\n'
done
fg_ifn="$(sed '/^[[:space:]]*$/d' <<< $fg_ifn)" # suppression lignes vides
fg_mac="$(sed '/^[[:space:]]*$/d' <<< $fg_mac)" # suppression lignes vides
fg_ifn="$(sed '/^[[:blank:]]*$/d' <<< $fg_ifn)" # suppression lignes vides
fg_mac="$(sed '/^[[:blank:]]*$/d' <<< $fg_mac)" # suppression lignes vides
fg_mac_tp="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $fg_mac)"
[ "$fg_ifn" ] && fg_ifn=${fg_ifn::-1} # suppression dernier $'\n'
[ "$fg_mac" ] && fg_mac=${fg_mac::-1} # suppression dernier $'\n'
@ -2448,8 +2483,13 @@ figet_wm(){ # thanks neofetch, assigne $fg_wm # 30/10/2017
}
# aiguillage export paste
fipaste(){
f__requis "curl" # requis pour paste
fipaste(){ # 10/11/2017
f__requis "curl"
if [ "$?" -gt 0 ]; then
f__info "une fois Curl installé, inutile de relancer la détection" \
"$GREEN ./getInfo -p" "pour exporter le rapport existant"
return 1
fi
fipaste_curl_pastery "$fileOutput" "$pasteDuration" "$optDebug"
# à tester fipaste_curl_markdownshare "$fileOutput"
}
@ -2547,7 +2587,7 @@ fscript_get_version(){ # 06/11/2017
}
# installation du script dans le système
fscript_install(){ # 06/11/2017
fscript_install(){ # 10/11/2017
if grep -q 'bin' <<< "$(dirname $0)" ; then
f__info "$RED""l'installation dans le système doit se faire depuis un script local $GREEN(./$script -i )"
return 1
@ -2558,7 +2598,7 @@ fscript_install(){ # 06/11/2017
return $?
fi
[ "$(type -t fscript_install_special)" ] && fscript_install_special # test, si fonction spécifique, appel
f__requis "wget anacron cron"
f__requis "wget anacron cron" || exit 1
# install /opt
mkdir -p /opt/bin/
cp -d "$(basename $0)" "$fileInstall"
@ -2746,7 +2786,7 @@ f__affichage
prg_alert_init
# requis pour fonctionnement programme
f__requis "gawk wget ip>iproute2 lspci>pciutils wc>coreutils"
f__requis "gawk wget ip>iproute2 lspci>pciutils wc>coreutils" || exit 1
options=$@
# traitement option paramètres
@ -2793,7 +2833,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_disk
fi_graph
exit ;; # test
-c* | all )
[ "$j" == "-c" ] && exec $0 "menu"

View File

@ -1,7 +1,17 @@
# changelog getInfo
* f__wcv, f_display_grep, f__wget_test, fscript_get_version, fscript_update
* f__wcv, f_display_grep, f_dspl_md, f__wget_test, fscript_get_version, fscript_update
* ! f__requis, fscript_install, f__scandir
## 2.29.0 10/11/2017
* nouveau: figet_gpu v3, retourne infos et nb de gpu quelques soit options lspci
* révision: alerte curl manquant moins déroutant pour nouvel utilisateur
* révision: alertes/infos
* révision: f_disk
* révision: f_graph, glxinfo durci pour configs multi-cartes
* révision: f_grep_file
* fix: extraction shell
## 2.28.0 09/11/2017