getInfo 2.46.0

This commit is contained in:
kyodev 2017-11-27 06:26:24 +01:00
parent 0a18474665
commit 15f4bda4fc
2 changed files with 68 additions and 57 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.45.6
date="25/11/2017"
version=2.46.0
date="26/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -330,7 +330,7 @@ f_display(){ # 20/11/2017
[[ "${!1}" || "$2" =~ :vide ]] || return 0 # test si contenu dans $1
local display="" toDisplay="${!1}"
# flush, avant fonction, de $text parent
[ "$text" ] && echo -en "$text\n" >> "$fileOutput"
[ "$text" ] && echo -en "$text" >> "$fileOutput"
unset text
# traitement ligne de titre
[ "$toDisplay" ] || toDisplay="vide" # cas si :vide
@ -451,34 +451,44 @@ f_dspl_scandir(){ # 21/10/2017
}
# $1=liste fichier(s) à grepper, [$2]: largeur 1ère colonne &| nofile &| novide &| ligneVide
# si 'nofile' pas d'énumération de fichier greppé, si aucun fichier retour 'nofile',
## concatène les fichiers, induit novide
# si novide pas d'indication vide,
# ex. cumul option: " 10 novide" '10-novide-nofile' fonctionne
# si ligneVide, pas de suppression des lignes vides
# grep -Ersv '^[[:blank:]]*#|^[[:blank:]]*$' file|dossier
f_grep_file(){ # 22/11/2017
# si aucun fichier dans la liste retour: 'nofile|vide|inexistant
# si novide pas d'indication vide
# si 'notitre' pas d'énumération de fichier greppé (destiné à un seul fichier)
# si 'noinexist' pas de titre si fichier inexistant
# si lignevide, pas de suppression des lignes vides
# ex. cumul option: "10 novide nofile lignevide"
# cmd de base: grep -Ersv '^#|^$' file|dossier
f_grep_file(){ # 26/11/2017
local file content display
for file in $1; do
content=$( grep -Ersv '^[[:blank:]]*#|^[[:blank:]]*$' "$file")
[[ ${2,,} =~ lignevide ]] && content=$( grep -Ersv '^[[:blank:]]*#' "$file")
[ -d "$file" ] && file+='/' # si répertoire, ajout / final
content=${content//$file} # joli, suppression de $file dans les noms de fichiers en tête de ligne
if [[ "$2" =~ [0-9] ]]; then # si $2 contient des chiffres, largeur, gawk
# contenu
if [[ "${2,,}" =~ lignevide ]]; then
content=$( grep -Ersv '^[[:blank:]]*#' "$file")
else
content=$( grep -Ersv '^[[:blank:]]*#|^[[:blank:]]*$' "$file")
fi
if [[ "$2" =~ [0-9] ]]; then # si $2 contient des chiffres (largeur), gawk
content=$(gawk -v "larg=${2//[[:alpha:]]}" '
{ printf "%-"larg"s",$1; $1=""; printf "%s\n",$0 }
/^[[:graph:]]/ { printf "%-"larg"s",$1; $1=""; printf "%s\n",$0 } # graph exclut ligne vide ou retour grep vide
' <<< "$content")
fi
#echo "***"
#[ -z "$content" ] && unset content
content=${content%%[[:space:]]}
#echo -n "$content"
#echo "***"
content+=$'\n'
[[ "$2" =~ nofile ]] || display+=" $file \n" # nom fichier greppé si $2 pas 'nofile'
[[ "$2" =~ novide || "$content" ]] && display+="$content"$'\n' || display+=" ‣ vide"$'\n'
[ -d "$file" ] && file+='/' # si répertoire, ajout / final, joli
content=${content//$file} # joli, suppression de $file dans les noms de fichiers entete grep
# mise en forme
if [[ ! "${2,,}" =~ notitre ]]; then # titre
if [ -e "$file" ]; then
display+=" $file \n"
else
[[ "${2,,}" =~ "noinexist" ]] || display+=" $file: inexistant"$'\n\n'
fi
fi
if [ "$content" ]; then
display+="$content"$'\n\n'
elif [[ ! "$2" =~ novide && -e "$file" ]]; then
display+=" ‣ vide"$'\n\n'
fi
done
display=${display::-1}
display=${display%%[[:space:]]}
[ "$display" ] || display="nofile" # si display vide, inscription 'nofile'
echo -en "$display"
}
@ -530,8 +540,8 @@ fi_batt(){ # 10/11/2017
unset text
}
fi_conf(){ # 22/11/2017
local conf toScrut=(
fi_conf(){ # 26/11/2017
local confs file grepP toScrut=(
/etc/sysctl.conf
'/etc/sysctl.d/*.conf'
'/etc/hostname' # debian
@ -546,19 +556,13 @@ fi_conf(){ # 22/11/2017
# /etc/machine-id # voir fi-serial
/etc/machine-info
)
#conf=$( f_grep_file "${toScrut[@]}" )
#f_grep_file "${toScrut[*]}" "nofile novide"
echo "----"
#f_grep_file "/etc/apt/s" "nofile esc"
#f_grep_file "/etc/apt/sources.list.d" "nofile"
f_grep_file "/etc/apt/sources.list /etc/apt/sources.list.d/* /etc/toto" ""
echo "----"
#f_grep_file "/etc/apt/sources.list /etc/apt/sources.list.d/* /etc/toto" "nofile"
#echo "----"
#echo $conf
###
text="## fichiers conf divers \n\n"
f_display "conf" "cmd" "grep "
confs=$( f_grep_file "${toScrut[*]}" "noinexist" )
for file in ${toScrut[*]}; do
[ -e "$file" ] && grepP+=" $file" # fichiers présents
done
###
text="## fichiers configuration divers \n\n"
f_display "confs" "cmd" "grep -Ersv '^#|^$' $grepP"
echo -en "$text\n" >> "$fileOutput"
unset text
}
@ -611,9 +615,9 @@ fi_disk(){ # 25/11/2017
# lsblk répertoire disques & partitions
disk_lsblk=$( lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID )
# fstab
fstab=$( f_grep_file "/etc/fstab" "nofile" )
fstab=$( f_grep_file "/etc/fstab" "notitre" )
# resume
resume=$( f_grep_file "/etc/initramfs-tools/conf.d/resume" "nofile" )
resume=$( f_grep_file "/etc/initramfs-tools/conf.d/resume" "notitre" )
if [ "$resume" == "nofile" ]; then
# alert resume absent
alert_file_resume="Pas de fichier _resume_ dans /etc/initramfs-tools/conf.d/ \n"
@ -907,9 +911,9 @@ fi_hw(){ # 25/11/2017
unset text
}
fi_journal(){ # 25/11/2017
fi_journal(){ # 26/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 info_ucode text nb_lignes=25
local alert_jctl_persist alert_firmBug
if [ -z $( f__which journalctl ) ]; then
fi_dmesg # pas systemd, appel dmesg
@ -924,6 +928,7 @@ fi_journal(){ # 25/11/2017
LC_ALL=C journalctl --no-pager --no-hostname --boot 0 -p 4..4 > $file-warn ; \
LC_ALL=C journalctl --no-pager --no-hostname --boot 0 -p 4 -n$nb_lignes > $file-last ; \
LC_ALL=C journalctl --disk-usage > $file-size ; \
LC_ALL=C journalctl -o short-monotonic -b -k -p6 > $file-ucode ; \
chown $user_: $file-*"
if [ "$?" != "0" ]; then
f__info "\n les commandes$GREEN journalctl$RED ont échoué $BLUE(droits root requis, échec authentification?)" \
@ -965,6 +970,9 @@ fi_journal(){ # 25/11/2017
' $file-warn | sed -n 1,"$nb_lignes"p )
# dernières lignes, toute provenance
jctl_last=$( sed '/-- Logs begin/d; s/-- No entries --/ ‣ vide/;s/<warn>//' $file-last )
# messages microcode
info_ucode=$( grep 'microcode: .*updated early' $file-ucode )
[ "$info_ucode" ] && info_ucode="microde processeur mis à jour au boot"
# suppression fichier de transfert
rm "$file-"*
alert_firmBug=$( grep -i 'Firmware Bug' <<< $jctl_err_k )
@ -1006,6 +1014,7 @@ fi_journal(){ # 25/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"
f_dspl_alert "info_ucode" "info"
echo -en "$text\n" >> "$fileOutput"
unset text
}
@ -1123,7 +1132,7 @@ fi_nm(){ # 23/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" )
nm_etat=$( f_grep_file "/var/lib/NetworkManager/NetworkManager.state" "notitre" )
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 /etc/NetworkManager/conf.d/*.conf" )
@ -1525,7 +1534,7 @@ fi_reseau(){ # 20/11/2017
# interfaces & resolv
interfaces=$( f_grep_file "/etc/network/interfaces*" )
interfaces=$( sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )
resolv=$( f_grep_file "/etc/resolv.conf" nofile )
resolv=$( f_grep_file "/etc/resolv.conf" "notitre" )
# iwconfig
if [ $( f__which iwconfig ) ]; then #paquet wireless-tools requis
iwconfig=$( LC_ALL=C iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^[[:space:]]*$' )
@ -1556,7 +1565,7 @@ fi_reseau(){ # 20/11/2017
fi
[ "$fg_mod_net" ] || figet_mod_net
###
text="## réseau \n\n"
# text="## réseau \n\n"
#lspci
f_display "cards" "cmd" "lspci -nnv | grep -EiA 15 'network|ethernet"
# ip locales avec type
@ -1626,7 +1635,7 @@ fi_ssid(){ #v2 22/11/2017
local fileOutput="/tmp/$RANDOM-$RANDOM" # ré-assigne sortie pour f_display
[ "$EUID" -eq 0 ] || f__error "Root requis"
[ $( f__which nmcli ) ] || f__error "NetworkManager requis"
nm_ssid=$( f_grep_file "/etc/NetworkManager/system-connections/*" "ligneVide" )
nm_ssid=$( f_grep_file "/etc/NetworkManager/system-connections/*" "lignevide" )
###
f__info "$RED""Attention:$BLUE la clé du réseau wifi est visible"
text="## configuration(s) ssid networkmanager \n\n"
@ -1779,7 +1788,7 @@ fi_systeme(){ # 25/11/2017
fi
###
f__architecture || f__info "Architecture non supportée"
text="## système \n\n"
# text="## système \n\n"
text+="> **$fg_dmi** \n\n"
text+="* CPU \n"
text+=" * **$(sed -n '1p' <<< $fg_cpu)** \n"
@ -2994,7 +3003,7 @@ figet_shell(){ #v2 25/11/2017 # thanks neofetch
fg_shell="${fg_shell^} $shell"
# shells installés détectés
if [ -e "/etc/shells" ]; then # by-pass sinon soucis sous fedora et openSuse?
for ish in $( f_grep_file "/etc/shells" "nofile" ); do # élimine lignes vides et commentées
for ish in $( f_grep_file "/etc/shells" "notitre" ); do # élimine lignes vides et commentées
fg_shells+=${ish##*/}" " # conservation dernier "champs", ifs '/'
done
fg_shells=${fg_shells% } # suppression espace de fin
@ -3455,7 +3464,7 @@ prg_2(){ # traitements principaux 21/11/2017
fi
if [[ "$1" == all || "$1" =~ c ]]; then #configuration #debian, packages -cc fi_conf
echo -e "# ▷ Configuration \n\n" >> "$fileOutput"
for i in fi_locale fi_vrms fi_packagers ; do
for i in fi_locale fi_conf fi_vrms fi_packagers ; do
echo -n "•"
$i
done

View File

@ -4,6 +4,14 @@
* ! f__requis (debOnly), fscript_install, f__scandir
## 2.46.0 26/11/2017
* nouveau: fi_conf
* révision: f_grep
* révision: fi_journal, info_ucode
## 2.45.6 25/11/2017
* nouveau: gestion no $DISPLAY
@ -76,19 +84,16 @@
* fix: fi_pkg_apt, détection full-upgrade
* fix: fi_disk, détection fichier resume absent
## 2.37.3 17/11/2017
* révision complète: fi_packager fi_pkg_x
* fusion pkg_ctl & fi_packager
* fix: affichage microcodes installés
## 2.36.4 17/11/2017
* fix mineurs: fi_pkg_apt
## 2.36.0 16/11/2017
* nouveau: fi_pkg_apt, test paquets hold, révision affichage & non standard
@ -96,7 +101,6 @@
* révision: fi_serial
* révision: fi_system_analyse, fi_systeme, présentation si aucune alerte
## 2.35.3 15/11/2017
* nouveau, révision : f_display, fi_system_analyse, affichage + services critiques, graphique services au chargement
@ -137,14 +141,12 @@ fix: localisation fichier shells correcte (et non test)
* révision: fi_vrms
* fix: détection paquet non installés
## 2.30.0 10/11/2017
* révision fonctions affichage (f_display, f_grep_file, f_dspl_alert, suppression f_dspl_file_KO)
* fi_journal, f_disk, fi-graph, fi_locale, fi_reseau, fi_sources, fi_cpu, fi_hw
* fix: fi_journal, mauvaise détection journaux non persistants
## 2.29.0 10/11/2017
* nouveau: figet_gpu v3, retourne infos et nb de gpu quelque soit options lspci