From e1c508ed67c89dae27f885fac1c18a0aea0bc83c Mon Sep 17 00:00:00 2001 From: kyodev Date: Mon, 20 Nov 2017 15:27:48 +0100 Subject: [PATCH] getInfo 2.41.0 --- scripts/getInfo | 580 +++++++++++++++++++---------------- scripts/getInfo_changelog.md | 6 + 2 files changed, 315 insertions(+), 271 deletions(-) diff --git a/scripts/getInfo b/scripts/getInfo index 02e01c7..847fcc4 100755 --- a/scripts/getInfo +++ b/scripts/getInfo @@ -1,7 +1,7 @@ #!/bin/bash -version=2.40.2 -date="19/11/2017" +version=2.41.0 +date="20/11/2017" projet="simpledeb" contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/" script="getInfo" @@ -44,18 +44,6 @@ f__architecture(){ # 08/2017 spécifique esac } - # $1=commande à tester, return localisation cmd si existe, return 1 si absent avec aucun message (à là debian) - # pour un test concis genre [ "$(f__cmd_exist $cmd)" ] && echo "$cmd existe" - # utilisation `type -p` pour le test, pour une bonne portabilité -f__cmd_exist(){ # 11/11/2017 -# command -v - if type -p "$1" &>/dev/null ; then - echo $(type -p $1) - else - return 1 - fi -} - f__color(){ # 08/10/2017 YELLOW=$(tput setaf 3) # question GREEN=$(tput setaf 2) # ok @@ -134,20 +122,20 @@ f__log(){ # 27/10/2017 # 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(){ # 10/11/2017 +f__requis(){ # 20/11/2017 local dependsMissing packagesMissing command package ireq compteur pluriel unset debOnlyPackages debOnlyPresents for ireq in $1; do command="$(cut -d '>' -f 1 <<< $ireq)" package="$(cut -d '>' -f 2 <<< $ireq)" if [ "$2" == "debOnly" ]; then - if [ "$(f__cmd_exist dpkg)" ]; then # package only et debian + if [ $( f__which dpkg ) ]; then # package only et debian LC_ALL=C dpkg --get-selections | grep -qE "^$package[[:space:]]+install" \ && debOnlyPresents+="$package " || debOnlyPackages+="$package " else f__error "dpkg n'est pas disponible sur ce système" fi - elif [ -z "$(f__cmd_exist $command)" ]; then + elif [ -z $( f__which $command ) ]; then dependsMissing+="$command " packagesMissing+="$package " fi @@ -205,9 +193,9 @@ f__sudo(){ # 22/10/2017 local nb=2 sudo isudo # sudo --shell bash équivalent su ? if sudo -v &>/dev/null && [ $EUID -ne 0 ] ; then - sudo="sudo su --shell $(f__cmd_exist bash) --preserve-environment -c " + sudo="sudo su --shell $(f__which bash) --preserve-environment -c " else - sudo="su --shell $(f__cmd_exist bash) --preserve-environment -c " + sudo="su --shell $(f__which bash) --preserve-environment -c " fi [ "$2" ] && nb="$2" for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do @@ -318,40 +306,52 @@ f__wget_test(){ # 06/11/2017 exit 0 } - # $1 variable à afficher, $2=var|cmd|sans[:text] (type titre) [$3 titre] [$4 commentaire en () si cmd] - # $2 cmd->`titre`, var->**titre**, sans: pas de titre - # "variable" "var" "" "comment" -> pas de titre mais commentaire encadré + # $1=commande à tester, return localisation cmd si existe, return 1 si absent avec aucun message (à là debian) + # pour un test concis genre [ "$(f__which $cmd)" ] && echo "$cmd existe" + # utilisation `type -p` pour le test, pour une bonne portabilité +f__which(){ # 11/11/2017 +# command -v + if type -p "$1" &>/dev/null ; then + echo $(type -p $1) + else + return 1 + fi +} + + # $1 variable à afficher, $2 type de titre var|cmd|sans|+:text|+:vide [$3 titre] [$4 commentaire] + # $2: cmd->`titre`, var->**titre**, sans: pas de titre # :text ajouté, affiche le text en liste (avec puce) - # :vide bypass test contenu $1, affiche vide si besoin (en liste) + # :vide bypass le test de contenu $1, affiche 'vide', si besoin, en liste + # "variable" "sans" "" "comment" -> pas de titre mais commentaire encadré # passage en paramètre variable et pas $variable - # un test si variable $1 est vide est fait - # un test si variable $1 contient 'nofile', non trouvé par f_grep_file - # f_display "variable" "type" "titrage" "titrage_commentaire" -f_display(){ # 17/11/2017 + # un test si variable $1 est vide est fait sauf ':vide' + # un test si variable $1 contient 'nofile' (non trouvé par f_grep_file) + # f_display "variable" "type" "titre" "commentaire" +f_display(){ # 20/11/2017 [[ "${!1}" || "$2" =~ :vide ]] || return 0 # test si contenu dans $1 local display="" toDisplay="${!1}" - [ "$toDisplay" ] || toDisplay="vide" # flush, avant fonction, de $text parent - [ "$text" ] && echo -en "$text" >> "$fileOutput" + [ "$text" ] && echo -en "$text\n" >> "$fileOutput" unset text - # coeur fonction -#toDisplay=${toDisplay//\\/\\\\} + # traitement ligne de titre + [ "$toDisplay" ] || toDisplay="vide" # cas si :vide [[ "$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 cmd, titre entre backtick - [ "$4" ] && display+="$spc5( $4 )" # +$4 en gras avec 5 espaces insécables avant - [ "$2" == "sans" ] || display+=" \n" - if [ "$toDisplay" == "nofile" ]; then + [ "$4" ] && display+="$spc5( $4 )" # +$4 en gras avec 5 espaces insécables avant +# [ "$2" == "sans" ] || display+=" \n" + display+=" \n" + # traitement contenu + if [ "$toDisplay" == "nofile" ]; then # renvoyé par f_grep display+="\n* fichier $1 non trouvé \n" elif [[ "$2" =~ :text || "$toDisplay" == "vide" ]]; then - display+='\n' - display+="* $toDisplay \n\n" + display+="\n* $toDisplay \n" else display+='``` \n' display+="$toDisplay \n" - display+='``` \n\n' + display+='``` \n' fi - echo -en "$display" >> "$fileOutput" # flush fonction + echo -en "$display\n" >> "$fileOutput" # flush fonction } # $1 variable à afficher en alerte/info, [$2 alert|info] type de message, alert par défaut @@ -361,15 +361,15 @@ f_dspl_alert(){ # 19/11/2017 [ "${!1}" ] || return 0 # test si contenu dans $1 local display type # flush, avant fonction, de $text parent - [ "$text" ] && echo -en "$text" >> "$fileOutput" + [ "$text" ] && echo -en "$text\n" >> "$fileOutput" unset text # coeur fonction [[ "$2" =~ info ]] && type="info" [[ "$2" =~ alert ]] && type="alert" [ "$2" ] || type="alert" # alert par défaut - [ "$type" == "alert" ] && display="> ↯ ${!1} \n\n\n" - [ "$type" == "info" ] && display=" ☛ ${!1} \n\n\n" - echo -en "$display" >> "$fileOutput" # flush fonction + [ "$type" == "alert" ] && display="> ↯ ${!1} \n\n" + [ "$type" == "info" ] && display=" ☛ ${!1} \n\n" + echo -en "$display\n" >> "$fileOutput" # flush fonction } # conversion markdown pour affichage en console, $1 file à parser @@ -519,7 +519,7 @@ fi_batt(){ # 10/11/2017 [ "$fg_nb_batt" -gt 1 ] && pluriel="s" || unset pluriel text="## batterie"$pluriel" \n\n" f_display "fg_batt" "sans" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -541,7 +541,7 @@ fi_cpu(){ # 19/11/2017 f_display "fg_uarch" "var" "µarchitecture processeur" f_display "cpu_flags" "var" "$qte_flags flags cpu" # flags cpu bruts f_display "text_flags" "sans" # flags cpu texte - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -805,14 +805,14 @@ SMCA ⟷ Scalable MCA " } -fi_disk(){ # 18/11/2017 +fi_disk(){ # 20/11/2017 local dd_temp="" 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 + if [ $( f__which hddtemp ) ]; then for idisk in $fg_disk_fixe; do [ -r "/dev/$idisk" ] || continue - temp=$(($( LC_ALL=C hddtemp -n /dev/$idisk 2>/dev/null))) + temp=$(( $( LC_ALL=C hddtemp -n /dev/$idisk 2>/dev/null ) )) if [ "$temp" -ge 50 ]; then alert_dd_temp+="$idisk: température > 50°C "$'\n' fi @@ -896,7 +896,7 @@ fi_disk(){ # 18/11/2017 "resume" f_dspl_alert "alert_file_resume" "info" f_dspl_alert "alert_uuidResume" "alert" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -937,55 +937,54 @@ fi_dmesg(){ # 10/11/2017 f_display "dmesg_err" "cmd" "dmesg -l err" "erreur, $nb_lignes premières lignes" f_display "dmesg_warn" "cmd" "dmesg -l warn" "warning, $nb_lignes premières lignes" text+="**les $nb_lignes premières lignes commencent à la date la plus ancienne encore dans les logs kernel** \n\n" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_efi(){ # 19/11/2017 +fi_efi(){ # 20/11/2017 local efiboot text - [ "$(f__cmd_exist "efibootmgr" )" ] || return 0 + [ $( f__which efibootmgr ) ] || return 0 efiboot=$( gawk ' /^Boot0/ { gsub(/\\/,"\\\\",$3); printf "%s %s: \n %s \n", $1, $2, $3 }; ! /^Boot0/ { print $0 } ' <<< $( efibootmgr -v 2>/dev/null ) ) ### - text="## EI boot manager \n\n" + text="## EFI boot manager \n\n" f_display "efiboot" "cmd" "efibootmgr -v" "config EFI boot" echo -en "$text\n" >> "$fileOutput" unset text } -fi_graph(){ # 19/11/2017 - local slots ig cmd cards stock_glxinfo glx_dev glx_dev_temp openGl providers resolutions - local pluriel modules text +fi_graph(){ # 20/11/2017 + local slots cards cmd_cards ig + local stck_glxinfo stck_glxinfoOpt stck_glxinfoDri glx_dvc cmd_glx_dvc glx_dvc_temp openGl cmd_openGl + local providers resolutions pluriel modules cmt_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 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 + cmd_cards="lspci -nnv | grep -iEA11 'vga|display|3d'" # commande par défaut if ! lspci -nnv &>/dev/null ; then # commande/option indisponible cards="lspci -nnv non disponible"$'\n' - elif [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, essai optirun et prime - if [ $(f__cmd_exist optirun) ]; then + elif [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, essai optirun ou prime + if [ $( f__which optirun ) ]; then for ig in $slots; do - cards+="$(optirun lspci -nnv -s $ig)"$'\n' + cards+=$( optirun lspci -nnv -s $ig )$'\n' done - cmd="optirun lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport - else # DRI + cmd_cards="optirun $cmd_cards" + else # DRI for ig in $slots; do - cards+="$(DRI_PRIME=1 lspci -nnv -s $ig)"$'\n' + cards+=$( DRI_PRIME=1 lspci -nnv -s $ig )$'\n' done - cmd="DRI_PRIME=1 lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport + cmd_cards="DRI_PRIME=1 cmd_cards" fi - else # une seule carte, ras - for ig in $slots; do - cards+="$(lspci -nnv -s $ig)"$'\n' - done + else + cards+=$( lspci -nnv -s $slots )$'\n' # une seule carte fi cards=${cards::-1} # suppression dernier $'\n' if grep -iq 'Unknown header type 7f' <<< "$cards" ; then @@ -993,63 +992,87 @@ fi_graph(){ # 19/11/2017 alert_hybrid+="Voir DRI_PRIME, vga-switcheroo, Bumbledee...?" fi # openGl / glxinfo - if [ $( f__cmd_exist glxinfo ) ]; then - stock_glxinfo=$( glxinfo ) + if [ $( f__which glxinfo ) ]; then + stck_glxinfo=$( glxinfo ) # test 3D actif - glx_dev=$( grep -i 'direct rendering:' <<< "$stock_glxinfo" )$'\n' - if grep -iq 'direct rendering: No' <<< "$stock_glxinfo" ; then + if grep -iq 'direct rendering: No' <<< "$stck_glxinfo" ; then alert_3D="l'accélération 3D n'est pas active" fi # devices - glx_dev+=$( grep 'Device: ' <<< "$stock_glxinfo" | xargs ) - # openGL - fi_graph_openGl(){ # $1="|opt|dri", assigne $openGl pour un ou plusieurs gpu (dri & optirun) - local iogl - [[ "$1" == "dri" || "$1" == "opt" ]] && openGl+="◽" - 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+=$( grep "$iogl" <<< "$stock_glxinfo" )$'\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 + glx_dvc=$( grep -i 'direct rendering:' <<< "$stck_glxinfo" )$'\n' + glx_dvc+=$( grep 'Device: ' <<< "$stck_glxinfo" ) + cmd_glx_dvc="glxinfo | grep -E 'rendering|Device: '" + if [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, optirun et prime + if [ $( f__which optirun ) ]; then + stck_glxinfoOpt=$( optirun glxinfo ) + glx_dvc_temp=$( grep 'Device: ' <<< $stck_glxinfoOpt ) + cmd_glx_dvc="optirun $cmd_glx_dvc" + else + stck_glxinfoDri=$( DRI_PRIME=1 glxinfo ) + glx_dvc_temp=$( grep 'Device: ' <<< $stck_glxinfoDri ) + cmd_glx_dvc="DRI_PRIME=1 $cmd_glx_dvc" fi - [ "$glx_dev_temp" != "$glx_dev" ] && glx_dev+="\n$glx_dev_temp" # ajout si diff, pas suffisant avec optirun? + [ "$glx_dvc_temp" != "$glx_dvc" ] && glx_dvc+="\n$glx_dvc_temp" # ajout si diff + fi + # $1="[opt|dri]", assigne $openGl pour un ou plusieurs gpu (dri & optirun) & $cmd_openGl + fi_graph_openGl(){ + local iogl dri_glxinfo="" + [[ "$1" == "opt" ]] && openGl+="---- \n" + for iogl in 'vendor' 'renderer' 'version' 'shading language' 'extensions'; do + [ "$iogl" == 'shading language' ] || iogl="OpenGL $iogl" + if [ "$1" == "dri" ]; then + dri_glxinfo+=$( grep "$iogl" <<< $stck_glxinfoDri )$'\n' + elif [ "$1" == "opt" ]; then + openGl+=$( grep "$iogl" <<< $stck_glxinfoOpt )$'\n' + else + openGl+=$( grep "$iogl" <<< "$stck_glxinfo" )$'\n' + fi + done + if [ "$1" == "dri" ]; then + dri_glxinfo=${dri_glxinfo::-1} + [ $( f__which uniq ) ] && openGl=$(uniq <<< $dri_glxinfo) || openGl="$dri_glxinfo" + fi + openGl=${openGl::-1} + } + # openGL + fi_graph_openGl # openGl pour une carte ou gpu de base + if [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, optirun et prime + if [ $( f__which optirun ) ]; then + fi_graph_openGl "opt" # ajout à $openGl existant, pas de redondance + cmd_openGl="optirun glxinfo" + else # DRI + fi_graph_openGl "dri" # redondance + cmd_openGl="DRI_PRIME=1 glxinfo" + fi + else + cmd_openGl="glxinfo | grep -E 'OpenGL vendor|OpenGL renderer|OpenGL version|shading language|OpenGL extensions'" fi openGl=${openGl// string:/:} # suppression chaîne ' string' - openGl=${openGl::-1} # suppression dernier $'\n' openGl=${openGl% } # suppression espace final éventuel fi # 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 )" # DRI: ok, sort 2 fournisseurs - [ $(f__cmd_exist xrandr) ] && current_preferred="$( xrandr --verbose | grep -EA2 'current|preferred' )" + [ $( f__which xrandr ) ] && resolutions="$( xrandr --query | grep -A11 'Screen [0-9]' )" + [ $( f__which xrandr ) ] && providers="$( xrandr --listproviders )" # DRI: ok, sort 2 fournisseurs + [ $( f__which xrandr ) ] && current_preferred="$( xrandr --verbose | grep -EA2 'current|preferred' )" # modules modules="$(lsmod | grep -Ei 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')" + cmt_modules="modules recherchés: amdgpu, ati, i915, nouveau, nvidia, radeon, video, gma" # fonctions externes [ "$fg_resolution" ] || figet_screen ### text="## graphisme \n\n" - [ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n" + [ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n" # mise en puces + quote # nb écran & résolution(s) active(s) text+="nombre d'écrans: **$fg_nb_screen** \n" - [ "$(f__wcv "-wv" "$fg_resolution" "pixels")" -gt 1 ] && pluriel="s" || unset pluriel + [ $( 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" + f_display "cards" "cmd" "$cmd_cards" f_dspl_alert "alert_hybrid" "alert" # openGl - f_display "glx_dev" "cmd" "glxinfo" "devices OpenGl" + f_display "glx_dvc" "cmd" "$cmd_glx_dvc" "devices OpenGl" f_dspl_alert "alert_3D" "info" - f_display "openGl" "cmd" "glxinfo" "OpenGl" + f_display "openGl" "cmd" "$cmd_openGl" "OpenGl" # liste providers, preferred & current f_display "current_preferred" "cmd" "xrandr --verbose | grep -EA2 'current|*preferred'" \ "résolution courante et préférée" @@ -1058,14 +1081,13 @@ fi_graph(){ # 19/11/2017 f_display "resolutions" "cmd" "xrandr --query | grep -A11 'Screen [0-9]'" \ "10 premières résolutions possibles" # modules vidéo - text+="### modules video \n\n" if [ "$modules" ]; then - f_display "modules" "var" "modules recherchés: amdgpu, ati, i915, nouveau, nvidia, radeon, video, gma" + f_display "modules" "var" "modules vidéo" "$cmt_modules" else - text+="Modules non reconnus. Il serait bien de communiquer le retour de \`lsmod\` pour mettre " - text+="à jour le script. Merci de contacter $projet: \n$contact " + text+="Modules non reconnus. Il serait bien de communiquer le retour de \`lsmod\` \n" + text+="merci de contacter $projet: \n$contact " fi - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -1075,15 +1097,15 @@ fi_hw(){ # 10/11/2017 text="## hardware monitor ACPI \n\n" f_display "fg_hw" "sans" [ "$fg_hw" ] || text+="* **pas d'informations détectées** \n\n" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_journal(){ # 18/11/2017 +fi_journal(){ # 20/11/2017 local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_last jctl_size file local text nb_lignes=25 local alert_jctl_persist alert_firmBug - [ "$(f__cmd_exist journalctl)" ] || fi_dmesg # pas systemd, appel dmesg + [ $( f__which journalctl ) ] || fi_dmesg # pas systemd, appel dmesg file="/tmp/$$-$RANDOM-journalctl" [ "$EUID" -eq 0 ] || echo f__sudo " LC_ALL=C journalctl --no-hostname --boot -1 &>$file-persistant ; \ @@ -1174,19 +1196,19 @@ fi_journal(){ # 18/11/2017 f_display "jctl_last" "cmd" "journalctl --no-pager --no-hostname --boot 0 -p 4 -n25" \ "toutes provenance, emergency-warning, $nb_lignes lignes les plus récentes" f_dspl_alert "alert_firmBug" "alert" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_locale(){ # 18/11/2017 +fi_locale(){ # 20/11/2017 local locale localectl timezone timedatectl xKeyboardMap keyboard text local alert_rtc alert_ntp # locale locale="$(f_grep_file "/etc/default/locale* /etc/locale.conf")" - [ "$(f__cmd_exist localectl)" ] && localectl=$(localectl --no-pager status) + [ $( f__which localectl ) ] && localectl=$(localectl --no-pager status) # timezone timezone="$(f_grep_file "/etc/timezone*")" - if [ "$(f__cmd_exist timedatectl)" ]; then + if [ $( f__which timedatectl ) ]; then timedatectl="$(timedatectl status --no-pager)" if grep -iq 'Network time on: no' <<< "$timedatectl"; then alert_ntp="Network time on: no \n" @@ -1204,7 +1226,7 @@ fi_locale(){ # 18/11/2017 fi # keyboard layout keyboard="$(f_grep_file "/etc/default/keyboard*")" - [ "$(f__cmd_exist setxkbmap)" ] && xKeyboardMap="$(setxkbmap -query)" + [ $( f__which setxkbmap ) ] && xKeyboardMap="$(setxkbmap -query)" ### text="## localisation \n\n" # locale @@ -1218,13 +1240,13 @@ fi_locale(){ # 18/11/2017 # keyboard layout f_display "keyboard" "cmd" "grep -EHv '#|^$' /etc/default/keyboard*" f_display "xKeyboardMap" "cmd" "setxkbmap -query" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_log_xorg(){ # 16/11/2017 +fi_log_xorg(){ # 20/11/2017 [ "$ENV_SSH" ] && return 0 - local logXorg xfile extract dateFile text nb_lignes=50 + local logXorg cmd_logXorg cmt_logXorg xfile extract dateFile text nb_lignes=50 # Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, # (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown (WW) warning, (EE) erreur for xfile in /var/log/Xorg.0.log /home/$user_/.local/share/xorg/Xorg.0.log ; do @@ -1245,21 +1267,20 @@ fi_log_xorg(){ # 16/11/2017 fi done logXorg="${logXorg::-2}" + cmd_logXorg="grep -Es '\(WW\)|\(EE\)|\(\?\?\)' /var/log/Xorg.?.log /home//.local/share/xorg/Xorg.?.log" + cmt_logXorg="Xorg.log" ### text="## journaux Xorg \n\n" - f_display "logXorg" "cmd" \ - "grep -Es '\(WW\)|\(EE\)|\(\?\?\)' /var/log/Xorg.?.log /home//.local/share/xorg/Xorg.?.log" \ - "Xorg.log" - text+="voir les options appliquées par défaut: \n" - text+="\`cat /var/log/Xorg.0.log | grep '(\*\*)'\`\n\n" - printf "$text\n" >> "$fileOutput" + f_display "logXorg" "cmd" "$cmd_logXorg" "$cmt_logXorg" + text+="voir les options appliquées par défaut: **cat /var/log/Xorg.0.log | grep '(\*\*)**'\n\n" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_mem(){ # 16/11/2017 +fi_mem(){ # 20/11/2017 local memoire swappiness text figet_mem "mem" #options possibles mem swap total notitle nocoltitle - memoire="$fg_mem \n\n" + memoire="$fg_mem \n" figet_mem "swap" "notitle" memoire+="$fg_mem" swappiness="$(cat /proc/sys/vm/swappiness 2>/dev/null)" @@ -1267,26 +1288,31 @@ fi_mem(){ # 16/11/2017 text="## mémoire \n\n" f_display "memoire" "cmd" "free -h" f_display "swappiness" "cmd" "cat /proc/sys/vm/swappiness" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_nm(){ # 13/11/2017 - [ "$(f__cmd_exist nmcli)" ] || return 0 - local nm_etat nm_conf nm_wifis nm_connected text +fi_nm(){ # 20/11/2017 + [ $( f__which nmcli ) ] || return 0 + local nm_etat cmd_nm_etat cmt_nm_etat nm_conf cmd_nm_conf cmt_nm_conf nm_wifis cmd_nm_wifis cmt_nm_wifis + local nm_connected text nm_etat=$( f_grep_file "/var/lib/NetworkManager/NetworkManager.state" "nofile" ) + cmd_nm_etat="grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state" + cmt_nm_etat="état de NetworkManager" nm_conf=$( f_grep_file "/etc/NetworkManager/NetworkManager.conf" "nofile" ) - nm_wifis=$( nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15 ) + cmd_nm_conf="grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf" + cmt_nm_conf="configuration de NetworkManager" + nm_wifis=$( LC_ALL=C nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15 ) + cmd_nm_wifis="nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list" + cmt_nm_wifis="wifis à proximité" + [ "$(f__wcv "-l" "$nm_wifis")" -eq 1 ] && unset nm_wifis nm_connected=$( LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | gawk '/yes[[:space:]]+\*/ {print $1}' ) ### text="## NetworkManager \n\n" - f_display "nm_etat" "cmd" "grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state" - f_display "nm_conf" "cmd" "grep -Ev '#|^$' /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" - fi - printf "$text\n" >> "$fileOutput" + f_display "nm_etat" "cmd" "$cmd_nm_etat" "$cmt_nm_etat" + f_display "nm_conf" "cmd" "$cmd_nm_conf" "$cmt_nm_conf" + f_display "nm_wifis" "cmd" "$cmd_nm_wifis" "$cmt_nm_wifis" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -1334,19 +1360,19 @@ fi_packagers(){ #v2 19/11/2017 fi } -fi_pkg_apt(){ #v3 19/11/2017 +fi_pkg_apt(){ #v3 20/11/2017 local dateMaj nb_packages ifile info_update text pluriel - local sources comment_sources cmd_sources apt_v apt_version - local apt_prefs comment_apt_prefs cmd_apt_prefs - local stock_upgd qte_upgradable - local upgrade comment_upgrade cmd_upgrade - local notUpgraded comment_notUpgraded cmd_notUpgraded - local toRemove qte_toRemove comment_toRemove cmd_toRemove - local autoclean qte_autoclean comment_autoclean cmd_autoclean size_clean size_cleanH - local clean qte_clean comment_clean cmd_clean size_clean - local non_ii qte_non_ii comment_non_ii cmd_non_ii etat ligne stock_etat - local deborphan qte_deborphan comment_deborphan cmd_deborphan - local holded qte_holded comment_holded cmd_holded + local sources cmt_sources cmd_sources + local apt_v apt_version apt_prefs cmt_apt_prefs cmd_apt_prefs + local stck_upgd qte_upgradable + local upgrade cmt_upgrade cmd_upgrade + local notUpgraded cmt_notUpgraded cmd_notUpgraded + local toRemove qte_toRemove cmt_toRemove cmd_toRemove + local autoclean qte_autoclean cmt_autoclean cmd_autoclean size_clean size_cleanH + local clean qte_clean cmt_clean cmd_clean size_clean + local non_ii qte_non_ii cmt_non_ii cmd_non_ii etat ligne stck_etat + local deborphan qte_deborphan cmt_deborphan cmd_deborphan + local holded qte_holded cmt_holded cmd_holded local alert_https alert_httpsPossible alert_non_list alert_httpredir alert_upgrade alert_full_upgrade local alert_remove alert_autoclean alert_clean alert_non_ii alert_deborphan # avertissement @@ -1360,7 +1386,7 @@ fi_pkg_apt(){ #v3 19/11/2017 dateMaj=$( date -r /var/cache/apt '+%d/%m/%Y %H:%M %z' 2>/dev/null) # /var/lib/dpkg/ nb_packages=$( dpkg -l | grep -c '^ii' ) sources=$( f_grep_file "/etc/apt/sources.list /etc/apt/sources.list.d/*.list" 8 ) - comment_sources="dépôts" + cmt_sources="dépôts" cmd_sources="grep -Ersv '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list" if [ $( ls -1 /etc/apt/sources.list.d/ | grep -cEv '\.list$' ) -gt 0 ]; then for ifile in $( ls /etc/apt/sources.list.d/* ); do @@ -1392,33 +1418,33 @@ fi_pkg_apt(){ #v3 19/11/2017 fi # apt prefs apt_prefs=$( f_grep_file "/etc/apt/preferences.d/*" ) - comment_apt_prefs="préférences apt" + cmt_apt_prefs="préférences apt" cmd_apt_prefs="grep -Erv '^#|^$' /etc/apt/preferences.d/" printf "◇" # extraction qte ugrade, full-upgrade - stock_upgd=$( LC_ALL=C apt-get upgrade --simulate ) + stck_upgd=$( LC_ALL=C apt-get upgrade --simulate ) # $1 upgraded, $6 to remove, $10 not upgraded # => qte_upgradable [0]=upgraded, [1]=notUpgraded - qte_upgradable=($( gawk '/ newly installed/{print $1" "$10}' <<< $stock_upgd )) # tableau + qte_upgradable=($( gawk '/ newly installed/{print $1" "$10}' <<< $stck_upgd )) # tableau { # upgrade [ "${qte_upgradable[0]}" -gt 1 ] && pluriel="s" || unset pluriel - comment_upgrade="${qte_upgradable[0]} paquet"$pluriel" à mettre à jour" - [ "${qte_upgradable[0]}" -eq 0 ] && comment_upgrade=${comment_upgrade/0 /aucun } + cmt_upgrade="${qte_upgradable[0]} paquet"$pluriel" à mettre à jour" + [ "${qte_upgradable[0]}" -eq 0 ] && cmt_upgrade=${cmt_upgrade/0 /aucun } cmd_upgrade="apt list --upgradable" if [ "${qte_upgradable[0]}" -gt 0 ]; then - upgrade=$( grep '^Inst' <<< "$stock_upgd" | sort | gawk '{ + upgrade=$( grep '^Inst' <<< "$stck_upgd" | sort | gawk '{ sub(/\(/,"",$4); sub(/\/.*/,"",$5); sub(/\[/,"",$3); sub(/\]/,"",$3); printf "%-25s source: %-25s %-20s ⇉ %-20s\n",$2,$5,$3,$4 }') alert_upgrade="ces paquets peuvent être mis à jour avec: **apt upgrade**" fi # full-upgrade if [ "${qte_upgradable[1]}" -gt 0 ]; then - notUpgraded=${stock_upgd%The following packages will be upgraded*} # suppression fin + notUpgraded=${stck_upgd%The following packages will be upgraded*} # suppression fin notUpgraded=${notUpgraded#*The following packages have been kept back:} # suppression début notUpgraded=$( sed '/newly/d' <<< "$notUpgraded" | sort | tr '\n' ' ' ) notUpgraded=${notUpgraded// / } # suppression espace double [ "${qte_upgradable[1]}" -gt 1 ] && pluriel="s" || unset pluriel - comment_notUpgraded="${qte_upgradable[1]} paquet"$pluriel" nécessitant une mise à jour profonde)" + cmt_notUpgraded="${qte_upgradable[1]} paquet"$pluriel" nécessitant une mise à jour profonde)" cmd_notUpgraded="" alert_full_upgrade="ces paquets peuvent être mis à jour avec avec: **apt full-upgrade**" fi @@ -1429,8 +1455,8 @@ fi_pkg_apt(){ #v3 19/11/2017 qte_toRemove=$( gawk '/ newly installed/{printf $6}' <<< $toRemove ) toRemove=$( sed '/newly/d' <<< "$toRemove" ) # suppression ligne état [ "$qte_toRemove" -gt 1 ] && pluriel="s" || unset pluriel - comment_toRemove="$qte_toRemove paquet"$pluriel" inutile"$pluriel - [ "$qte_toRemove" -eq 0 ] && comment_toRemove=${comment_toRemove/0 /aucun } + cmt_toRemove="$qte_toRemove paquet"$pluriel" inutile"$pluriel + [ "$qte_toRemove" -eq 0 ] && cmt_toRemove=${cmt_toRemove/0 /aucun } cmd_toRemove="apt autoremove --simulate" if [ "$qte_toRemove" -gt 0 ]; then toRemove=$( sed -E '/^Remv/!d; s/\[.*\]//g; s/Remv //' <<< $toRemove | tr '\n' ' ' ) @@ -1440,13 +1466,13 @@ fi_pkg_apt(){ #v3 19/11/2017 alert_remove+="au besoin, les marquer comme installées manuellement avec apt-mark manual \n" alert_remove+="ou les installer manuellement avec apt install " fi - # autoclean + # autoclean printf "◇" autoclean=$( grep '^Del' <<< $( LC_ALL=C apt-get autoclean --simulate 2>/dev/null ) ) qte_autoclean=$( f__wcv -l "$autoclean" ) [ "$qte_autoclean" -gt 1 ] && pluriel="s" || unset pluriel - comment_autoclean="$qte_autoclean archive"$pluriel" périmée"$pluriel - [ "$qte_autoclean" -eq 0 ] && comment_autoclean=${comment_autoclean/0 /aucune } + cmt_autoclean="$qte_autoclean archive"$pluriel" périmée"$pluriel + [ "$qte_autoclean" -eq 0 ] && cmt_autoclean=${cmt_autoclean/0 /aucune } cmd_autoclean="apt autoclean --simulate" if [ "$qte_autoclean" -gt 0 ]; then autoclean=$( gawk '{print $2}' <<< $autoclean | sort | tr '\n' ' ' ) @@ -1461,7 +1487,7 @@ fi_pkg_apt(){ #v3 19/11/2017 size_cleanH=${size_cleanH%[[:blank:]]total} qte_clean=$( f__wcv -l "$( ls -1 /var/cache/apt/archives/ )") [ "$qte_clean" -gt 1 ] && pluriel="s" || unset pluriel - comment_clean="taille du cache des paquets" + cmt_clean="taille du cache des paquets" cmd_clean="du -chS /var/cache/apt/archives/" if [ "$size_clean" -gt 200 ]; then # alerte si > à 100 ko (cache pas vide) alert_clean="$qte_clean archive"$pluriel" dans le cache de téléchargement des paquets \n" @@ -1474,17 +1500,17 @@ fi_pkg_apt(){ #v3 19/11/2017 printf "%-3s %-20s %-12s",$1,$2,$3; $1=$2=$3=$4=""; printf "%s \n",$0}' ) qte_non_ii=$( f__wcv -l "$non_ii" ) [ "$qte_non_ii" -gt 1 ] && pluriel="s" || unset pluriel - comment_non_ii="$qte_non_ii paquet"$pluriel" dans un état non standard (^ii)" - [ "$qte_non_ii" -eq 0 ] && comment_non_ii=${comment_non_ii/0 /aucun } + cmt_non_ii="$qte_non_ii paquet"$pluriel" dans un état non standard (^ii)" + [ "$qte_non_ii" -eq 0 ] && cmt_non_ii=${cmt_non_ii/0 /aucun } cmd_non_ii="dpkg -l | grep -v '^ii'" # dpkg -l | gawk '! /^ii/ {print $0}' if [ "$qte_non_ii" -gt 0 ]; then # extraction différents états constatés while read etat ligne ; do - stock_etat+="$etat"$'\n' + stck_etat+="$etat"$'\n' done <<< "$non_ii" - stock_etat=$( sort -u <<< "$stock_etat" ) # tri et dédoublonnage + stck_etat=$( sort -u <<< "$stck_etat" ) # tri et dédoublonnage non_ii+="\n\n ‣ État souhaité / État du paquet / Drapeaux d'erreur\n" - for ligne in $stock_etat; do + for ligne in $stck_etat; do [[ ${ligne,,} =~ ^h ]] && non_ii+=" h: hold (à garder) " [[ ${ligne,,} =~ ^i ]] && non_ii+=" i: install (à installer) " [[ ${ligne,,} =~ ^p ]] && non_ii+=" p: purge (à purger) " @@ -1502,20 +1528,20 @@ fi_pkg_apt(){ #v3 19/11/2017 non_ii+=$'\n' done non_ii=${non_ii::-1} # suppression $'\n' - if grep -q '^rc' <<< "$stock_etat"; then + if grep -q '^rc' <<< "$stck_etat"; then alert_non_ii="les paquets dans un état 'rc' (fichiers de configuration orphelins) " alert_non_ii+="peuvent être purgés avec: \n" alert_non_ii+="**dpkg --purge \$(dpkg -l | awk '/^rc/{print \$2}')**" fi fi # deborphan éventuel - if [ "$( f__cmd_exist deborphan )" ]; then + if [ $( f__which deborphan ) ]; then deborphan=$( deborphan -P ) cmd_deborphan="deborphan -P" qte_deborphan=$( f__wcv "-l" "$deborphan" ) [ "$qte_deborphan" -gt 1 ] && pluriel="s" || unset pluriel - comment_deborphan="$qte_deborphan bibliothèque"$pluriel" orpheline"$pluriel - [ "$qte_deborphan" -eq 0 ] && comment_deborphan=${comment_deborphan/0 /aucune } + cmt_deborphan="$qte_deborphan bibliothèque"$pluriel" orpheline"$pluriel + [ "$qte_deborphan" -eq 0 ] && cmt_deborphan=${cmt_deborphan/0 /aucune } if [ "$qte_deborphan" -gt 0 ]; then alert_deborphan="bibliothèque"$pluriel" orpheline"$pluriel", suppression possible: \n" alert_deborphan+="**apt purge \$(deborphan)** \n" @@ -1529,8 +1555,8 @@ fi_pkg_apt(){ #v3 19/11/2017 qte_holded=$( f__wcv "-l" "$holded" ) [ "$holded" ] && holded=$( sort <<< $holded | tr '\n' ' ' ) [ "$qte_holded" -gt 1 ] && pluriel="s" || unset pluriel - comment_holded="$qte_holded paquet"$pluriel" figé"$pluriel - [ "$qte_holded" -eq 0 ] && comment_holded=${comment_holded/0 /aucun } + cmt_holded="$qte_holded paquet"$pluriel" figé"$pluriel + [ "$qte_holded" -eq 0 ] && cmt_holded=${cmt_holded/0 /aucun } cmd_holded="apt-mark showhold" } ### @@ -1540,29 +1566,28 @@ fi_pkg_apt(){ #v3 19/11/2017 text+="* version apt: **$apt_version** \n" text+="\n" f_dspl_alert "info_update" "info" - f_display "sources" "cmd" "$cmd_sources" "$comment_sources" + f_display "sources" "cmd" "$cmd_sources" "$cmt_sources" f_dspl_alert "alert_https" "info" f_dspl_alert "alert_httpsPossible" "info" f_dspl_alert "alert_non_list" "info" f_dspl_alert "alert_httpredir" "info" - f_display "apt_prefs" "cmd" "$cmd_apt_prefs" "$comment_apt_prefs" - f_display "upgrade" "cmd:vide" "$cmd_upgrade" "$comment_upgrade" + f_display "apt_prefs" "cmd" "$cmd_apt_prefs" "$cmt_apt_prefs" + f_display "upgrade" "cmd:vide" "$cmd_upgrade" "$cmt_upgrade" f_dspl_alert "alert_upgrade" "info" - f_display "notUpgraded" "var" "$cmd_notUpgraded" "$comment_notUpgraded" + f_display "notUpgraded" "var" "$cmd_notUpgraded" "$cmt_notUpgraded" f_dspl_alert "alert_full_upgrade" "info" - f_display "toRemove" "cmd:vide" "$cmd_toRemove" "$comment_toRemove" + f_display "toRemove" "cmd:vide" "$cmd_toRemove" "$cmt_toRemove" f_dspl_alert "alert_remove" "info" - f_display "autoclean" "cmd:vide" "$cmd_autoclean" "$comment_autoclean" + f_display "autoclean" "cmd:vide" "$cmd_autoclean" "$cmt_autoclean" f_dspl_alert "alert_autoclean" "info" - f_display "clean" "cmd:vide" "$cmd_clean" "$comment_clean" + f_display "clean" "cmd:vide" "$cmd_clean" "$cmt_clean" f_dspl_alert "alert_clean" "info" - f_display "non_ii" "cmd:vide" "$cmd_non_ii" "$comment_non_ii" + f_display "non_ii" "cmd:vide" "$cmd_non_ii" "$cmt_non_ii" f_dspl_alert "alert_non_ii" "info" - [ "$( f__cmd_exist deborphan )" ] && f_display "deborphan" "cmd:vide" "$cmd_deborphan" \ - "$comment_deborphan" - [ "$( f__cmd_exist deborphan )" ] && f_dspl_alert "alert_deborphan" "info" - f_display "holded" "cmd:vide" "$cmd_holded" "$comment_holded" - printf "$text\n" >> "$fileOutput" + [ $( f__which deborphan ) ] && f_display "deborphan" "cmd:vide" "$cmd_deborphan" "$cmt_deborphan" + [ $( f__which deborphan ) ] && f_dspl_alert "alert_deborphan" "info" + f_display "holded" "cmd:vide" "$cmd_holded" "$cmt_holded" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -1650,7 +1675,7 @@ fi_pkg_x(){ #v2 17/11/2017 f_display "alert_pkg_todo" "var" "" "aide souhaitée" } -fi_reseau(){ # 18/11/2017 +fi_reseau(){ # 20/11/2017 local slots cards ip_a iwconfig interfaces route resolv canal_wifi ifx text pluriel local alert_wlx alert_ifconfig # cardsManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')" @@ -1673,11 +1698,11 @@ fi_reseau(){ # 18/11/2017 interfaces="$(sed -E 's/wpa-psk [[:graph:]]+/wpa-psk /; s/:/: /' <<< $interfaces )" resolv="$(f_grep_file "/etc/resolv.conf" nofile)" # iwconfig - if [ $(f__cmd_exist iwconfig) ]; then #paquet wireless-tools requis + if [ $( f__which iwconfig ) ]; then #paquet wireless-tools requis iwconfig="$(iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^[[:space:]]*$')" fi # iwlist - if [ $(f__cmd_exist iwlist) ]; then # canal wifi utilisé; /sbin, paquet wireless-tools requis + if [ $( f__which iwlist ) ]; then # canal wifi utilisé; /sbin, paquet wireless-tools requis canal_wifi="$(iwlist chan 2>&1 | grep 'Current Frequency' | grep -Eio 'channel [0-9]+')" fi # network manager @@ -1696,7 +1721,7 @@ fi_reseau(){ # 18/11/2017 alert_wlx+="éventuellement, changer le renommage: \n" alert_wlx+="https://kyodev.frama.io/kyopages/trucs/interfaces-nommage-classique/" fi - if [ $(f__cmd_exist ifconfig) ] ; then + if [ $( f__which ifconfig ) ] ; then alert_ifconfig="ifconfig [net-tools](https://github.com/giftnuss/net-tools) est un projet abandonné " alert_ifconfig+="depuis des années. iproute2 (linuxfoundation) le remplace." fi @@ -1707,21 +1732,21 @@ fi_reseau(){ # 18/11/2017 f_display "cards" "cmd" "lspci -nnv | grep -EiA 15 'network|ethernet" # ip locales avec type [ $(f__wcv "-l" "$fg_ip_tp") -gt 1 ] && pluriel="s" || unset pluriel - f_display "fg_ip_tp" "sans" "" "IP locale"$pluriel + f_display "fg_ip_tp" "sans" "" "IP locale"$plurielD f_dspl_alert "alert_wlx" "alert" text+="* les adresses Mac peut être affichées avec "'`./getInfo --mac` ou `getInfo --mac`'" (script installé) \n" text+="* l'IP publique peut être connue avec: "'`./getInfo --ip` ou `getInfo --ip` (script installé) \n\n' # gateways [ $(f__wcv "-l" "$fg_gws") -gt 1 ] && pluriel="s" || unset pluriel - f_display "fg_gws" "var" "" "Passerelle"$pluriel + f_display "fg_gws" "sans" "" "Passerelle"$pluriel # interface prioritaire if [ $(wc -w <<< $fg_ifn) -gt 1 ]; then - f_display "fg_ifn_prior" "var" "" "interface de sortie" + f_display "fg_ifn_prior" "sans" "" "interface de sortie" fi # 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" - f_display "interfaces" "cmd" "grep -EHrsv '#|^$' /etc/network/interfaces*" + f_display "interfaces" "cmd" "grep -EHrsv '#|^$' /etc/network/interfaces*" "configuration manuelle" f_display "resolv" "cmd" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés" # iwconfig & iwlist f_display "iwconfig" "cmd" "iwconfig" "état carte wifi" @@ -1732,24 +1757,19 @@ fi_reseau(){ # 18/11/2017 text+="\`./getInfo --ssid\` ou \`getInfo --ssid\` (script installé) \n\n" fi # network manager + text+="* **gestionnaire de réseau** \n\n" if [ "$netmgrinst" ]; then - text+="### gestionnaire de réseau \n\n" - if [ "$netmgrinst" ]; then - [ $(wc -w <<< $netmgrinst) -gt 1 ] && pluriel="s" || unset pluriel - text+="installé"$pluriel": **$netmgrinst** \n" - else - [ $(wc -w <<< $netmgrnames[@]) -gt 1 ] && pluriel="s" || unset pluriel - text+="non trouvé"$pluriel" parmi: ${netmgrnames[@]} \n" - fi - text+="en fonctionnement: " - [ "$netmgrrun" ] && text+="**$netmgrrun** \n\n" || text+="aucun \n\n" + [ $(wc -w <<< $netmgrinst) -gt 1 ] && pluriel="s" || unset pluriel + text+=" * installé"$pluriel": **$netmgrinst** \n" + text+=" * en fonctionnement: **$netmgrrun** \n\n" + else + text+=" * non trouvé parmi: ${netmgrnames[@]} \n" fi # modules réseau - text+="### modules réseau \n\n" - f_display "fg_mod_net" "var" "liste non garantie complète" + f_display "fg_mod_net" "var" "modules réseau" "liste non garantie complète" [ "$fg_mod_net" ] || text+="**Modules chargés non reconnus**" f_dspl_alert "alert_ifconfig" "info" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -1769,12 +1789,12 @@ fi_serial(){ # 16/11/2017 [ "$fg_batt_serial" ] && text+="$BLUE$fg_batt_serial \n\n$STD" [ "$chassis_serial" ] && text+="$GREEN * Chassis \n" [ "$chassis_serial" ] && text+="$BLUE$chassis_serial \n\n$STD" - echo -e "$text" + echo -en "$text\n" >> "$fileOutput" unset text } fi_ssid(){ # 09/11/2017 - [ "$(f__cmd_exist nmcli)" ] || f__error "NetworkManager requis" + [ $( f__which nmcli ) ] || f__error "NetworkManager requis" local nm_ssid file="/tmp/$$-$RANDOM-fi_ssid" text # nm_ssid="$(grep -Ev '#|^$' /etc/NetworkManager/system-connections/*)" [ "$EUID" -eq 0 ] || echo @@ -1791,37 +1811,35 @@ fi_ssid(){ # 09/11/2017 text="$BOLD configuration(s) ssid networkmanager \n\n" text+="$GREEN""grep -Ehv '#|^$' /etc/NetworkManager/system-connections/*$STD \n\n" text+="$nm_ssid \n\n" - echo -e "$text" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_system_analyse(){ # 19/11/2017 - [ "$(f__cmd_exist systemd)" ] || return 0 # pas systemd - local bootTime bootBlame bootCritic bootGraph srvcFail srvcFail_list isrvc text +fi_system_analyse(){ # 20/11/2017 + [ $( f__which systemd ) ] || return 0 # pas systemd + local bootTime cmd_bootTime cmt_bootTime pluriel text + local srvcFail cmd_srvcFail cmt_srvcFail qte_srvcFail isrvc srvcFail_list + local bootBlame cmd_bootBlame cmt_bootBlame bootCritic cmd_bootCritic cmt_bootCritic + local bootGraph cmd_bootGraph cmt_bootGraph local alert_srvcFail # durée du précédent boot bootTime=$( systemd-analyze time ) bootTime=${bootTime/Startup finished in /Durée de boot: } bootTime=${bootTime/userspace/espace utilisateur} - # détail par service - bootBlame=$( systemd-analyze blame | head -n 20 ) - # services critiques ralentisseurs - bootCritic=$( systemd-analyze critical-chain ) - bootCritic="${bootCritic/The time after the unit is active or started is printed after the \"@\" character./ @: temps pour que l\'unité soit active ou démarrée}" - bootCritic="${bootCritic/The time the unit takes to start is printed after the \"+\" character./ +: temps que l\'unité prend pour démarrer}" - # génération graphique - systemd-analyze plot > "/tmp/getInfo-graph.svg" 2>/dev/null - bootGraph="[file:///tmp/getInfo-graph.svg](file:///tmp/getInfo-graph.svg) \n" - bootGraph+=" * en console: \`xdg-open /tmp/getInfo-graph.svg\` \n" - bootGraph+=" * copier/coller le lien dans la barre d'adresses, l'ouverture automatique ne devrait pas fonctionner dans un navigateur \n" - # workaround, erreur buster en root, fichier non crée - [ -e "/tmp/getInfo-graph.svg" ] || unset bootGraph -# un lien local ne s'ouvrira pas automatiquement :( : http://kb.mozillazine.org/Links_to_local_pages_do_not_work + cmd_bootTime="systemd-analyze time" + cmt_bootTime="durée du boot, avant interface graphique" + # services en erreur # srvcFail=$( systemctl --state=active,failed | grep -cE 'error|not-found|failed' ) - srvcFail=$( systemctl --state=active,failed | gawk '/error|not-found|failed/ { sub(/●/,""); + srvcFail=$( systemctl --state=active,failed | gawk ' + /error|not-found|failed/ { sub(/●/,""); printf "%-50s %-11s %-8s %-8s %s",$1,$2,$3,$4,$5; $1=$2=$3=$4=$5=""; print $0}' ) - if [ $(f__wcv -l $srvcFail) -gt 0 ]; then - alert_srvcFail="statut des services en erreur: \n\n" + cmd_srvcFail="systemctl --state=active,failed | grep -E 'error|not-found|failed'" + qte_srvcFail=$(f__wcv -l $srvcFail) + srvcFail=$( printf "%-50s %-11s %-8s %-8s %s" Unit Load Active Sub Description )$'\n'"$srvcFail" + [ "$qte_srvcFail" -gt 1 ] && pluriel="s" || unset pluriel + cmt_srvcFail="service"$pluriel" en erreur" + if [ "$qte_srvcFail" -gt 0 ]; then + alert_srvcFail="service"$pluriel" en erreur, statut: \n\n" srvcFail_list=$( gawk '{print $1}' <<< "$srvcFail" ) for isrvc in $srvcFail_list; do alert_srvcFail+="\`systemctl status $isrvc\` \n" @@ -1830,19 +1848,37 @@ fi_system_analyse(){ # 19/11/2017 alert_srvcFail+='```\n' done alert_srvcFail=${alert_srvcFail//●} - srvcFail=$( printf "%-50s %-11s %-8s %-8s %s" Unit Load Active Sub Description )$'\n'"$srvcFail" fi + # détail par service + bootBlame=$( systemd-analyze blame | head -n 20 ) + cmd_bootBlame="systemd-analyze blame | head -n 20" + cmt_bootBlame="détail par service" + # services critiques ralentisseurs + bootCritic=$( systemd-analyze critical-chain ) + bootCritic=${bootCritic/The time after the unit is active or started is printed after the \"@\" character./ @: temps auquel l\'unité est active ou démarrée} + bootCritic=${bootCritic/The time the unit takes to start is printed after the \"+\" character./ +: temps que l\'unité prend pour démarrer} + cmd_bootCritic="systemd-analyze critical-chain" + cmt_bootCritic="services critiques ralentisseurs" + # génération graphique + systemd-analyze plot > "/tmp/getInfo-graph.svg" 2>/dev/null + bootGraph="en console: \`xdg-open /tmp/getInfo-graph.svg\` \n" + bootGraph+="* dans un navigateur: copier/coller ce lien dans la barre d'adresses " + bootGraph+="file:///tmp/getInfo-graph.svg \n" +# un lien local ne s'ouvrira pas automatiquement :( : http://kb.mozillazine.org/Links_to_local_pages_do_not_work + cmd_bootGraph="systemd-analyze plot > graph.svg ; xdg-open graph.svg" + cmt_bootGraph="graph durées et ordre de chargement des services" + # workaround, erreur buster en root, fichier non crée + [ -e "/tmp/getInfo-graph.svg" ] || unset bootGraph ### text="## analyse boot systemd \n\n" [ "$srvcFail" ] || text+="* pas de service en erreur \n\n" - f_display "bootTime" "cmd" "systemd-analyze time" "durée du précédent boot avant interface graphique" - f_display "srvcFail" "cmd" "systemctl --state=active,failed | grep -E 'error|not-found|failed'" "services en erreur" + f_display "bootTime" "cmd" "$cmd_bootTime" "$cmt_bootTime" + f_display "srvcFail" "cmd" "$cmd_srvcFail" "$cmt_srvcFail" f_dspl_alert "alert_srvcFail" "alert" - f_display "bootBlame" "cmd" "systemd-analyze blame | head -n 20" "détail par service" - f_display "bootCritic" "cmd" "systemd-analyze critical-chain" "services critiques ralentisseurs" - f_display "bootGraph" "cmd:text" "systemd-analyze plot > graph.svg ; xdg-open graph.svg" \ - "graph durées et ordre de chargement des services" - printf "$text\n" >> "$fileOutput" + f_display "bootBlame" "cmd" "$cmd_bootBlame" "$cmt_bootBlame" + f_display "bootCritic" "cmd" "$cmd_bootCritic" "$cmt_bootCritic" + f_display "bootGraph" "cmd:text" "$cmd_bootGraph" "$cmt_bootGraph" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -1958,7 +1994,7 @@ fi_systeme(){ # 19/11/2017 f_dspl_alert "alert_SLiM" "info" f_dspl_alert "alert_microcode" "info" [ "$alert_microcode" ] || text+="* les microcodes sont installés\n\n" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -1970,13 +2006,13 @@ fi_usb(){ # 25/10/2017 text="## USB \n\n" f_display "lsusb" "cmd" "lsusb" f_display "lsusb_t" "cmd" "lsusb -t" - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } -fi_vrms(){ # 15/11/2017 +fi_vrms(){ # 20/11/2017 local vrms non_free contrib total text pluriel tempo - if [ "$(f__cmd_exist vrms)" ]; then + if [ $( f__which vrms ) ]; then vrms="$(vrms)" non_free=$(($( sed -En 's/([0-9]+) non-free packages,.*/\1/p' <<< "$vrms" ))) contrib=$(($( sed -En 's/([0-9]+) contrib packages,.*/\1/p' <<< "$vrms" ))) @@ -2001,7 +2037,7 @@ fi_vrms(){ # 15/11/2017 else text+="* les paquets non-free ou contrib ne peuvent être détectés sans l'installation de vrms \n" fi - printf "$text\n" >> "$fileOutput" + echo -en "$text\n" >> "$fileOutput" unset text } @@ -2286,10 +2322,10 @@ figet_cpu_uarch(){ # 05/11/2017 [ "$fg_uarch" ] && fg_uarch+=" {0x$family|0x$model}" } -figet_de(){ # thanks neofetch, assigne $fg_de #30/10/2017 +figet_de(){ # thanks neofetch, assigne $fg_de #20/11/2017 fg_de="n/a (ssh)" [ "$ENV_SSH" ] && return 0 || fg_de="n/a" - [ "$(f__cmd_exist xprop)" ] || return 0 + [ $( f__which xprop ) ] || return 0 local de="n/a" de="$XDG_CURRENT_DESKTOP" de="${de/'X-'}" @@ -2621,7 +2657,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(){ # 09/11/2017 local ifn - [ "$(f__cmd_exist ip)" ] || return 1 + [ $( f__which ip ) ] || return 1 fg_ip="$(sed '/[[:digit:]]:[[:blank:]]lo.*inet/d; /inet6.*scope/d' <<< $(ip -o a) | gawk '{print " ",$4,"(",$2,")"}')" fg_ip_tp="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $fg_ip)" fg_gws="$(LC_ALL=C ip -4 route | gawk '/default via/ {print " ",$3,"(",$5,")"}')" @@ -2640,7 +2676,7 @@ figet_ip(){ # 09/11/2017 } # $1=4|6, assigne $fg_public -figet_ip_pub(){ # 27/10/2017 +figet_ip_pub(){ # 20/11/2017 local dig_test ip_test iip list_ip4(){ ip_test+=" http://whatismyip.akamai.com" @@ -2691,14 +2727,14 @@ figet_ip_pub(){ # 27/10/2017 ip_telnet=6.ifcfg.me fi - if [ "$(f__cmd_exist dig)" ] && [ -z "$fg_public" ]; then + if [ $( f__which dig ) ] && [ -z "$fg_public" ]; then for iip in $dig_test ; do fg_public="$(dig +short $(sed 's;/; ;g' <<< $iip))" [ "$fg_public" ] && break done fi - if [ "$(f__cmd_exist wget)" ] && [ -z "$fg_public" ]; then + if [ $( f__which wget ) ] && [ -z "$fg_public" ]; then cmd="wget --quiet --timeout=5 -O - " for iip in $ip_test ; do fg_public="$($cmd $iip)" @@ -2706,7 +2742,7 @@ figet_ip_pub(){ # 27/10/2017 done fi - if [ "$(f__cmd_exist curl)" ] && [ -z "$fg_public" ]; then + if [ $( f__which curl ) ] && [ -z "$fg_public" ]; then cmd="curl --silent --location --retry 0 --max-time 5" #--location pour aider redirections for iip in $ip_test ; do fg_public="$($cmd $iip)" @@ -2714,11 +2750,11 @@ figet_ip_pub(){ # 27/10/2017 done fi - if [ "$(f__cmd_exist telnet)" ] && [ -z "$fg_public" ]; then + if [ $( f__which telnet ) ] && [ -z "$fg_public" ]; then fg_public="$(telnet $ip_telnet 23 2>/dev/null | grep $1 | cut -d ' ' -f 4)" fi - if [ "$(f__cmd_exist nc)" ] && [ -z "$fg_public" ] && [ "$1" != "IPv6" ]; then + if [ $( f__which nc ) ] && [ -z "$fg_public" ] && [ "$1" != "IPv6" ]; then fg_public="$(nc $ip_telnet 23 2>/dev/null | grep $1 | cut -d ' ' -f 4)" fi @@ -2800,7 +2836,8 @@ figet_mem(){ # 09/11/2017 [ "$fg_mem" ] && fg_mem=${fg_mem::-1} # suppression dernier $'\n' } -figet_mod_net(){ # thanks wireless-info, assigne $fg_mod_net # 30/10/2017 + # assigne $fg_mod_net # 30/10/2017 +figet_mod_net(){ # thanks wireless-info local MODMATCHES LSMODMATCHES MODMATCHES="(air|ar5|at7|ath[^3]?|b43|bcma|brcm|carl|ipw|iwl|ndis|r(818|8192[eu]|871|92su)|8(188|189|192|723|812)[acde][esu]|rt[23567]|rtl|ssb|wl|(cfg|mac)80211)" LSMODMATCHES="(wmi|(dell|ideapad)[-_]laptop)" @@ -2808,15 +2845,15 @@ figet_mod_net(){ # thanks wireless-info, assigne $fg_mod_net # 30/10/2017 } # assigne $fg_nb_screen, $fg_resolution. return fg_resolution=n/a[ (ssh)] & fg_nb_screen=n/a ou valeurs -figet_screen(){ #v2 30/10/2017 +figet_screen(){ #v2 20/11/2017 fg_nb_screen="n/a" fg_resolution="n/a" [ "$ENV_SSH" ] && fg_resolution+=" (ssh)" [ "$ENV_SSH" ] && return 0 # xrandr & et xdpyinfo ne retourne pas de nombre écrans correct (multiplex? hybrid?) - if [ $(f__cmd_exist xrandr) ]; then + if [ $( f__which xrandr ) ]; then fg_resolution=$( gawk '/[0-9]\*/ {gsub(/\*\+/,"",$2); printf "%s pixels (%dHz), ", $1, $2}' <<< $( xrandr --query ) ) - elif [ $(f__cmd_exist xdpyinfo) ]; then + elif [ $( f__which xdpyinfo ) ]; then fg_resolution=$( gawk '/dimensions/ { print $2, $3 ", " }' <<< $(xdpyinfo) ) fi fg_resolution="${fg_resolution%,*}" # suppression ',*' @@ -2846,7 +2883,7 @@ figet_shell(){ # thanks neofetch, assigne $fg_shell # 30/10/2017 fg_shell="$shell" } -figet_test_batt(){ # 23/10/2017 +figet_test_batt(){ # 20/11/2017 local text var_temp objet # matériel figet_dmi @@ -2856,13 +2893,13 @@ figet_test_batt(){ # 23/10/2017 text="--- \n\n" text+="## batterie test \n\n" # acpi éventuel - if [ "$(f__cmd_exist acpi)" ]; then + if [ $( f__which acpi ) ]; then var_temp=$(acpi -abi) - [ "$var_temp" ] || var_temp="pas de batterie dans $(f__cmd_exist acpi)" + [ "$var_temp" ] || var_temp="pas de batterie dans $( f__which acpi )" f_display "var_temp" "cmd" "acpi -abi" fi # upower - if [ "$(f__cmd_exist upower)" ]; then + if [ $( f__which upower ) ]; then objet=$(grep -i 'battery' <<< $(upower -e)) var_temp=$(upower -i $objet) f_display "var_temp" "cmd" "upower -i $objet" @@ -2906,7 +2943,7 @@ figet_test_gpu(){ # 30/10/2017 f_display "fg_gpu" "var" "fg_gpu" } -figet_test_hw(){ # 11/11/2017 +figet_test_hw(){ # 20/11/2017 local text var_temp # matériel figet_dmi @@ -2915,11 +2952,11 @@ figet_test_hw(){ # 11/11/2017 ### text+="## hwmon test \n\n" # sensors et acpi éventuel - if [ "$(f__cmd_exist sensors)" ]; then + if [ $( f__which sensors ) ]; then var_temp=$(sensors -u) f_display "var_temp" "cmd" "sensors -u" fi - if [ "$(f__cmd_exist acpi)" ]; then + if [ $( f__which acpi ) ]; then var_temp=$(acpi -V | grep -E 'Thermal|Cooling') f_display "var_temp" "cmd" "acpi -V" fi @@ -2949,7 +2986,7 @@ figet_test_hw(){ # 11/11/2017 figet_wm(){ # thanks neofetch, assigne $fg_wm # 30/10/2017 fg_wm="n/a (ssh)" [ "$ENV_SSH" ] && return 0 || fg_wm="n/a" - [ "$(f__cmd_exist xprop)" ] || return 0 + [ $( f__which xprop ) ] || return 0 local id wm if [ -n "$DISPLAY" ]; then id="$(xprop -root -notype _NET_SUPPORTING_WM_CHECK | cut -d' ' -f5)" @@ -3157,9 +3194,10 @@ prg_1(){ # début echo -e "> $script sur *$(uname -n)* \n" > "$fileOutput" echo -e "$ligneRapport \n\n" >> "$fileOutput" } -prg_2(){ # traitements principaux - if [ "$EUID" -eq 0 ]; then - f__info "des erreurs$YELLOW No protocol specified, Can't open display :0$BLUE peut indiquer un défaut de configuration système (Xorg, Wayland?)" \ +prg_2(){ # traitements principaux 20/11/2017 + # essai détection erreur No protocol specified, Can't open display :0 (root Fedora) + if [ -z "$DISPLAY" ]; then + f__info "des erreurs$YELLOW Can't open display$BLUE peut indiquer un défaut de configuration système (Xorg, Wayland?)" \ "lancer le script en utilisateur pour avoir toutes les informations" fi if [[ "$1" == all || "$1" =~ s ]]; then #systeme, matériel -cs @@ -3319,7 +3357,7 @@ for j in $options; do case $j in -t | --test ) prg_1 "$*" - fi_packagers + fi_graph exit ;; # test -c* | all ) [ "$j" == "-c" ] && exec $0 "menu" diff --git a/scripts/getInfo_changelog.md b/scripts/getInfo_changelog.md index de053fa..e56e88d 100644 --- a/scripts/getInfo_changelog.md +++ b/scripts/getInfo_changelog.md @@ -4,6 +4,12 @@ * ! f__requis, fscript_install, f__scandir +## 2.41.0 20/11/2017 + +* révision: fi_graph, multi-cartes +* révision: fi_nm, cas ou pas de wifi à proximité, révision +* fix mineurs: f_display, fi_reseau, affichage + ## 2.40.2 19/11/2017 * nouveau: fi_pkg_apt, alert htps