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

View File

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