getInfo 2.3.0

This commit is contained in:
kyodev 2017-10-12 21:49:57 +02:00
parent 17178d43ab
commit c59b917cd2
2 changed files with 238 additions and 131 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.2.0
date="11/10/2017"
version=2.3.0
date="12/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -259,7 +259,7 @@ f__wget_test(){ # 08/10/2017
exit 0
}
f_help(){ # 11/10/2017
f_help(){ # 12/10/2017
printf "$BLUE"
cat << 'EOF'
----------------------------------------------------------------------
@ -279,7 +279,8 @@ cat << 'EOF'
--ssid : affiche configurations ssid, infos confidentielles, pas de rapport markdown,
root et NetworkManager requis
--debug-batt : rapport batterie avec affichage BAT?/uevent et rapport markdown
--debug-batt : test batterie avec affichage BAT?/uevent et rapport markdown
--debug-hw : test valeurs hwmon et rapport markdown
--debug-dmi : test valeurs dmi et rapport markdown
--debug-paste : le résultat json du paste sera affiché après export
@ -291,12 +292,12 @@ EOF
echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
}
fi_batt(){ # 10/10/2017
[ "$batt_nb" ] || figet_battery # appel figet_battery si pas déjà fait par fi_systeme
[[ "$batt_nb" == "-1" || "$batt_nb" -gt 0 ]] || return 0
fi_batt(){ # 12/10/2017
[ "$fget_batt_nb" ] || figet_battery # appel figet_battery si pas déjà fait par fi_systeme
[[ "$fget_batt_nb" == "-1" || "$fget_batt_nb" -gt 0 ]] || return 0
text="## batterie(s) \n\n"
text+='```\n'
text+="$batt_detail\n"
text+="$fget_batt\n"
text+='```\n\n'
if [ "$optDebug" == "debugBatt" ]; then
text+='`cat /sys/class/power_supply/BAT?/uevent \n'
@ -329,7 +330,7 @@ fi_cpu(){ # 04/10/2017
}
fi_disk(){ # 11/10/2017
local disk_lsblk disk_df disk_df_i fstab resume idResume idSwap alert_uuidResume text
local disk_lsblk disk_df disk_df_i fstab resume idResume idSwap alert_uuidResume text pluriel
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
disk_df="$(df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
disk_df_i="$(df -i --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
@ -348,6 +349,7 @@ fi_disk(){ # 11/10/2017
alert_uuidResume+="**vérifier la config resume**, l'UUID ne correspond pas à celui du swap. \n"
alert_uuidResume+="vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_, voir supprimer ce fichier"
fi
# [ "$var" -gt 1 ] && pluriel="s" || unset pluriel
###
text="## disque(s) \n\n"
[ "$part_fix_tot" ] || figet_disk # appel figet_disk si pas déjà fait par fi_systeme
@ -439,7 +441,7 @@ fi_dmesg(){ # 10/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_graph(){ # 06/10/2017
fi_graph(){ # 12/10/2017
local slotGraphCards graphCards openGl resolutions logXorg modules text
# graphCards="$(lspci -nnk | grep -iEA 3 'vga|display|3d')"
# graphCards="$(lspci -nnv | grep -iEA 13 '^[0-9]+.*vga|display|3d')"
@ -448,7 +450,7 @@ fi_graph(){ # 06/10/2017
graphCards+="$(lspci -s $ig -nnv)"$'\n'
done
unset ig
graphCards="$(sed 's/\n//' <<< $graphCards)"
graphCards=${graphCards::-1} # suppression dernier $'\n'
[ "$(which glxinfo)" ] && openGl="$(glxinfo | grep 'OpenGL version')"
resolutions="$(xrandr --query | grep '^ *[0-9]' | head -n 10)"
modules="$(lsmod | grep -iE 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')"
@ -482,6 +484,15 @@ fi_graph(){ # 06/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_hw(){ # 12/10/2017
figet_hw
text="## hardware monitor ACPI \n\n"
text+='```\n'
text+="$fget_hw\n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
}
fi_localisation(){ # 11/10/2017
local locale timezone keymap keyboard timedatectl alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
locale="$(grep -Ev '#|^$' /etc/default/locale)"
@ -605,7 +616,7 @@ fi_nonFree(){ # 25/09/2017
echo -e "$text" >> "$fileOutput"
}
fi_reseau(){ # 11/10/2017
fi_reseau(){ # 12/10/2017
local slotNetCards netCards ip_a iwconfig interfaces route resolv text liste_canaux_wifi
# netCards="$(lspci -nnk | grep -iEA 5 'network|ethernet')"
# netCards="$(lspci -nnv | grep -iEA 15 'network|ethernet')"
@ -614,7 +625,7 @@ fi_reseau(){ # 11/10/2017
netCards+="$(lspci -s $in -nnv)"$'\n'
done
unset in
netCards="$(sed 's/\n//' <<< $netCards)"
netCards=${netCards::-1} # suppression dernier $'\n'
ip_a="$(ip a | sed '/link\/ether/d; /valid_lft/d')" # filtre sur adr MAC & bail
# ip_a="$(sed '/inet6.*scope global/d; /inet6.*scope link/d' <<< $ip_a)" # filtre sur inet6 scope global & scope link (fe80::)
ip_a="$(sed '/inet6.*/d' <<< $ip_a)" # filtre sur inet6)
@ -702,19 +713,17 @@ fi_reseau(){ # 11/10/2017
text+="### modules réseau \n\n"
text+="liste non garantie complète \n"
text+='```\n'
text+="$modules_net \n"
text+="$fget_mod_net \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
}
fi_sources(){ # 11/10/2017
if [ -z "(which dpkg)" ]; then
f__info "le système n'est pas basé sur dpkg. les informations correspondantes ne peuvent "
"donc être ""extraites \n"
return 0
fi
local sources dateMaj nb_packages apt autoremove paquetToRemove httpredir upgradable nbUpgradable
local paquetBiz text
fi_sources(){ # 12/10/2017
[ "$(which dpkg)" ] || return 0
local sources dateMaj nb_packages apt text pluriel
local alert_autoremove alert_nbAutoremove alert_paquetToRemove alert_httpredir alert_httpredir_text
local alert_upgradable alert_upgradable_text alert_nbUpgradable
local alert_alert_paquetBiz alert_paquetBiz_text0 alert_paquetBiz_text
printf "."
sources="$(grep -Evrs '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list)"
sources="$(sed 's/:deb/: deb/; s/ / /g' <<< $sources)"
@ -722,14 +731,48 @@ fi_sources(){ # 11/10/2017
nb_packages="$(dpkg -l | grep -c '^ii')"
printf "."
apt="$(LC_ALL=C apt-get autoremove --simulate)"
autoremove="$(grep -c 'Remv' <<< $apt)"
paquetToRemove="$(sed -En 's/Remv (.*)\[[0-9.-]*\]/\1/p' <<< $apt | tr '\n' ' ')"
alert_nbAutoremove="$(grep -c 'Remv' <<< $apt)"
if [ "$alert_nbAutoremove" -ne 0 ]; then
[ "$alert_nbAutoremove" -gt 1 ] && pluriel="s" || unset pluriel
alert_autoremove="**$alert_nbAutoremove paquet$pluriel installé$pluriel inutile$pluriel**, "
alert_autoremove+="vous pouvez utiliser "'`apt autoremove`'
alert_paquetToRemove="$(sed -En 's/Remv (.*)\[[0-9.-]*\]/\1/p' <<< $apt | tr '\n' ' ')"
fi
printf "."
httpredir="$(grep 'httpredir' <<< $sources)"
upgradable="$(LC_ALL=C apt list --upgradable 2>/dev/null | sed '1d')"
[ "$upgradable" ] && nbUpgradable="$(grep -c '.' <<< "$upgradable")"
alert_httpredir="$(grep 'httpredir' <<< $sources)"
if [ "$alert_httpredir" ]; then
alert_httpredir_text="url **httpredir**, ces urls sont obsolètes, préférer "
alert_httpredir_text+="http://deb.debian.org/debian/ ou un miroir local"
fi
alert_upgradable="$(LC_ALL=C apt list --upgradable 2>/dev/null | sed '1d')"
if [ "$alert_upgradable" ]; then
alert_nbUpgradable="$(grep -c '.' <<< "$alert_upgradable")"
alert_upgradable_text="**$alert_nbUpgradable paquets devraient être mis à jour:** \n"
alert_upgradable_text+='`apt list --upgradable`:'
fi
printf "."
paquetBiz="$(dpkg -l | gawk 'FNR>5 && ! /^i/ {print $1, $2, $3}')"
alert_paquetBiz="$(dpkg -l | gawk 'FNR>5 && ! /^i/ {print $1, $2, $3}')"
if [ "$alert_paquetBiz" ]; then
[ "$(grep -c '.' <<< "$alert_paquetBiz")" -gt 1 ] && pluriel="s" || unset pluriel
alert_paquetBiz_text0="$(grep -c '.' <<< "**$alert_paquetBiz") paquet$pluriel dans un état non installé**"
[[ ${alert_paquetBiz,,} =~ ^. ]] && alert_paquetBiz_text="* **Ètat souhaité** "$'\n'
[[ ${alert_paquetBiz,,} =~ ^h ]] && alert_paquetBiz_text+=" * **h**old (à garder) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^i ]] && alert_paquetBiz_text+=" * **i**nstall (à installer) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^p ]] && alert_paquetBiz_text+=" * **p**urge (à purger) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^r ]] && alert_paquetBiz_text+=" * **r**emove (à supprimer) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^u ]] && alert_paquetBiz_text+=" * **u**nknown (inconnu) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.. ]] && alert_paquetBiz_text+="* **Ètat du paquet** "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.c ]] && alert_paquetBiz_text+=" * **c**onfig-files (fichiers de configuration seuls) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.f ]] && alert_paquetBiz_text+=" * hal**F**-configured-configured (semi-configuré) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.h ]] && alert_paquetBiz_text+=" * **H**alf-installed (semi-installé) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.i ]] && alert_paquetBiz_text+=" * **i**nstalled (installé) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.n ]] && alert_paquetBiz_text+=" * **n**ot-installed (non installé) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.t ]] && alert_paquetBiz_text+=" * **t**riggers-pending (en instance déclencheurs) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.u ]] && alert_paquetBiz_text+=" * **u**npacked (décompressé seulement) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^.w ]] && alert_paquetBiz_text+=" * triggers-a**w**aiting (attente déclencheurs) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^..r ]] && alert_paquetBiz_text+="* **Drapeaux d'erreur**\n * (réinstallation requise) "$'\n'
alert_paquetBiz_text=${alert_paquetBiz_text::-1} # suppression dernier $'\n'
fi
###
text="## sources list \n\n"
text+='`'"grep -Evrs '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"'` \n'
@ -738,37 +781,34 @@ fi_sources(){ # 11/10/2017
text+='```\n\n'
text+="nombre de paquets installés: **$nb_packages** \n\n"
text+="dernière mise à jour apt: **$dateMaj** \n\n"
if [ "$autoremove" -ne 0 ] ; then
text+="**$autoremove paquet(s) installé(s) inutile(s)**, vous pouvez utiliser: "'`apt autoremove`'" \n"
text+="paquet(s) concerné(s): \n"
if [ "$alert_autoremove" ] ; then
text+="$alert_autoremove \n"
text+='```\n'
text+="$paquetToRemove \n"
text+="$alert_paquetToRemove \n"
text+='```\n\n'
fi
if [ "$httpredir" ]; then
text+="url **httpredir,** ces urls sont obsolètes, préférer http://deb.debian.org/debian/ ou un miroir local \n"
if [ "$alert_httpredir" ]; then
text+="$alert_httpredir_text \n"
text+='```\n'
text+="$httpredir \n"
text+="$alert_httpredir \n"
text+='```\n\n'
fi
if [ "$upgradable" ]; then
text+="**$nbUpgradable paquets devraient être mis à jour:** \n"
text+='`apt list --upgradable` \n'
if [ "$alert_upgradable" ]; then
text+="$alert_upgradable_text \n"
text+='```\n'
text+="$upgradable \n"
text+="$alert_upgradable \n"
text+='```\n\n'
fi
if [ "$paquetBiz" ]; then
text+="il y a des **paquet(s) dans un état non installé**. ce n'est pas forcément grave, mais ça peut être examiné. \n"
text+="paquet(s) concerné(s): \n"
if [ "$alert_paquetBiz" ]; then
text+="$alert_paquetBiz_text0 \n"
text+='```\n'
text+="$paquetBiz \n"
text+="$alert_paquetBiz \n"
text+='```\n\n'
text+="$alert_paquetBiz_text"' \n\n'
fi
echo -e "$text" >> "$fileOutput"
}
# affiche configurations ssid
fi_ssid(){ # 11/10/2017
[ "$(which nmcli)" ] || f__error "il manque NetworkManager"
local nm_ssid file="/tmp/$$-$RANDOM-fi_ssid" text
@ -839,7 +879,7 @@ fi_systeme(){ # 11/10/2017
figet_shell
figet_wm
text="## système \n\n"
text+="$fget_dmi \n"
text+="$fget_dmi \n\n"
text+="| | | \n"
text+=" --- | --- \n"
text+="CPU | **$fget_cpu** \n"
@ -860,10 +900,10 @@ fi_systeme(){ # 11/10/2017
text+="shell actif: $fget_shell \n"
text+="shells installés: $shells \n"
text+="$part_fix_tot \n"
if [ "$batt_detail" ]; then
[ "$batt_nb" -gt "1" ] && pluriel="(s)"
text+="$batt_nb batterie$pluriel présente$pluriel: \n"
text+="$(sed -En 's/^BAT(.*)$/ BAT\1/p' <<< $batt_detail) \n"
if [ "$fget_batt" ]; then
[ "$fget_batt_nb" -gt "1" ] && pluriel="s" || unset pluriel
text+="$fget_batt_nb batterie$pluriel présente$pluriel: \n"
text+="$(sed -En 's/^BAT(.*)$/ BAT\1/p' <<< $fget_batt) \n"
fi
text+="dernier boot: $lastboot, uptime: $uptime \n"
text+="charge système depuis les 1, 5 et 15 dernières minutes: $charge \n"
@ -888,15 +928,15 @@ fi_usb(){ # 25/09/2017
echo -e "$text" >> "$fileOutput"
}
# informations batterie(s), assigne $batt_nb $batt_detail
figet_battery(){ # 11/10/2017
local batt_alim batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
# informations batterie(s), assigne $fget_batt_nb $fget_batt
figet_battery(){ # 12/10/2017
local batt_alim batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso batt_detail batt_nb
local batt_voltage batt_status batt_sn batt_cycle alert_batterie tempo batt_restant ibat
# batt_nb="$(grep 'Battery' /sys/class/power_supply/*/type | grep -c .)"
batt_nb="$(ls /sys/class/power_supply/ | grep -c 'BAT')"
if [ ! -d /sys/class/power_supply ]; then # anciennes interfaces ou inconnu
[ -d /proc/acpi/battery ] && batt_detail="ancien ACPI non géré"
[ -f /proc/apm ] && batt_detail="batteries APM non gérées"
[ -d /proc/acpi/battery ] && batt_detail="ancienne interface ACPI non gérée (obolète)"
[ -f /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
@ -966,15 +1006,16 @@ figet_battery(){ # 11/10/2017
batt_detail+="$(cat $ibat/technology 2>/dev/null) "
batt_detail+="$batt_capa_design $batt_unit "
batt_detail+="$batt_voltage V "
[ "$batt_batt_sn" ] && batt_detail+="n° série:$batt_sn"$'\n'
[ "$batt_cycle" != "0" ] && batt_detail+="$batt_cycle cycles"$'\n' || batt_detail+=$'\n'
[ "$batt_batt_sn" ] && batt_detail+="n° série:$batt_sn"$' \n'
[ "$batt_cycle" != "0" ] && batt_detail+="$batt_cycle cycles"$' \n' || batt_detail+=$' \n'
[ "$batt_capa_full" ] && batt_detail+="pleine charge effective: $batt_capa_full $batt_unit, "
[ "$batt_capa_design" != "na" ] && batt_detail+="pleine charge théorique: $batt_capa_design $batt_unit => "
[ "$batt_sante" ] && batt_detail+="$batt_sante % (indicateur santé)"$'\n'
[ "$batt_sante" ] && batt_detail+="$batt_sante % (indicateur santé)"$' \n'
[ "$batt_restant" ] && batt_detail+="$batt_restant"$'\n'
[ "$alert_batterie" ] && batt_detail+="alarme batterie: $alert_batterie"$'\n'
[ "$alert_batterie" ] && batt_detail+="alarme batterie: $alert_batterie"$' \n'
done
batt_detail="$(sed 's/\n//' <<< $batt_detail)"
fget_batt=${batt_detail::-1} # suppression dernier $'\n'
fget_batt_nb="$batt_nb"
fi
}
@ -1078,7 +1119,7 @@ figet_disk(){ # 11/10/2017
disk_fix+="$idisk " # "sda sdb sdc"
fi
done
disk_detail=${disk_detail::-1} # suppression dernier \n
disk_detail=${disk_detail::-1} # suppression dernier $'\n'
# séquences partitions fixes, $part_fix, $(printf '/dev/%s ' $part_fix), "sda1 sda2 sda3"
part_fix="$(lsblk -o KNAME,MOUNTPOINT $(printf '/dev/%s ' $disk_fix) 2>/dev/null | grep '/')"
part_fix="$(gawk '{print $1}' <<< $part_fix | tr '\n' ' ')"
@ -1128,7 +1169,7 @@ figet_distro(){ # thanks neofetch, assigne $fget_distro # 09/10/2017
}
# informations DMI, assigne $fget_dmi
figet_dmi(){ # 11/10/2017
figet_dmi(){ # 12/10/2017
local product board bios tempo idmi indic1 indic2
unset indic1 indic2
for idmi in sys_vendor product_name product_version chassis_type; do
@ -1151,25 +1192,24 @@ figet_dmi(){ # 11/10/2017
tempo=$(sed 's/x.xx*//' <<< $tempo | xargs)
bios+="$tempo "
done
fget_dmi=$(printf '%7s: %s' "produit" "$product")$'\n'
[ "$indic1" != "$indic2" ] && fget_dmi+=$(printf '%7s: %s' "board" "$board")$'\n'
fget_dmi+=$(printf '%7s: %s' "bios" "$bios")$'\n'
return 0
for idmi in chassis_vendor chassis_version chassis_type; do
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
tempo=$(sed 's/x.xx*//' <<< $tempo)
[[ "$idmi" == "chassis_type" && "$tempo" == "10" ]] && tempo="Notebook"
chassis+="$tempo "
done
fget_dmi=$(printf '%7s: %s' "produit" "$product")$' \n'
[ "$indic1" != "$indic2" ] && fget_dmi+=$(printf '%7s: %s' "board" "$board")$' \n'
fget_dmi+=$(printf '%7s: %s' "bios" "$bios")
# for idmi in chassis_vendor chassis_version chassis_type; do
# tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
# tempo=$(sed 's/x.xx*//' <<< $tempo)
# [[ "$idmi" == "chassis_type" && "$tempo" == "10" ]] && tempo="Notebook"
# chassis+="$tempo "
# done
}
figet_dmi_test(){ # 11/10/2017
# for i in $(ls /sys/class/dmi/id/); do printf "$i: "; cat /sys/class/dmi/id/$i; done
figet_dmi_test(){ # 12/10/2017
#manuel: for i in $(ls /sys/class/dmi/id/); do printf "$i: "; cat /sys/class/dmi/id/$i; done
local idmi text
text="## dmi test \n\n"
text+='```\n'
for idmi in $(ls /sys/class/dmi/id/); do
[[ "$idmi" == "modalias" || "$idmi" == "uevent" ]] && continue
# [[ "$idmi" == "modalias" || "$idmi" == "uevent" ]] && continue
[ -d "/sys/class/dmi/id/$idmi" ] && continue
if [ -r "/sys/class/dmi/id/$idmi" ]; then
text+="$idmi: $(cat /sys/class/dmi/id/$idmi) \n"
@ -1205,9 +1245,67 @@ figet_gpu(){ # thanks neofetch, assigne $fget_gpu # 09/10/2017
fget_gpu="$gpu"
}
# acpi via kernel, hardware monitor, assigne $fget_hw_nb $fget_hw
figet_hw(){ # 12/10/2017
local ihw ihwx text core fan autre nbf nbc input crit
fget_hw_nb=$(grep -c . <<< $(ls /sys/class/hwmon/ 2>/dev/null)) # nb de ressources gérées via acpi/kernel
if [ "$fget_hw_nb" -eq 0 ]; then
fget_hw="gestion ACPI non acessible"
return 1
fi
unset fan core autre
nbf=0
nbc=0
for ihw in $(ls /sys/class/hwmon/); do
if grep -Eq 'fan[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
nbf=$(( nbf+1 ))
fan+="fan$nbf $(cat /sys/class/hwmon/$ihw/fan*_input)t/mn"
elif grep -Eq 'temp[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
if grep -q 'core' <<< $(cat /sys/class/hwmon/$ihw/name) ; then
nbc=$(( nbc+1 ))
input=$(awk '{print $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_input))
crit=$(awk '{print $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit))
core+="core$nbc $(printf "%.1f" $input)°C (crit: $(printf "%.1f" $crit)°C)"
else
input=$(awk '{print $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_input))
crit=$(awk '{print $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit))
autre+="$(cat /sys/class/hwmon/$ihw/name) $(printf "%.1f" $input)°C (crit: $(printf "%.1f" $crit)°C)"
fi
fi
done
fget_hw="$core"$' \n'
fget_hw+="$autre"$' \n'
fget_hw+="$fan"
}
figet_hw_test(){ # 12/10/2017
local ihw ihwx text
text="## hwmon test \n\n"
text+='```\n'
for ihw in $(ls /sys/class/hwmon/); do
text+="$ihw \n"
for ihwx in $(ls /sys/class/hwmon/$ihw/); do
[ -d "/sys/class/hwmon/$ihw/$ihwx" ] && continue
if [ -r "/sys/class/hwmon/$ihw/$ihwx" ]; then
if [ "$(cat /sys/class/hwmon/$ihw/$ihwx)" ]; then
text+="$ihwx: $(cat /sys/class/hwmon/$ihw/$ihwx) \n"
else
text+="$ihwx: -vide- \n"
fi
else
text+="$ihwx: - \n"
fi
done
text+=" \n"
done
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
}
# assigne $ip_local, $gateways, $gateways_type, $gateway, $gateway_type, $if_prioritaire
# $ip_local, $ip_local_type, $ifnames, $ifnames_type, $mac_address, mac_address_type
figet_ip(){ # 09/10/2017
figet_ip(){ # 12/10/2017
local ifn
[ -z "$(which ip)" ] && return 1
# ip_local="$(sed '/lo.*inet/d; /inet6.*scope global/d' <<< "$(ip -o a)" | gawk '{print " ",$4,"(",$2,")"}')"
@ -1227,8 +1325,8 @@ figet_ip(){ # 09/10/2017
ifnames_type+="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $ifnames)"
mac_address="$(sed '/^$/d' <<< $mac_address)" # suppression \n final
mac_address_type="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $mac_address)"
ifnames="$(sed 's/\n//' <<< $ifnames)"
mac_address="$(sed 's/\n//' <<< $mac_address)"
ifnames=${ifnames::-1} # suppression dernier $'\n'
mac_address=${mac_address::-1} # suppression dernier $'\n'
}
# $1=4|6, assigne $ip_public
@ -1324,7 +1422,7 @@ figet_ip_public(){ # 02/10/2017
}
# $1=mem&|swap&|total&|notitle&|nocoltitle, assigne $fget_mem ($2=debug)
figet_mem(){ # 05/10/2017
figet_mem(){ # 12/10/2017
local freeDebug MemTotal MemFree MemAvailable Buffers Cached SReclaimable Shmem MemUsed
local SwapTotal SwapFree SwapCached col
[ "$2" == "debug" ] && freeDebug="$(free -hw | sed '3d')"
@ -1381,18 +1479,18 @@ figet_mem(){ # 05/10/2017
local espace=$(printf '% 6s')
fget_mem="$espace""mém.: totale utilisée libre shared buffers cache disponible"$'\n'
fget_mem+="$espace""ram :$MemTotal$MemUsed$MemFree$Shmem$Buffers$Cached$MemAvailable"$'\n'
fget_mem="$(sed 's/\n//' <<< $fget_mem)"
fget_mem=${fget_mem::-1} # suppression dernier $'\n'
echo "$fget_mem"
echo "$freeDebug"
fi
fget_mem="$(sed 's/\n//' <<< $fget_mem)"
fget_mem=${fget_mem::-1} # suppression dernier $'\n'
}
figet_mod_net(){ # thanks wireless-info, assigne $modules_net # 01/10/2017
figet_mod_net(){ # thanks wireless-info, assigne $fget_mod_net # 01/10/2017
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)"
modules_net="$(lsmod | grep -E "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")"
fget_mod_net="$(lsmod | grep -E "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")"
}
figet_resolution(){ # thanks neofetch, assigne $fget_resolution # 09/10/2017
@ -1458,7 +1556,7 @@ fipaste_curl_pastery(){ # $1 fichier à exporter, $2 durée de conservation en j
# curl -X POST "https://www.pastery.net/api/paste/?title=getInfo&language=markdown" -F file=@$1
curl="$(curl --silent -X POST "https://www.pastery.net/api/paste/?title=getInfo_$version&language=markdown&duration=$(($2*1440))" --data-binary @$1)"
id="$(echo $curl | cut -d '"' -f 4)"
[ "$pasteDuration" -gt 1 ] && pluriel="s"
[ "$pasteDuration" -gt 1 ] && pluriel="s" || unset pluriel
f__info "\n votre paste:$GREEN https://www.pastery.net/$id/" \
"(valide pendant $RED$pasteDuration jour$pluriel)"
[ "$3" == "debugPaste" ] && echo -e "\n$curl\n"
@ -1619,7 +1717,7 @@ prg_2(){ # traitements principaux
printf " ."
if [[ "$1" == all || "$1" =~ s ]]; then #systeme, matériel -cs
echo -e "# Système et matériel \n" >> "$fileOutput"
for i in fi_systeme fi_cpu fi_mem fi_graph fi_batt fi_disk fi_usb ; do
for i in fi_systeme fi_cpu fi_mem fi_hw fi_batt fi_graph fi_disk fi_usb ; do
$i
printf "."
done
@ -1749,7 +1847,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1
fi_reseau
fi_disk
prg_3
exit ;; # test seulement
-c* | all )
@ -1781,6 +1879,11 @@ for j in $options; do
figet_dmi_test
prg_3
exit ;; # rapport batterie avec affichage /sys/class/power_supply/BAT?/uevent
--debug-hw )
prg_1
figet_hw_test
prg_3
exit ;; # rapport batterie avec affichage /sys/class/power_supply/BAT?/uevent
--dmesg )
prg_1
fi_log_xorg

View File

@ -4,55 +4,60 @@
## todo
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
* option erreur pour f__info?
* revoir figet_ip, gateway
* éviter 169.254.10.12/16 ( enp3s0 ) (ethernet) si non branché
* disk: comptage, pluriel, renommage variables publiques
---
## 2.3.0 12/10/2017
* nouveau: figet_hw, figet_hw_test
* révision fi_sources: explications état paquet non ii, _alertifié_
* révision suppression fin de ligne $'\n'
* révision figet_battery, figet_mod_net: renommage variables publiques
## 2.2.0 11/10/2017
* nouveau: figet_dmi, figet_dmi_test
* figet_disk, fi_disk: révision, présentation, espace disk dans détails, alert resume
* figet_battery: erreur anciennes batteries APM ou interface ACPI
* nouveau: figet_dmi, figet_dmi_test
* fix f__sudo : fonctionnement avec sudo
* fix: f__sudo : fonctionnement avec sudo
## 2.1.0 10/10/2017
* fi_ssid: géré via f__sudo (oubli)
* fi_systeme: charge système
* nouveau: fi_ssid: géré via f__sudo (oubli)
* nouveau: fi_systeme: charge système
* nouveau: alarm batterie éventuelle
* figet_cpu: révision présentation et $fget_core
* option --dmesg au lieu de -d + log xorg
* révision help
* alarm batterie éventuelle
* fix fi_batt: pas d'affichage si pas de batterie
* fix: fi_batt: pas d'affichage si pas de batterie
## 2.0.0 09/10/2017
* nouveau: 4 catégories de rapport possible, avec menu éventuel pour choix catégorie
* nouveau: f__sudo, dmesg pour user, avec gestion su ou sudo
* nouveau: intégration f__sudo dans install & remove script
* révision option debug
* simplification syntaxe options
* fileOutput géré par chmod
* 4 catégories de rapport possible, avec menu éventuel pour choix catégorie
* log xorg passés en catégorie analyse
* f__sudo, dmesg pour user, avec gestion su ou sudo
* f__user, premier essai root only, fonctionnement en root only en console
* révision f__color: utilisation terminfo pour retour au std (et non noir), donc modifs:
* f__color f__error f__info f__wget_test f__dialog_oui_non
* fscript_get_version fscript_install fscript_remove fscript_update
* intégration f__sudo dans install & remove script
* force gawk pour éviter incompatibilités
* début révision réseau
## 1.35.0 05/10/2017
* fi_disk: inoeuds
* nouveau: fi_disk: inoeuds
* figet_mem: révision & meilleure précision
## 1.34.1 04/10/2017
* nouveau: figet_mem
* suppression figet_memory neofetch
* nouveau figet_mem
* révision fi_mem, affichage mémoire expurgé comparé à free
* révision fi_mem, affichage mémoire expurgé comparé à `free`
* révision nommage variables fonctions neofetch
* test une seule fois frama.link
@ -64,7 +69,7 @@
## 1.32.2 02/10/2017
* révision sed s/
* fi_systeme: boot image avec options
* révision fi_systeme: boot image avec options
* révision fi_disk
* révision nommage variables fonctions neofetch
* variables de boucles en local
@ -73,35 +78,35 @@
## 1.31.0 01/10/2017
* figet_disk: meilleure détection vendor/model quand vide sur lsblk
* révision figet_disk: meilleure détection vendor/model quand vide sur lsblk
* révision fi_gpu, fi_reseau
* divers révision et mise en forme
## 1.30.0 30/09/2017
* révision fi_systeme, figet_ip, figet_disk, fi_reseau, fi_gpu, figet_battery
* fix mineur figet_cpu, fi_sources: comptage ligne avec grep si 0 ligne
* fi_sources plus de critère d'architecture dans les paquetsBiz
* révision fi_sources plus de critère d'architecture dans les paquetsBiz
* fix: figet_cpu, fi_sources: comptage ligne avec grep si 0 ligne
## 1.29.0 29/09/2017
* f__wget_test: correction code retour lors "test"
* nouveau: figet_battery: voltage, conso si 0
* fi_sources:
* révision
* nb de packages installés
* mieux date dernier apt update
* figet_cpu, remplacement wc -l par grep -c
* plus de dépendances wc
* figet_battery: voltage, conso si 0
* fi_disk, correction si pas de fichier resume (absence normale?)
* fi_disk, correction si pas de fichier resume
* fix: f__wget_test: correction code retour lors "test"
## 1.28.0 28/09/2017
* nouveau: figet_battery
* suppression figet_battery neofetch
* nouveau figet_battery
* fix mineur figet_disk
* retour en f_user "général"
* f__wget_test, nouveau nommage fichier temp
* révision f__wget_test, nouveau nommage fichier temp
* fix: figet_disk
## 1.27.0 27/09/2017
@ -110,8 +115,8 @@
## 1.26.0 26/09/2017
* figet_disk: suppression neofetch
* figet_disk: nouveau avec nouvelles infos et espace disque des partitions montées seulement
* nouveau: figet_disk avec nouvelles infos et espace disque des partitions montées seulement
* suppression figet_disk neofetch
* révision partitions/disques, fi_disk
* test bash4 au démarrage
* requis curl uniquement pour paste
@ -120,28 +125,27 @@
* f__wget_test(): nouvelle option test
* liens raccourcis frama.link
* commandes: présentation markdown
* présentation des commandes au format markdown
## 1.24.0 24/09/2017
* nouveau: fi_nonFree
* ménage fi_dmesg, fi_nm_wifis
* nouveau fi_nonFree
## 1.23.0 23/09/2017
* f__requis, f__info, f__error unset/for
* révision unset/for
## 1.22.0 22/09/2017
* nouveau: daemon d'initialisation (systemd ou autre)
* système, présentation en table pour meilleure présentation
* daemon d'initialisation (systemd ou autre)
* révision fi_gpu, réduction verbosité (1v au lieu de 3v)(pour éviter erreur en root avec capabilities)
et sélection par slot, présentation
* révision fi_reseau, homogénéité nnv au lieu de nnk et sélection par slot , présentation
* révision fi_sources, présentation et nombres de paquets upgradables
* présentaion rapport, modifs mineures
* présentation et fix bug mineur fi_dmesg
* présentation et fix fi_dmesg
## 1.20.0 18/09/2017
@ -150,7 +154,7 @@
## 1.19.0 16/09/2017
* timedatectl dans localisation et alertes horloge RTC et Ntp
* nouveau: timedatectl dans localisation et alertes horloge RTC et Ntp
* révision mineure fi_disk, variable alert_
## 1.18.0 15/09/2017
@ -160,7 +164,7 @@
## 1.17.0 14/09/2017
fix bug: id resume dans fi_disk
fix: id resume dans fi_disk
## 1.15.0 07/09/2017
@ -174,13 +178,13 @@ fix bug: id resume dans fi_disk
## 1.13.0 04/09/2017
* nouveau: option affichage adresses mac
* nouveau IFS
* révision figet_ip:
* ifnames, toutes les interfaces et pas seulement les connectées
* mac address des interfaces
* révision affichage fi_ssid
* fix bug: export direct après génération rapport
* nouveau: option affichage adresses mac
* fix: export direct après génération rapport
## 1.12.0 03/09/2017
@ -190,7 +194,7 @@ fix bug: id resume dans fi_disk
## 1.10.0 02/09/2017
* fix bug commande parasite sur détection ip
* fix: commande parasite sur détection ip
## 1.9.1 01/09/2017
@ -211,8 +215,8 @@ fix bug: id resume dans fi_disk
## 1.7.0 28/08/2017
* fix bug: localisation fileDev
* révision f__wget_test
* fix: localisation fileDev
## 1.6.0 27/08/2017
@ -221,15 +225,15 @@ fix bug: id resume dans fi_disk
## 1.5.0 27/08/2017
* fix bug upgrade
* fix: upgrade
## 1.4.3 26/08/2017
* maj fscript_install pour éventuel fscript_install_special
* renommage fscript_dl en fscript_update
* révision fscript_install, fscript_update, fscript_get_version
* révision f__wget_test
* révision f__error, f__info
* maj fscript_install pour éventuel fscript_install_special
## 1.3.0 24/08/2017
@ -241,8 +245,8 @@ fix bug: id resume dans fi_disk
## 1.2.0 22/08/2017
* fix bug: f__log manquant
* maj mineure fscript_dl
* fix: f__log manquant
## 1.1.0 21/08/2017
@ -252,8 +256,8 @@ fix bug: id resume dans fi_disk
## 1.0.9 20/08/2017
* fix bug: fscript_cronAnacron appel fscript_cronAnacron_special
* fix $TERM
* fix: fscript_cronAnacron appel fscript_cronAnacron_special
* fix: $TERM
## 1.0.8 19/08/2017
@ -267,19 +271,19 @@ fix bug: id resume dans fi_disk
## 1.0.6 18/08/2017
* maj fscript_cronAnacron lors upgrade et spécial pour dev
* fix affichage ipv6, filtre sur inet6 & scope global & adr MAC
* adresse MAC non affichée
* révision ip locales, système et réseau
* protection absence iproute
* révision test sur which
* vérification requis pour fonctionnement script
* maj fscript_get_version, fscript_dl, fscript_install
* fix publication version test
* fix: publication version test
* fix: affichage ipv6, filtre sur inet6 & scope global & adr MAC
## 1.0.3 17/08/2017
* version publique
* fix bug: fi_systeme
* get_distro(neofetch)
* révision protection variables
* désactivation affichage ipv6 en attente meilleur filtrage
* fix: fi_systeme