getInfo 2.30.1

This commit is contained in:
kyodev 2017-11-11 08:01:41 +01:00
parent 1585ea597e
commit 95209015bd
2 changed files with 49 additions and 28 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.30.0
date="10/11/2017"
version=2.30.1
date="11/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -44,10 +44,10 @@ f__architecture(){ # 08/2017 spécifique
esac
}
# $1=commande à tester, return localisation cmd si existe, return 1 si absent avec aucun message (ala debian)
# $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(){ # 22/10/2017
f__cmd_exist(){ # 11/11/2017
# command -v
if type -p "$1" &>/dev/null ; then
echo $(type -p $1)
@ -368,7 +368,7 @@ f_dspl_alert(){ # 10/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(){ # 10/11/2017
f_dspl_md(){ # 11/11/2017
local display display2 ifs_origin
if [ ! -f "$1" ]; then
f__info "pas de rapport à afficher, vous devez lancer une analyse auparavant:" \
@ -377,7 +377,7 @@ f_dspl_md(){ # 10/11/2017
fi
display=$(< $1)
display=${display//\`\`\`/---} # transforme ``` en ---, plus visibles
# traitement par lignes, ala sed, obligatoire pour les titres #
# 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_origin="$IFS"
IFS="\n"
@ -1218,7 +1218,7 @@ fi_nm(){ # 10/11/2017
unset text
}
fi_reseau(){ # 10/11/2017
fi_reseau(){ # 11/11/2017
local slots cards ip_a iwconfig interfaces route resolv canal_wifi ifx alert_wlx text pluriel
# cardsManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')"
# cardsManuel="$(lspci -nnv | grep -EiA 15 'network|ethernet')"
@ -1251,7 +1251,7 @@ fi_reseau(){ # 10/11/2017
netmgrpaths=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand") # thanks wireless-info
netmgrnames=("NetworkManager" "Wicd" "ConnMan")
for ifx in "${!netmgrpaths[@]}"; do
[ -f "${netmgrpaths[$ifx]}" ] && netmgrinst+=${netmgrnames[$ifx]}
[ -e "${netmgrpaths[$ifx]}" ] && netmgrinst+=${netmgrnames[$ifx]}
if [ "$(ps -ef | grep -c ${netmgrpaths[$ifx]})" -ge 2 ]; then
netmgrrun+="$(ps -ef | grep -o "${netmgrpaths[$ifx]}.*$" | head -n 1)"
fi
@ -1337,7 +1337,7 @@ fi_serial(){ # 06/11/2017
unset text
}
fi_sources(){ #v2 10/11/2017
fi_sources(){ #v2 11/11/2017
[ "$(f__cmd_exist dpkg)" ] || return 0
local sources dateMaj nb_packages upgrade upgrade_qte remove remove_qte non_ii_qte text pluriel
local alert_httpredir alert_upgrade alert_full_upgrade alert_upgrade_titre
@ -1384,11 +1384,11 @@ fi_sources(){ #v2 10/11/2017
printf "‣"
# paquet non ^ii
alert_non_ii="$(LC_ALL=C dpkg -l | gawk 'FNR>5 && ! /^i/ {
printf "%-3s %-20s %-12s",$1,$2,$3; $1=$2=$3=$4=""; printf "%s \n",$0}') \n\n"
printf "%-3s %-20s %-12s",$1,$2,$3; $1=$2=$3=$4=""; printf "%s \n",$0}')"
non_ii_qte=$( f__wcv -l "$alert_non_ii" )
if [ "$non_ii_qte" -gt 0 ]; then
[ "$non_ii_qte" -gt 1 ] && pluriel="s" || unset pluriel
alert_non_ii_titre="$non_ii_qte paquet"$pluriel" dans un état non installé"
alert_non_ii_titre="\n\n$non_ii_qte paquet"$pluriel" dans un état non installé"
[[ ${alert_non_ii,,} =~ ^. ]] && alert_non_ii+=" ‣ État souhaité "$'\n'
[[ ${alert_non_ii,,} =~ ^h ]] && alert_non_ii+=" h.. hold (à garder) "$'\n'
[[ ${alert_non_ii,,} =~ ^i ]] && alert_non_ii+=" i.. install (à installer) "$'\n'
@ -1557,17 +1557,29 @@ fi_usb(){ # 25/10/2017
unset text
}
fi_vrms(){ # 03/11/2017
local vrms text tempo tempo1 tempo2 pluriel
fi_vrms(){ # 11/11/2017
local vrms non_free contrib total text pluriel tempo
[ "$(f__cmd_exist vrms)" ] && vrms="$(vrms)"
###
# tempo1=$(grep -o '.*non-free packages' <<< "$vrms" | xargs)
# tempo2=$(grep -o '.*contrib packages' <<< "$vrms" | xargs)
# tempo=$(( ${tempo1:0:1} + ${tempo2:0:1} ))
# [[ "$tempo1" && "$tempo" -gt 1 ]] && pluriel="s" || unset pluriel
text="## paquets$pluriel non-libres$pluriel \n\n"
if [ "$vrms" ]; then
f_display "vrms" "cmd" "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" )
if [[ "$non_free" && "$contrib" ]]; then
total=$(( $non_free + $contrib ))
[ "$non_free" -gt 1 ] && pluriel="s" || unset pluriel
vrms=$( sed -E "s/Non-free packages installed on.*/$non_free paquets non libre$pluriel installé$pluriel:/" <<< "$vrms" )
[ "$contrib" -gt 1 ] && pluriel="s" || unset pluriel
vrms=$( sed -E "s/Contrib packages installed on.*/$contrib paquets contrib installés:/" <<< "$vrms" )
vrms=$( sed -E '/[0-9]+ non-free packages,/d; /[0-9]+ contrib packages,/d; ' <<< $vrms )
[ "$total" -gt 1 ] && pluriel="s" || unset pluriel
elif grep -iq 'proud' <<< "$vrms" ; then
tempo="Aucun paquet non libre ou contrib installé sur ce système \n\t\t **rms serait fier ☺**"
vrms=$( sed -E "s/.*rms would be proud.*/$tempo/" <<< "$vrms" )
fi
fi
### No non-free or contrib packages installed on xxx! rms would be proud
text="## paquet"$pluriel" non-libre"$pluriel" \n\n"
if [ "$vrms" ]; then
f_display "vrms" "cmd" "vrms" "détection des paquets non libres par Richard M. Stallman"
else
text+="* les paquets non-free ou contrib ne peuvent être détectés sans l'installation de vrms \n"
fi
@ -1576,13 +1588,13 @@ fi_vrms(){ # 03/11/2017
}
# informations batterie(s), assigne $fg_nb_batt $fg_batt $fg_batt_serial
figet_batt(){ #v2 07/11/2017
figet_batt(){ #v2 11/11/2017
local batt_detail batt_nb batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
local batt_volt_min batt_volt_now batt_status batt_cycle alert_batt_alarm
local batt_sante batt_restant tempo batRep ibat uevent
if [ ! -d /sys/class/power_supply ]; then # anciennes interfaces ou inconnu
[ -d /proc/acpi/battery ] && batt_detail="ancienne interface ACPI non gérée (obsolète)"
[ -f /proc/apm ] && batt_detail="anciennes batteries APM non gérées (obolète)"
[ -e /proc/apm ] && batt_detail="anciennes batteries APM non gérées (obolète)"
[ "$batt_detail" ] || batt_detail="répertoire power_supply inaccessible"
batt_nb="-1"
return 1
@ -2437,7 +2449,7 @@ figet_test_gpu(){ # 30/10/2017
f_display "fg_gpu" "var" "fg_gpu"
}
figet_test_hw(){ # 22/10/2017
figet_test_hw(){ # 11/11/2017
local text var_temp
# matériel
figet_dmi
@ -2464,14 +2476,14 @@ figet_test_hw(){ # 22/10/2017
var_temp="/sys/devices/platform/coretemp.0/hwmon/"
f_dspl_scandir "$var_temp" 1
# analyse méthode neofetch
if [ -f "/sys/class/hwmon/hwmon0/temp1_input" ]; then
if [ -e "/sys/class/hwmon/hwmon0/temp1_input" ]; then
var_temp="$(< "/sys/class/hwmon/hwmon0/temp1_input")"
var_temp="$((var_temp * 100 / 10000))" # 33000 x 100 / 10 000 = 330
var_temp="[${var_temp/${var_temp: -1}}.${var_temp: -1}°C]" # formatage 1 point décimal
else
var_temp=" non accessible"
fi
f_display "var_temp" "var" "hwmon0/temp1_input ala neofetch"
f_display "var_temp" "var" "hwmon0/temp1_input à là neofetch"
# fonction script
figet_hw
f_display "fg_hw" "var" "figet_hw"
@ -2761,12 +2773,12 @@ function display_menu {
reply="$(sed 's/-call/all/' <<< $reply)"
exec $0 "$reply"
}
prg_alert_init(){ # 29/10/2017
prg_alert_init(){ # 11/10/2017
bashVersion=($(grep -o 'version 4' <<< $(bash --version)))
[ ${bashVersion[1]} -ge 4 ] || f__error "bash v4 requis" \
"version installée: $(sed -n '1p' <<< $(bash --version))"
[ -f /proc/cpuinfo ] || f__error "/proc/cpuinfo non trouvé" "/proc ne doit pas être monté"
[ -e /proc/cpuinfo ] || f__error "/proc/cpuinfo non trouvé" "/proc ne doit pas être monté"
# test OS
OS=$(uname -s)
@ -2847,7 +2859,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_sources
fi_vrms
exit ;; # test
-c* | all )
[ "$j" == "-c" ] && exec $0 "menu"

View File

@ -4,11 +4,20 @@
* ! f__requis, fscript_install, f__scandir
## 2.30.1 11/11/2017
* 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