getInfo 2.53.1

This commit is contained in:
kyodev 2017-12-03 13:48:03 +01:00
parent 7e5faf6080
commit ad2f190bda
3 changed files with 4191 additions and 194 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.53.0
date="02/12/2017"
version=2.53.1
date="03/12/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -194,17 +194,17 @@ f__sudo(){ # 22/10/2017
# user ayant initié la session graphique, assigne $fu_user
# return 1 sur échec identification user, return 2 sur absence home/
# gestion variable environnement user avec: USER_INSTALL=<user> script
f__user(){ # 2/12/2017
f__user(){ # 3/12/2017
local user userid test root_login
root_login="$(grep ':0:' /etc/passwd | cut -d':' -f1)" || root_login="root"
if [ "$USER_INSTALL" ]; then # user via variable environnement, moyen d'injecter root
user="$USER_INSTALL";
if [ "$USER_INSTALL" ]; then # user via variable environnement, moyen d'injecter root si pb
fu_user="$USER_INSTALL";
return 0
elif [[ "$TERM" =~ linux ]]; then #debian 9 recovery ou nomodeset TERM=linux
if [ "$USER" ]; then
user="$USER"
elif [ "$EUID" -eq 0 ]; then
user="$root_login"
fu_user="$root_login"
return 0
fi
fi
@ -217,6 +217,7 @@ f__user(){ # 2/12/2017
fi
[ "$userid" ] && user="$(grep $userid /etc/passwd | cut -d ":" -f 1 )"
if [ "$user" ] && [ "$user" != "$root_login" ]; then
fu_user="$user"
return 0
else
if [ "$SUDO_USER" ] && [ "$SUDO_USER" != "$root_login" ]; then
@ -228,8 +229,8 @@ f__user(){ # 2/12/2017
fi
fi
fu_user="$user"
if [ -z "$fu_user" ]; then return 1; fi
if [ ! -d "/home/$fu_user" ]; then return 2; fi
[ "$fu_user" ] || return 1
[ -d "/home/$fu_user" ] || return 2
return 0
}
@ -321,18 +322,18 @@ f_affichage(){ # 2/12/2017
# $1: cmd->`titre`, var->**titre**, sans: pas de titre
# :text ajouté, affiche le text en liste (avec puce)
# :vide bypass le test de contenu $2, affiche 'vide', si besoin, en liste
# "variable" "sans" "" "comment" -> pas de titre mais commentaire encadré
# passage en paramètre variable et pas $variable
# passage en paramètre VARIABLE et pas $variable
# un test si variable $2 est vide est fait sauf ':vide'
# un test si variable $2 contient 'nofile' (non trouvé par f_grep_file)
# f_di "variable" "type" "titre" "commentaire"
f_di(){ # 1/12/2017
local display='' toDisplay="${!2}"
f_di(){ # 2/12/2017
local display='' toDisplay
[ "$text" ] && echo -en "$text" >> "$fileOutput" # flush, avant fonction, de $text parent
unset text
[[ "${!2}" || "$1" =~ :vide ]] || return 0 # test si contenu dans $2
toDisplay="$2"
[[ "$2" || "$1" =~ :vide ]] || return 0 # test si contenu dans $2
# traitement ligne de titre
[ "$toDisplay" ] || toDisplay="vide" # cas si :vide
[[ "$1" =~ sans|var|cmd ]] || display=" **⚡ erreur f_di \$1 ($2 $3) ⚡** \n" # test $1 valide
@ -355,10 +356,9 @@ f_di(){ # 1/12/2017
}
# $1 variable à afficher en alerte/info, [$2 alert|info] type de message, alert par défaut
# passage en paramètre variable et pas $variable
# un test si variable $1 est vide ou non est fait
f_dspl_alrt(){ # 21/11/2017
[ "${!1}" ] || return 0 # test si contenu dans $1
[ "$1" ] || return 0 # test si contenu dans $1
local display type
# flush, avant fonction, de $text parent
[ "$text" ] && echo -en "$text\n" >> "$fileOutput"
@ -367,8 +367,8 @@ f_dspl_alrt(){ # 21/11/2017
[[ "$2" =~ info ]] && type="info"
[[ "$2" =~ alert ]] && type="alert"
[ "$2" ] || type="alert" # alert par défaut
[ "$type" == "alert" ] && display="> ↯ ${!1} \n\n"
[ "$type" == "info" ] && display=" ☛ ${!1} \n\n"
[ "$type" == "alert" ] && display="> ↯ $1 \n\n"
[ "$type" == "info" ] && display=" ☛ $1 \n\n"
echo -en "$display\n" >> "$fileOutput" # flush fonction
}
@ -377,7 +377,7 @@ f_dspl_alrt(){ # 21/11/2017
# 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(){ # 27/11/2017
f_dspl_md(){ # 3/12/2017
local display display2 ligne margin
if [ ! -f "$1" ]; then
f__info "pas de rapport à afficher, vous devez lancer une analyse auparavant:" \
@ -394,7 +394,7 @@ f_dspl_md(){ # 27/11/2017
display=${display//\`\`\`/------------} # transforme ``` en ---, plus visibles
# traitement par lignes, à là sed, obligatoire pour les titres #
# plus simple pour les multi-patterns, sinon matches multilignes délicats à gérer en cas d'impairage
IFS="\n"
IFS=$'\n' # normalement inutile
display=${display//\\/\\\\} # echappement des antislash, utile pour efiboot
while read ligne; do
ligne=${ligne//\\/\\\\} # re echappement des antislash, utile pour efiboot, méthode bourrin, sans comprendre le pourquoi
@ -451,28 +451,36 @@ f_dspl_scandir(){ # 21/10/2017
echo -e "$text" >> "$fileOutput" # flush fonction
}
# $1=liste fichier(s) à grepper, [$2]: largeur 1ère colonne &| nofile &| novide &| ligneVide &| date
# $1=liste fichier(s) à grepper, [$2]: largeur 1ère colonne &| nofile &| novide &| ligneVide &| date &| commentXY
# si aucun fichier dans la liste retour: 'nofile|vide|inexistant'
# option 'novide' pas d'indication vide
# option 'notitre' pas d'énumération de fichier greppé (destiné à un seul fichier)
# option 'noinexist' pas de titre si fichier inexistant
# option 'lignevide', pas de suppression des lignes vides
# option 'date', date de modification du fichier
# option 'commentXY', commentaire supplémentaire à filtrer, ex: comment//, incompatible avec larg.colonne
# ex. cumul option: "10 novide nofile lignevide"
# cmd de base: grep -Ersv '^#|^$' file|dossier
f_grep_file(){ # 27/11/2017
local file content display
# cmd de base: grep -Ersv '^#|^$' file|dossier "options"
f_grep_file(){ # 3/12/2017
local file content display motif
if [[ "$2" =~ lignevide ]]; then
motif= "^[[:blank:]]*#"
elif [[ "$2" =~ comment ]]; then
comment=${2#comment} # on garde les symboles de commentaires
motif="^[[:blank:]]*$comment|^[[:blank:]]*#|^[[:blank:]]*$"
else
motif="^[[:blank:]]*#|^[[:blank:]]*$" # motif de base
fi
for file in $1; do
# 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:]]}" '
/^[[:graph:]]/ { printf "%-"larg"s",$1; $1=""; printf "%s\n",$0 } # graph exclut ligne vide ou retour grep vide
' <<< "$content")
else
content=$( grep -Ersv $motif "$file" 2>&1)
fi
[ -d "$file" ] && file+='/' # si répertoire, ajout / final, joli
content=${content//$file} # joli, suppression de $file dans les noms de fichiers entete grep
@ -482,10 +490,10 @@ f_grep_file(){ # 27/11/2017
if [[ "${2,,}" =~ "date" ]]; then
display+=" $file, date de modification: $( date -r $file '+%d/%m/%Y %H:%M %z' ) \n"
else
display+=" $file \n"
display+="---- $file \n"
fi
else
[[ "${2,,}" =~ "noinexist" ]] || display+=" $file: inexistant"$'\n\n'
[[ "${2,,}" =~ "noinexist" ]] || display+="---- $file: inexistant"$'\n\n'
fi
fi
if [ "$content" ]; then
@ -631,12 +639,12 @@ fi_audio(){ # 1/12/2017
f_pr l "$(sed -E 's/(.*)/**\1** /' <<< $fe_cards_audio)" # en gras
f_pr
# lspci -nnv
f_di cmd "cardsAudio" "$cmd_cards"
f_dspl_alrt "alert_alsa" "alert"
f_di cmd "version_alsa" "/proc/asound/version" "driver alsa (Advanced Linux Sound Architecture)"
f_di cmd "card_alsa" "$cmd_card_alsa" "$cmt_card_alsa"
f_di cmd "mod" "$cmd_mod" "$cmt_mod"
f_di cmd "modules" "$cmd_modules" "$cmt_modules"
f_di cmd "$cardsAudio" "$cmd_cards"
f_dspl_alrt "$alert_alsa" "alert"
f_di cmd "$version_alsa" "/proc/asound/version" "driver alsa (Advanced Linux Sound Architecture)"
f_di cmd "$card_alsa" "$cmd_card_alsa" "$cmt_card_alsa"
f_di cmd "$mod" "$cmd_mod" "$cmt_mod"
f_di cmd "$modules" "$cmd_modules" "$cmt_modules"
}
fi_batt(){ # 1/12/2017
@ -647,7 +655,7 @@ fi_batt(){ # 1/12/2017
[ "$fg_nb_batt" -gt 1 ] && pluriel="s" || unset pluriel
###
f_pr titre2 "batterie"$pluriel
f_di sans "fg_batt"
f_di sans "$fg_batt"
}
# [$1=silent] (pas d'affichage), assigne $fe_nb_bluez, $fe_cards_bluez
@ -666,7 +674,7 @@ fi_bluez(){ # 1/12/2017
[ "$1" == "silent" ] && return 0
###
[ "$alert_na" ] && alert_na="Bluetooth inaccessible, en erreur"
f_dspl_alrt "alert_na" "alert"
f_dspl_alrt "$alert_na" "alert"
[ "$fe_nb_bluez" -eq 0 ] && return 0
###
# état
@ -683,33 +691,34 @@ fi_bluez(){ # 1/12/2017
srch_mod=${fg_modMotif//|/ } # fg_modMotif motif de recherche, avec |
###
f_pr titre2 "Bluetooth"
f_di cmd "bluez" "$cmd_bluez" "$cmt_bluez"
f_di cmd "mod" "$cmd_mod" "$cmt_mod"
f_di var "srch_mod" "" "* recherche parmi:"
f_di cmd "$bluez" "$cmd_bluez" "$cmt_bluez"
f_di cmd "$mod" "$cmd_mod" "$cmt_mod"
f_di var "$srch_mod" "" "* recherche parmi:"
}
fi_conf(){ # 2/12/2017
fi_conf(){ # 3/12/2017
local confs toScrut=(
/etc/sysctl.conf
'/etc/sysctl.d/*.conf'
'/etc/hostname' # debian
/etc/sysconfig/network # fedora?
/etc/HOSTNAME # suse
# /etc/os-release # nouveau standard systemd/freedesktop
'/etc/hostname' # debian
/etc/sysconfig/network # fedora?
/etc/HOSTNAME # suse
# /etc/os-release # nouveau standard systemd/freedesktop
/etc/vconsole.conf
# /etc/locale.conf # voir fi_locale
# /etc/locale.conf # voir fi_locale
'/etc/tmpfiles.d/*.conf'
'/etc/binfmt.d/*.conf'
# /etc/machine-id # voir fi-serial
'/etc/modules-load.d/*.conf' #modules to load at boot time
# /etc/machine-id # voir fi-serial
'/etc/modules-load.d/*.conf' #modules to load at boot time
/etc/machine-info
/etc/modprobe.d/*.conf # blacklist modules
/etc/modprobe.d/*.conf # blacklist modules
'/etc/systemd/system/*/override.conf' # éditions services
)
confs=$( f_grep_file "${toScrut[*]}" "noinexist" )
###
f_pr titre2 "fichiers configuration divers"
f_di cmd "confs" "grep -Ersv '^#|^$' <fichiers désirés>"
f_di cmd "$confs" "grep -Ersv '^#|^$' <fichiers désirés>"
}
fi_cpu(){ # 1/12/2017
@ -733,13 +742,13 @@ fi_cpu(){ # 1/12/2017
[ ${fg_cpu:0:1} -gt 1 ] && pluriel="s" || unset pluriel
###
f_pr titre2 "processeur"$pluriel
f_di cmd "fg_cpu" "lscpu" # affichage proc
f_di var "fg_uarch" "µarchitecture processeur"
f_dspl_alrt "alert_microcode" "info"
f_di cmd "$fg_cpu" "lscpu" # affichage proc
f_di var "$fg_uarch" "µarchitecture processeur"
f_dspl_alrt "$alert_microcode" "info"
f_pr 1 "$fg_ucode" '[[ -z "$alert_microcode" && "$fg_ucode" ]]'
f_pr
f_di var "cpu_flags" "$qte_flags flags cpu" # flags cpu bruts
f_di sans "text_flags" # flags cpu texte
f_di var "$cpu_flags" "$qte_flags flags cpu" # flags cpu bruts
f_di sans "$text_flags" # flags cpu texte
}
fi_disk(){ # 1/12/2017
@ -834,20 +843,20 @@ fi_disk(){ # 1/12/2017
f_pr l "| $fg_disk_ata | $fg_disk_usb | $fg_disk_mmc | $fg_disk_nvme |"
f_pr
# éventuellement hddtemp
f_di cmd "dd_temp" "$cmd_dd_temp" "température disque"$pluriel
f_dspl_alrt "alert_dd_temp" "info"
f_di cmd "$dd_temp" "$cmd_dd_temp" "température disque"$pluriel
f_dspl_alrt "$alert_dd_temp" "info"
# df, espaces des partitions montées seules
f_di cmd "disk_df" "$cmd_dfh" "utilisation disque"$pluriel
f_di cmd "$disk_df" "$cmd_dfh" "utilisation disque"$pluriel
# df -i, inoeuds
f_di cmd "disk_df_i" "$cmd_dfi" "utilisation inoeuds"
f_di cmd "$disk_df_i" "$cmd_dfi" "utilisation inoeuds"
# lsblk répertoire disques & partitions
f_di cmd "disk_lsblk" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" "disque"$pluriel" & partitions"
f_di cmd "$disk_lsblk" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" "disque"$pluriel" & partitions"
# fstab
f_di cmd "fstab" "grep -Ev '^#|^$' /etc/fstab" "fstab"
f_di cmd "$fstab" "grep -Ev '^#|^$' /etc/fstab" "fstab"
# resume
f_di cmd "resume" "grep -Evs '^#|^$' /etc/initramfs-tools/conf.d/resume" "resume"
f_dspl_alrt "alert_file_resume" "info"
f_dspl_alrt "alert_uuidResume" "alert"
f_di cmd "$resume" "grep -Evs '^#|^$' /etc/initramfs-tools/conf.d/resume" "resume"
f_dspl_alrt "$alert_file_resume" "info"
f_dspl_alrt "$alert_uuidResume" "alert"
}
fi_dmesg(){ # 2/12/2017
@ -890,15 +899,15 @@ fi_dmesg(){ # 2/12/2017
rm "$file-"*
###
f_pr titre2 "dmesg kernel (emergency, alerte, erreur, warning ou critique)"
f_di cmd "dmesg_emerg" "dmesg -l emerg" "emergency, $nb_lignes premières lignes"
f_di cmd "dmesg_alert" "dmesg -l alert" "alerte, $nb_lignes premières lignes"
f_di cmd "dmesg_crit" "dmesg -l crit" "critique, $nb_lignes premières lignes"
f_di cmd "dmesg_err" "dmesg -l err" "erreur, $nb_lignes premières lignes"
f_di cmd "dmesg_warn" "dmesg -l warn" "warning, $nb_lignes premières lignes"
f_di cmd "$dmesg_emerg" "dmesg -l emerg" "emergency, $nb_lignes premières lignes"
f_di cmd "$dmesg_alert" "dmesg -l alert" "alerte, $nb_lignes premières lignes"
f_di cmd "$dmesg_crit" "dmesg -l crit" "critique, $nb_lignes premières lignes"
f_di cmd "$dmesg_err" "dmesg -l err" "erreur, $nb_lignes premières lignes"
f_di cmd "$dmesg_warn" "dmesg -l warn" "warning, $nb_lignes premières lignes"
f_pr l "**les $nb_lignes premières lignes commencent à la date la plus ancienne encore dans les logs kernel**"
f_pr flush
f_dspl_alrt "info_ucode" "info"
f_dspl_alrt "alert_firmBug" "alert"
f_dspl_alrt "$info_ucode" "info"
f_dspl_alrt "$alert_firmBug" "alert"
}
fi_efi(){ # 1/12/2017
@ -911,17 +920,18 @@ fi_efi(){ # 1/12/2017
' <<< $( efibootmgr -v 2>/dev/null ) )
###
f_pr titre2 "EFI boot manager"
f_di cmd "efiboot" "efibootmgr -v" "config EFI boot"
f_di cmd "$efiboot" "efibootmgr -v" "config EFI boot"
}
# assigne $fg_gpu (liste des gpu), $fe_nb_gpu, fe_Xorg, si [$1=silent|xorgOnly], sortie après configs xorg complete
fi_gpu(){ # 2/12/2017
fi_gpu(){ # 3/12/2017
local cards cmd_cards prefixCmd openGl pluriel text
local stck_glxinfo glx_dvc cmd_glx_dvc stck_glxinfoOpt stck_glxinfoDri glx_dvc_temp
local cmd_openGl resolutions cmd_resolutions cmt_resolutions providers cmd_providers
local current_preferred cmd_current_preferred cmt_current_preferred
local modGpu cmd_modGpu cmt_modGpu srch_modGpu modVid cmd_modVid cmt_modVid srch_modVid
local alert_hybrid alert_3D alert_Wayland
local toScrut confs ifile fileConfs cmd_confs cmt_confs
# cardsManuel="$(lspci -nnk | grep -EiA 3 'vga|display|3d')" # -nn: textual and numeric ID's, k kernel
# cardsManuel="$(lspci -nnv | grep -iEA10 'vga|display|3d)" # v=verbose
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )"
@ -943,25 +953,26 @@ fi_gpu(){ # 2/12/2017
[ "$1" == "silent" ] && return 0
[ "$fe_nb_gpu" -eq 0 ] && return 0 # pas de gpu, rien à voir
###
# config Xorg
local toScrut confs ifile fileConfs cmd_confs cmt_confs
### ## xorgOnly
toScrut=(
'/etc/X11/xorg.conf '
'/etc/X11/xorg.conf.d/*.conf'
)
[ "$1" == "xorgOnly" ] && toScrut=( "${toScrut[@]}" "/usr/share/X11/xorg.conf.d/*" )
confs=$( f_grep_file "${toScrut[*]}" )
for ifile in ${toScrut[*]}; do
[ -e "$ifile" ] && fileConfs+="$ifile "
done
[ "$fileConfs" ] && fileConfs="Aucun fichier trouvé"
confs=$( f_grep_file "${toScrut[*]}" "" )
cmd_confs="grep -Ersv '^#|^$' $fileConfs"
[ "$fileConfs" ] || cmd_confs="Aucun fichier à afficher"
cmt_confs="configuration Xorg"
info_config="les configurations par défaut de Xorg se trouve dans **/usr/share/X11/xorg.conf.d/**, "
info_config+="non sorties ici pour cause de place."
if [ "$1" == "xorgOnly" ]; then
f_di cmd "confs" "$cmd_confs" "$cmt_confs"
f_di cmd "$confs" "$cmd_confs" "$cmt_confs"
confs=$( f_grep_file "/usr/share/X11/xorg.conf.d/*" )
f_di cmd "$confs" "grep -Ersv '^#|^$' /usr/share/X11/xorg.conf.d/*" "config par défaut Xorg"
fi_log_xorg "notitre"
return 0
fi
###
@ -1061,27 +1072,27 @@ fi_gpu(){ # 2/12/2017
f_pr l "résolution"$pluriel" active"$pluriel": **$fg_resolution**"
f_pr
# lspci -nnv
f_di cmd "cards" "$cmd_cards"
f_dspl_alrt "alert_hybrid" "alert"
f_di cmd "$cards" "$cmd_cards"
f_dspl_alrt "$alert_hybrid" "alert"
# wayland
f_dspl_alrt "alert_Wayland" "info"
f_dspl_alrt "$alert_Wayland" "info"
# openGl
f_di cmd "glx_dvc" "$cmd_glx_dvc" "devices OpenGl"
f_dspl_alrt "alert_3D" "info"
f_di cmd "openGl" "$cmd_openGl" "OpenGl"
f_di cmd "$glx_dvc" "$cmd_glx_dvc" "devices OpenGl"
f_dspl_alrt "$alert_3D" "info"
f_di cmd "$openGl" "$cmd_openGl" "OpenGl"
# liste providers, preferred & current
f_di cmd "current_preferred" "$cmd_current_preferred" "$cmt_current_preferred"
f_di cmd "providers" "$cmd_providers"
f_di cmd "$current_preferred" "$cmd_current_preferred" "$cmt_current_preferred"
f_di cmd "$providers" "$cmd_providers"
# résolutions possibles, pas d'affichage si mode (ssh) ou xrandr pas accessible
f_di cmd "resolutions" "$cmd_resolutions" "$cmt_resolutions"
f_di cmd "$resolutions" "$cmd_resolutions" "$cmt_resolutions"
# modules vidéo
f_di cmd "modGpu" "$cmd_modGpu" "$cmt_modGpu"
f_di var "srch_modGpu" "" "* recherche parmi:"
f_di cmd "modVid" "$cmd_modVid" "$cmt_modVid"
f_di var "srch_modVid" "" "* recherche parmi:"
f_di cmd "$modGpu" "$cmd_modGpu" "$cmt_modGpu"
f_di var "$srch_modGpu" "" "* recherche parmi:"
f_di cmd "$modVid" "$cmd_modVid" "$cmt_modVid"
f_di var "$srch_modVid" "" "* recherche parmi:"
# Xorg config
f_di cmd "confs" "$cmd_confs" "$cmt_confs"
f_dspl_alrt "info_config" "info"
f_di cmd "$confs" "$cmd_confs" "$cmt_confs"
f_dspl_alrt "$info_config" "info"
}
# $1="[opt|dri]", assigne $openGl, sous fonction de fi_gpu
@ -1116,7 +1127,7 @@ fi_hw(){ # 1/12/2017
[ "$fg_hw" ] || figet_hw
###
f_pr titre2 "hardware monitor acpi"
f_di sans "fg_hw" "sans"
f_di sans "$fg_hw" "sans"
f_pr 1 "pas d'informations détectées" '[ -z "$fg_hw" ]'
f_pr flush
}
@ -1197,37 +1208,37 @@ fi_journal(){ # 2/12/2017
f_pr 1 "**journaux persistants**" '[ -z "$alert_jctl_persist" ]'
f_pr 1 "Début des log: **$jctl_boot**"
f_pr
f_dspl_alrt "alert_jctl_persist" "info"
f_dspl_alrt "$alert_jctl_persist" "info"
# journaux kernel
f_di cmd "jctl_alert_k" "journalctl --no-hostname -b0 -k -p1" \
f_di cmd "$jctl_alert_k" "journalctl --no-hostname -b0 -k -p1" \
"**kernel emergency 0 & alerte 1**, $nb_lignes premières lignes"
f_di cmd "jctl_crit_k" "journalctl --no-hostname -b 0 -k -p 2..2" \
f_di cmd "$jctl_crit_k" "journalctl --no-hostname -b 0 -k -p 2..2" \
"**kernel critique**, $nb_lignes premières lignes"
f_di cmd "jctl_err_k" "journalctl --no-hostname -b0 -k -p 3..3" \
f_di cmd "$jctl_err_k" "journalctl --no-hostname -b0 -k -p 3..3" \
"**kernel erreur**, $nb_lignes premières lignes)"
f_di cmd "jctl_warn_k" "journalctl --no-hostname -b0 -k -p 4..4" \
f_di cmd "$jctl_warn_k" "journalctl --no-hostname -b0 -k -p 4..4" \
"**kernel warning**, $nb_lignes premières lignes"
# journaux hors kernel
f_pr titre2 "journalctl hors kernel (emergency, alert, erreur, warning ou critique)"
f_pr 1 "Début des log: **$jctl_boot**"
f_pr
f_di cmd "jctl_alert_nok" "journalctl --no-hostname -b0 -p 1 | grep -v kernel" \
f_di cmd "$jctl_alert_nok" "journalctl --no-hostname -b0 -p 1 | grep -v kernel" \
"**hors kernel, emergency 0 & alerte 1**, $nb_lignes premières lignes"
f_di cmd "jctl_crit_nok" "journalctl --no-hostname -b0 -p 2..2 | grep -v kernel" \
f_di cmd "$jctl_crit_nok" "journalctl --no-hostname -b0 -p 2..2 | grep -v kernel" \
"**hors kernel, critique**, $nb_lignes premières lignes"
f_di cmd "jctl_err_nok" "journalctl --no-hostname -b0 -p 3..3 | grep -v kernel" \
f_di cmd "$jctl_err_nok" "journalctl --no-hostname -b0 -p 3..3 | grep -v kernel" \
"**hors kernel, erreur**, $nb_lignes premières lignes"
f_di cmd "jctl_warn_nok" "journalctl --no-hostname -b0 -p 4..4 | grep -v kernel" \
f_di cmd "$jctl_warn_nok" "journalctl --no-hostname -b0 -p 4..4 | grep -v kernel" \
"**hors kernel, warning**, $nb_lignes premières lignes"
#informations
f_pr 1 "les $nb_lignes premières lignes commencent à la date du dernier boot"
f_pr
f_di cmd "jctl_size" "journalctl --disk-usage " "taille des journaux"
f_di cmd "$jctl_size" "journalctl --disk-usage " "taille des journaux"
# dernières lignes
f_di cmd "jctl_last" "journalctl --no-pager --no-hostname -b0 -p 4 -n25" \
f_di cmd "$jctl_last" "journalctl --no-pager --no-hostname -b0 -p 4 -n25" \
"**toutes provenance, emergency-warning**, $nb_lignes lignes les plus **récentes**"
f_dspl_alrt "alert_firmBug" "alert"
f_dspl_alrt "info_ucode" "info"
f_dspl_alrt "$alert_firmBug" "alert"
f_dspl_alrt "$info_ucode" "info"
}
fi_locale(){ # 1/12/2017
@ -1265,19 +1276,20 @@ fi_locale(){ # 1/12/2017
###
f_pr titre2 "localisation"
# locale
f_di cmd "locale" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
f_di cmd "localectl" "localectl --no-pager status"
f_di cmd "$locale" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
f_di cmd "$localectl" "localectl --no-pager status"
# timezone
f_di cmd "timezone" "grep -EHsv '#|^$' /etc/timezone*"
f_di cmd "timedatectl" "timedatectl status --no-pager"
f_dspl_alrt "alert_ntp" "info"
f_dspl_alrt "alert_rtc" "alert"
f_di cmd "$timezone" "grep -EHsv '#|^$' /etc/timezone*"
f_di cmd "$timedatectl" "timedatectl status --no-pager"
f_dspl_alrt "$alert_ntp" "info"
f_dspl_alrt "$alert_rtc" "alert"
# keyboard layout
f_di cmd "keyboard" "grep -EHv '#|^$' /etc/default/keyboard*"
f_di cmd "xKeyboardMap" "setxkbmap -query"
f_di cmd "$keyboard" "grep -EHv '#|^$' /etc/default/keyboard*"
f_di cmd "$xKeyboardMap" "setxkbmap -query"
}
fi_log_xorg(){ # 2/12/2017
# [$1=notitre]
fi_log_xorg(){ # 3/12/2017
local toScrut xfile xfileTest="" logXorg cmd_logXorg="" cmt_logXorg extract dateFile text nb_lignes=50
local info_logs
@ -1319,9 +1331,9 @@ fi_log_xorg(){ # 2/12/2017
cmd_logXorg="grep -Es '\(WW\)|\(EE\)|\(\?\?\)' $cmd_logXorg"
cmt_logXorg="Xorg.log"
###
f_pr titre2 "journaux Xorg"
f_di cmd "logXorg" "$cmd_logXorg" "$cmt_logXorg"
f_dspl_alrt "info_logs" "info"
f_pr titre2 "journaux Xorg" '[ "$1" != "notitre" ]'
f_di cmd "$logXorg" "$cmd_logXorg" "$cmt_logXorg"
f_dspl_alrt "$info_logs" "info"
}
fi_mem(){ # 1/12/2017
@ -1334,8 +1346,8 @@ fi_mem(){ # 1/12/2017
swappiness=$( cat /proc/sys/vm/swappiness 2>/dev/null )
###
f_pr titre2 "mémoire"
f_di cmd "memoire" "cmd" "free -h"
f_di cmd "swappiness" "cmd" "cat /proc/sys/vm/swappiness"
f_di cmd "$memoire" "cmd" "free -h"
f_di cmd "$swappiness" "cmd" "cat /proc/sys/vm/swappiness"
}
# [$1=silent], assigne fe_nb_reseau, fe_cards_reseau
@ -1382,13 +1394,13 @@ fi_net(){ # 1/12/2017 ( matériel )
f_pr l "$(sed -E 's/(.*)/**\1**/' <<< $fe_cards_reseau)" '' # mise en gras
f_pr
# lspci -nnv
f_di cmd "cards" "$cmd_cards"
f_di cmd "$cards" "$cmd_cards"
# modules réseau
f_di cmd "modWln" "$cmd_modWln" "$cmt_modWln"
f_di var "srch_modWln" "" "* recherche parmi:"
f_di cmd "modEth" "$cmd_modEth" "$cmt_modEth"
f_di var "srch_modEth" "" "* recherche parmi:"
f_dspl_alrt "alert_wlx" "alert"
f_di cmd "$modWln" "$cmd_modWln" "$cmt_modWln"
f_di var "$srch_modWln" "" "* recherche parmi:"
f_di cmd "$modEth" "$cmd_modEth" "$cmt_modEth"
f_di var "$srch_modEth" "" "* recherche parmi:"
f_dspl_alrt "$alert_wlx" "alert"
}
fi_nm(){ # 1/12/2017
@ -1409,9 +1421,9 @@ fi_nm(){ # 1/12/2017
nm_connected=$( LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | gawk '/yes[[:space:]]+\*/ {print $1}' )
###
f_pr titre2 "NetworkManager"
f_di cmd "nm_etat" "cmd" "$cmd_nm_etat" "$cmt_nm_etat"
f_di cmd "nm_conf" "cmd" "$cmd_nm_conf" "$cmt_nm_conf"
f_di cmd "nm_wifis" "cmd" "$cmd_nm_wifis" "$cmt_nm_wifis"
f_di cmd "$nm_etat" "cmd" "$cmd_nm_etat" "$cmt_nm_etat"
f_di cmd "$nm_conf" "cmd" "$cmd_nm_conf" "$cmt_nm_conf"
f_di cmd "$nm_wifis" "cmd" "$cmd_nm_wifis" "$cmt_nm_wifis"
}
fi_packagers(){ #v2 23/11/2017
@ -1475,13 +1487,7 @@ fi_pkg_apt(){ #v3 1/12/2017
local alert_https alert_httpsPossible alert_non_list alert_httpredir alert_upgrade alert_full_upgrade
local alert_apt alert_remove alert_autoclean alert_clean alert_non_ii alert_deborphan
# avertissement
info_update="apt update n'a pas été lancé. vérifier que la date de mise à jour ne soit "
info_update+="pas trop ancienne, la précision de cette partie du rapport pourra en être améliorée."
# sources & divers
dateMaj=$( date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z' 2>/dev/null) || \
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
sources=$( f_grep_file "/etc/apt/sources.list /etc/apt/sources.list.d/*.list" 8 )
cmt_sources="dépôts"
cmd_sources="grep -Ersv '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"
@ -1492,6 +1498,51 @@ fi_pkg_apt(){ #v3 1/12/2017
fi
done
fi
# apt prefs
apt_prefs=$( f_grep_file "/etc/apt/preferences.d/*" )
cmt_apt_prefs="préférences apt"
cmd_apt_prefs="grep -Erv '^#|^$' /etc/apt/preferences.d/"
if [ "$1" == "confOnly" ]; then
shopt -s extglob
local apt_confs cmd_apt_confs cmt_apt_confs syslog cmd_syslog cmt_syslog
local apt_history cmd_apt_history cmd_apt_history cmt_apt_history essai
# apt_confs=$( f_grep_file "/etc/apt/apt.conf.d/!(*.save)" "comment//" )
apt_confs=$( f_grep_file "/etc/apt/apt.conf.d/50unattended-upgrades" "comment//" )
cmd_apt_confs="grep -Erv '^#|^//|^$' "
cmt_apt_confs="apt .conf unattended-upgrades"
syslog=$( f__sudo "cat /var/log/syslog | tail -n15" )
cmd_syslog="cat /var/log/syslog | tail -n15"
cmt_syslog="15 derniers logs"
apt_history=$( f__sudo "cat /var/log/apt/history.log | tail -n25" )
cmd_apt_history="cat /var/log/apt/history.log | tail -n25"
cmt_apt_history="25 derniers historiques apt"
f_di cmd "$sources" "$cmd_sources" "$cmt_sources"
f_di cmd "$apt_prefs" "$cmt_apt_prefs" "$cmt_apt_prefs"
f_di cmd "$apt_confs" "$cmd_apt_confs" "$cmt_apt_confs"
f_di cmd "$syslog" "$cmd_syslog" "$cmt_syslog"
# f_di cmd "$apt_history" "$cmd_apt_history" "$cmt_apt_history"
f_di cmd "$( f_grep_file /var/log/unattended-upgrades/* )"
IFS=$'\n'
essai=($(cat /var/log/apt/history.log | grep -B1 -A2 'unattended-upgrade'))
for i in "${!essai[@]}"; do
:
done
# f_di cmd $(echo "${essai[*]}") "$cmt_apt_history"
#echo ${#essai[*]}
#echo ${essai[0]}
#echo ${essai[1]}
#echo ${essai[2]}
#echo ${essai[3]}
IFS="$IFS_INI"
return 0
fi
# avertissement
info_update="apt update n'a pas été lancé. vérifier que la date de mise à jour ne soit "
info_update+="pas trop ancienne, la précision de cette partie du rapport pourra en être améliorée."
# divers
dateMaj=$( date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z' 2>/dev/null) || \
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' )
# https
apt_version=$( apt --version ) # apt 1.4.8 (i386)
apt_version=${apt_version#apt } # 1.4.8 (i386)
@ -1513,10 +1564,6 @@ fi_pkg_apt(){ #v3 1/12/2017
alert_httpredir="ces urls sont obsolètes, préférer http://deb.debian.org/ ou un miroir local: \n\n"
alert_httpredir+="$(grep 'httpredir' <<< "$sources")"
fi
# apt prefs
apt_prefs=$( f_grep_file "/etc/apt/preferences.d/*" )
cmt_apt_prefs="préférences apt"
cmd_apt_prefs="grep -Erv '^#|^$' /etc/apt/preferences.d/"
printf "◇"
# extraction qte ugrade, full-upgrade
stck_upgd=$( LC_ALL=C apt-get upgrade --simulate 2>/dev/null )
@ -1663,31 +1710,31 @@ fi_pkg_apt(){ #v3 1/12/2017
f_pr 1 "dernière mise à jour apt: **$dateMaj**"
f_pr 1 "version apt: **$apt_version**"
f_pr
f_dspl_alrt "info_update" "info"
f_di cmd "sources" "$cmd_sources" "$cmt_sources"
f_dspl_alrt "alert_https" "info"
f_dspl_alrt "alert_httpsPossible" "info"
f_dspl_alrt "alert_non_list" "info"
f_dspl_alrt "alert_httpredir" "info"
f_di cmd "apt_prefs" "$cmd_apt_prefs" "$cmt_apt_prefs"
f_di cmd:vide "upgrade" "$cmd_upgrade" "$cmt_upgrade"
f_dspl_alrt "alert_upgrade" "info"
f_dspl_alrt "alert_apt" "alerte"
f_di var "notUpgraded" "" "$cmt_notUpgraded"
f_dspl_alrt "alert_full_upgrade" "info"
f_di cmd:vide "toRemove" "$cmd_toRemove" "$cmt_toRemove"
f_dspl_alrt "alert_remove" "info"
f_di cmd:vide "autoclean" "$cmd_autoclean" "$cmt_autoclean"
f_dspl_alrt "alert_autoclean" "info"
f_di cmd "clean" "$cmd_clean" "$cmt_clean"
f_dspl_alrt "alert_clean" "info"
f_di cmd:vide "non_ii" "$cmd_non_ii" "$cmt_non_ii"
f_dspl_alrt "alert_non_ii" "info"
f_dspl_alrt "$info_update" "info"
f_di cmd "$sources" "$cmd_sources" "$cmt_sources"
f_dspl_alrt "$alert_https" "info"
f_dspl_alrt "$alert_httpsPossible" "info"
f_dspl_alrt "$alert_non_list" "info"
f_dspl_alrt "$alert_httpredir" "info"
f_di cmd "$apt_prefs" "$cmd_apt_prefs" "$cmt_apt_prefs"
f_di cmd:vide "$upgrade" "$cmd_upgrade" "$cmt_upgrade"
f_dspl_alrt "$alert_upgrade" "info"
f_dspl_alrt "$alert_apt" "alerte"
f_di var "$notUpgraded" "" "$cmt_notUpgraded"
f_dspl_alrt "$alert_full_upgrade" "info"
f_di cmd:vide "$toRemove" "$cmd_toRemove" "$cmt_toRemove"
f_dspl_alrt "$alert_remove" "info"
f_di cmd:vide "$autoclean" "$cmd_autoclean" "$cmt_autoclean"
f_dspl_alrt "$alert_autoclean" "info"
f_di cmd "$clean" "$cmd_clean" "$cmt_clean"
f_dspl_alrt "$alert_clean" "info"
f_di cmd:vide "$non_ii" "$cmd_non_ii" "$cmt_non_ii"
f_dspl_alrt "$alert_non_ii" "info"
if [ $( f__which deborphan ) ]; then
f_di cmd "deborphan" "$cmd_deborphan" "$cmt_deborphan"
f_dspl_alrt "alert_deborphan" "info"
f_di cmd "$deborphan" "$cmd_deborphan" "$cmt_deborphan"
f_dspl_alrt "$alert_deborphan" "info"
fi
f_di cmd:vide "holded" "$cmd_holded" "$cmt_holded"
f_di cmd:vide "$holded" "$cmd_holded" "$cmt_holded"
}
fi_pkg_x(){ #v2 1/12/2017
@ -1769,10 +1816,10 @@ fi_pkg_x(){ #v2 1/12/2017
[[ ${1#*:} == "Inconnue" ]] && unset nb_packages # totalement inconnu
###
f_pr titre2 "gestion de paquets ${1#*:}"
f_di cmd:text "nb_packages" "$cmd_nbPackages" "nombre de paquets installés"
f_di cmd "sources" "$cmd_sources" "sources"
f_di cmd "holded" "$cmd_holded" "paquets figés"
f_di var "alert_pkg_todo" "aide souhaitée"
f_di cmd:text "$nb_packages" "$cmd_nbPackages" "nombre de paquets installés"
f_di cmd "$sources" "$cmd_sources" "sources"
f_di cmd "$holded" "$cmd_holded" "paquets figés"
f_di var "$alert_pkg_todo" "aide souhaitée"
}
fi_reseau(){ # 1/12/2017 ( configuration )
@ -1814,26 +1861,26 @@ fi_reseau(){ # 1/12/2017 ( configuration )
f_pr titre2 "configuration"
# ip locales avec type
[ $(f__wcv "-l" "$fg_ip_tp") -gt 1 ] && pluriel="s" || unset pluriel
f_di sans "fg_ip_tp" "" "IP locale"$plurielD
f_di sans "$fg_ip_tp" "" "IP locale"$plurielD
f_pr 1 "les adresses Mac peuvent être affichées avec \`$DIRNAME""getInfo --mac\`"
f_pr 1 "l'IP publique peut être connue avec: \`$DIRNAME""getInfo --ip\`"
f_pr
# gateways
[ $(f__wcv "-l" "$fg_gws") -gt 1 ] && pluriel="s" || unset pluriel
f_di sans "fg_gws" "" "Passerelle"$pluriel
f_di sans "$fg_gws" "" "Passerelle"$pluriel
# interface se sortie
if [ $(wc -w <<< $fg_ifn) -gt 1 ]; then
f_di sans "fg_ifn_prior" "" "interface de sortie"
f_di sans "$fg_ifn_prior" "" "interface de sortie"
fi
# ip a & route & interface & resolv
f_di cmd "ip_a" "ip address" "sans ipV6 et sans adresses MAC"
f_di cmd "route" "ip route show"
f_di cmd "interfaces" "grep -EHrsv '#|^$' /etc/network/interfaces*" "configuration manuelle"
f_di cmd "resolv" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés"
f_di cmd "$ip_a" "ip address" "sans ipV6 et sans adresses MAC"
f_di cmd "$route" "ip route show"
f_di cmd "$interfaces" "grep -EHrsv '#|^$' /etc/network/interfaces*" "configuration manuelle"
f_di cmd "$resolv" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés"
# iwconfig & iwlist
f_di cmd "iwconfig" "iwconfig" "état carte wifi"
f_di cmd "$iwconfig" "iwconfig" "état carte wifi"
if [ "$canal_wifi" ]; then
f_di cmd "canal_wifi" "iwlist chan | grep 'Current Frequency' | grep -Eio 'channel [0-9]+'" \
f_di cmd "$canal_wifi" "iwlist chan | grep 'Current Frequency' | grep -Eio 'channel [0-9]+'" \
"canal wifi utilisé"
f_pr 1 "la configuration ssid utilisée peut être connue (si NetworkManager) avec \n \`$DIRNAME""getInfo --ssid\`"
f_pr
@ -1847,7 +1894,7 @@ fi_reseau(){ # 1/12/2017 ( configuration )
else
f_pr 2 "non trouvé parmi: ${netmgrnames[@]}"
fi
f_dspl_alrt "alert_ifconfig" "info"
f_dspl_alrt "$alert_ifconfig" "info"
f_pr flush
}
@ -1886,7 +1933,7 @@ fi_ssid(){ #v2 1/12/2017
###
f__info "$RED""Attention:$BLUE la clé du réseau wifi est visible"
f_pr titre1 "configuration(s) ssid networkmanager"
f_di cmd "nm_ssid" "grep -Ersv '#|^$' /etc/NetworkManager/system-connections/*"
f_di cmd "$nm_ssid" "grep -Ersv '#|^$' /etc/NetworkManager/system-connections/*"
f_pr flush
f_dspl_md "$fileOutput" "marge"
rm "$fileOutput"
@ -2081,13 +2128,13 @@ fi_system_analyse(){ #v 2/12/2017
###
f_pr titre2 "analyse boot systemd"
f_pr 1 "pas de service en erreur" '[ -z "$srvcFail" ]'
f_di cmd "bootTime" "$cmd_bootTime" "$cmt_bootTime"
f_di cmd "srvcFail" "$cmd_srvcFail" "$cmt_srvcFail"
f_dspl_alrt "info_services" "info"
f_dspl_alrt "alert_srvcFail" "alert"
f_di cmd "bootBlame" "$cmd_bootBlame" "$cmt_bootBlame"
f_di cmd "bootCritic" "$cmd_bootCritic" "$cmt_bootCritic"
f_di cmd:text "bootGraph" "$cmd_bootGraph" "$cmt_bootGraph"
f_di cmd "$bootTime" "$cmd_bootTime" "$cmt_bootTime"
f_di cmd "$srvcFail" "$cmd_srvcFail" "$cmt_srvcFail"
f_dspl_alrt "$info_services" "info"
f_dspl_alrt "$alert_srvcFail" "alert"
f_di cmd "$bootBlame" "$cmd_bootBlame" "$cmt_bootBlame"
f_di cmd "$bootCritic" "$cmd_bootCritic" "$cmt_bootCritic"
f_di cmd:text "$bootGraph" "$cmd_bootGraph" "$cmt_bootGraph"
}
fi_usb(){ # 1/12/2017
@ -2098,8 +2145,8 @@ fi_usb(){ # 1/12/2017
[ "$lsusb" ] || return 0
###
f_pr titre2 "USB"
f_di cmd "lsusb" "lsusb"
f_di cmd "lsusb_t" "lsusb -t"
f_di cmd "$lsusb" "lsusb"
f_di cmd "$lsusb_t" "lsusb -t"
}
fi_vrms(){ # 1/12/2017
@ -2124,7 +2171,7 @@ fi_vrms(){ # 1/12/2017
fi
###
f_pr titre2 "paquets non-libres"
f_di cmd "vrms" "vrms" "détection des paquets non libres par RMS"
f_di cmd "$vrms" "vrms" "détection des paquets non libres par RMS"
f_pr flush
}
@ -3845,7 +3892,6 @@ for k in $options; do
options="$(sed -E 's/-c[a-z]+//' <<< $k | xargs)"
done
[ "$categorie" ] && options+=" -c$categorie"
# actions
for j in $options; do
case $j in
@ -3853,7 +3899,7 @@ for j in $options; do
ORIGIN='test'
prg_1 "$*"
echo -n "•"
fi_gpu
fi_pkg_apt
echo; f_dspl_md "$fileOutput"
exit ;; # test
-c* | all )
@ -3868,6 +3914,11 @@ for j in $options; do
fi_gpu "xorgOnly"
f_dspl_md "$fileOutput"
exit ;; # essai détail, xorgOnly
-dp )
prg_1 "$*"
fi_pkg_apt "confOnly"
f_dspl_md "$fileOutput"
exit ;; # essai util source/apt confOnly
-j )
prg_1 "$*"
prg_2 "a"

3942
scripts/getInfo (copie) Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,10 @@
# changelog getInfo
## 2.53.1 03/12/2017
* fix: fu_user
## 2.53.0 02/12/2017
* révision: fi_dmeg, fi_journal, fu_user, fi_system_analyse, fscript_cronAnacron,