getInfo 2.6.0

This commit is contained in:
kyodev 2017-10-14 17:54:16 +02:00
parent e0bed83a14
commit 344c4b82c9
2 changed files with 169 additions and 134 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.5.0
date="13/10/2017"
version=2.6.0
date="14/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -155,13 +155,10 @@ f__requis(){ # 22/09/2017
fi
}
# $1=rep à scanner [$2=profondeur max|4 défaut] [$3=profondeur encours|0 défaut]
f__scandir(){ # 13/10/2017
if [ ! -d "$1" ]; then
echo "manque répertoire à scanner"
exit 1
fi
local rep rc text prof prof_max
# $1=rep à scanner [$2=profondeur max|4 défaut] [$3=profondeur encours|0 défaut] /usr/bin/strings (binutils) requis
f__scandir(){ # 14/10/2017
[ -d "$1" ] || f__error "manque répertoire à scanner"
local rep rc text prof prof_max tempo
[ "$2" ] && prof_max="$2" || prof_max=4
[ "$3" ] && prof=$3 || prof=0
text="répertoire: $1 \n"
@ -171,13 +168,9 @@ f__scandir(){ # 13/10/2017
if [ -d "$1$rep" ]; then
[ "$prof" -gt "$prof_max" ] && continue || f__scandir "$1$rep/" "$prof_max" "$prof"
else
if cat $1$rep &>/dev/null ; then
tempo="$(cat $1$rep)"
[[ "$rep" == "uevent" || "$rep" == "modalias" ]] && rc=" \n" || unset rc
[ "$tempo" ] && text+="$rep: $rc$tempo \n" || text+="$rep: <vide> \n"
else
text+="$rep: na \n"
fi
[[ "$rep" == "uevent" || "$rep" == "modalias" ]] && rc=" \n" || unset rc
tempo="$(strings -aw -n1 $1$rep)" # mini 1 caractères, inclus white space, all fichier
[ "$tempo" ] && text+="$rep: $rc$tempo \n" || text+="$rep: <vide> \n"
fi
prof=$(( prof-1 ))
done
@ -352,7 +345,7 @@ fi_cpu(){ # 04/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_disk(){ # 11/10/2017
fi_disk(){ # 14/10/2017
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')"
@ -372,14 +365,15 @@ 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
text+='```\n'
text+="$part_fix_tot \n" # espaces des partitions montées
text+="$(printf '%-22s: %s' "disque(s) fixe(s)" "$disk_fix") \n" # devices fixes
text+="$(printf '%-22s: %s' "disque(s) amovible(s)" "$disk_hotplug") \n\n" # devices hotplug
[ "$(grep -c . <<< $disk_fix)" -gt 1 ] && pluriel=s || unset pluriel
text+="$(printf '%-18s: %s' "disque$pluriel fixe$pluriel" "$disk_fix") \n" # devices fixes
[ "$(grep -c . <<< $disk_hotplug)" -gt 1 ] && pluriel=s || unset pluriel
text+="$(printf '%-18s: %s' "disque$pluriel amovible$pluriel" "$disk_hotplug") \n\n" # devices hotplug
text+="$disk_detail \n" # caractéristiques des disques trouvés
text+='```\n\n'
text+="**types de disque** \n\n"
@ -952,11 +946,10 @@ fi_usb(){ # 25/09/2017
}
# informations batterie(s), assigne $fget_batt_nb $fget_batt
figet_batt(){ # 13/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')"
figet_batt(){ # 14/10/2017
local batt_detail batt_nb batt_alim batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
local batt_volt_min batt_volt_now batt_status batt_cycle batt_sn alert_batt_alarm
local batt_sante batt_restant tempo batRep ibat uevent pluriel
if [ ! -d /sys/class/power_supply ]; then # anciennes interfaces ou inconnu
[ -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)"
@ -964,82 +957,83 @@ figet_batt(){ # 13/10/2017
batt_nb="-1"
return 1
fi
if [ "$batt_nb" -gt "0" ]; then
# extraction valeur
batt_alim="$(grep . /sys/class/power_supply/AC*/online | sed -n '1p')"
unset batt_detail
for ibat in /sys/class/power_supply/BAT*; do
# extraction pour valeur de calcul ou selon type unité
if [ -e "$ibat/charge_full_design" ]; then
batt_unit=" mAh"
batt_capa_design="$(cat $ibat/charge_full_design 2>/dev/null)"
batt_capa_full="$(cat $ibat/charge_full 2>/dev/null)"
batt_capa_now="$(cat $ibat/charge_now 2>/dev/null)"
batt_conso="$(cat $ibat/current_now 2>/dev/null)"
elif [ -e "$ibat/energy_full_design" ]; then
batt_unit=" mWh"
batt_capa_design="$(cat $ibat/energy_full_design 2>/dev/null)"
batt_capa_full="$(cat $ibat/energy_full 2>/dev/null)"
batt_capa_now="$(cat $ibat/energy_now 2>/dev/null)"
batt_conso="$(cat $ibat/power_now 2>/dev/null)"
else
batt_capa_design="na"
fi
# mise en forme micro en milli
batt_capa_design="${batt_capa_design%000}"
batt_capa_full="${batt_capa_full%000}"
batt_capa_now="${batt_capa_now%000}"
batt_conso="${batt_conso%000}"
# extraction
batt_voltage="$(cat $ibat/voltage_min_design 2>/dev/null)"
batt_status="$(cat $ibat/status 2>/dev/null)"
batt_sn="$(cat $ibat/serial_number 2>/dev/null)"
batt_cycle="$(cat $ibat/cycle_count 2>/dev/null)"
alert_batterie="$(cat $ibat/alarm 2>/dev/null)"
[ "$alert_batterie" == "0" ] && unset alert_batterie
# calculs
if [ "$batt_capa_design" != "na" ] && [ "$batt_capa_full" ]; then
batt_sante="$(gawk '{printf "%.1f", $1/$2*100}' <<< "$batt_capa_full $batt_capa_design")"
fi
if [ "$batt_status" == "Full" ] || [ "$batt_status" == "Unknow" ]; then
batt_restant="totalement chargée"
elif [ "$batt_status" == "Discharging" ]; then # alt: [ "$batt_alim" == "0" ]
batt_restant="en décharge, reste approximativement: "
# tempo="$(echo "scale=2;$batt_capa_now*0.9/$batt_conso" | bc)"
tempo="$(gawk '{print $1*0.9/$2}' <<< "$batt_capa_now $batt_conso")"
batt_restant+="$(gawk '{printf "%d h %02d mn \n", $1, $1*60%60}' <<< $tempo) "
elif [ "$batt_status" == "Charging" ]; then # alt: [ "$batt_alim" == "0" ]
batt_restant="en charge, reste approximativement: "
tempo="$(gawk '{print ($1-$2)/$3}' <<< "$batt_capa_full $batt_capa_now $batt_conso")"
batt_restant+="$(gawk '{printf "%d h %02d mn \n", $1, $1*60%60}' <<< $tempo) "
fi
if [ "$batt_conso" != "0" ]; then
batt_restant+="(consommation en cours: $batt_conso $(sed 's/h//' <<< $batt_unit), "
batt_restant+="charge en cours: $(printf "%'d" $batt_capa_now) $batt_unit)"
fi
# mise en forme pour sortie, séparateur milliers
batt_capa_design="$(printf "%'d" $batt_capa_design)"
batt_capa_full="$(printf "%'d" $batt_capa_full)"
batt_conso="$(printf "%'d" $batt_conso)"
batt_voltage="$(gawk '{printf "%.2f", $1/1000000}' <<< "$batt_voltage")" # µV en V
# sortie
batt_detail+="$(basename $ibat): "
batt_detail+="$(cat $ibat/manufacturer 2>/dev/null) "
batt_detail+="$(cat $ibat/model_name 2>/dev/null) "
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_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_restant" ] && batt_detail+="$batt_restant"$'\n'
[ "$alert_batterie" ] && batt_detail+="alarme batterie: $alert_batterie"$' \n'
done
batt_nb="$(grep -i 'Battery' /sys/class/power_supply/*/type | grep -c .)"
[ -z "$batt_nb" ] && return
batt_alim="$(grep '1' /sys/class/power_supply/AC*/online | grep -c .)" # plusieurs alims? -ge1
batRep="/sys/class/power_supply"
unset batt_detail
for ibat in $(ls $batRep); do
grep -qi 'Battery' "$batRep/$ibat/type" || continue # plus loin si non batterie
uevent=$(grep -s . $batRep/$ibat/uevent || batt_detail="$ibat: **uevent** incorrect")
# extractions valeur de calcul selon type
if grep -q 'POWER_SUPPLY_CHARGE_' <<< $uevent ; then
batt_unit="mAh"
batt_capa_design="$(gawk -F '=' '/POWER_SUPPLY_CHARGE_FULL_DESIGN=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_capa_full="$(gawk -F '=' '/POWER_SUPPLY_CHARGE_FULL=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_CHARGE_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_conso="$(gawk -F '=' '/POWER_SUPPLY_CURRENT_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
elif grep -q 'POWER_SUPPLY_ENERGY_' <<< $uevent ; then
batt_unit="mWh"
batt_capa_design="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL_DESIGN=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_capa_full="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
batt_conso="$(gawk -F '=' '/POWER_SUPPLY_POWER_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
else
batt_capa_design="na"
fi
# extractions simples
batt_volt_min="$(gawk -F '=' '/POWER_SUPPLY_VOLTAGE_MIN_DESIGN=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # V
batt_volt_now="$(gawk -F '=' '/POWER_SUPPLY_VOLTAGE_NOW=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # V
batt_status="$(gawk -F '=' '/POWER_SUPPLY_STATUS=/ {print $2}' <<< $uevent)"
batt_cycle="$(gawk -F '=' '/POWER_SUPPLY_CYCLE_COUNT=/ {print $2}' <<< $uevent)"
batt_sn="$(gawk -F '=' '/POWER_SUPPLY_SERIAL_NUMBER=/ {print $2}' <<< $uevent)"
alert_batt_alarm="$(cat $batRep/$ibat/alarm 2>/dev/null)"
[ "$alert_batt_alarm" == "0" ] && unset alert_batt_alarm || alert_batt_alarm="$ibat: $alert_batt_alarm"
# calculs
batt_sante="$(gawk '$1 != "na" && $2 != "" && $2 != "0" {printf "%.1f", $1/$2*100}' <<< "$batt_capa_full $batt_capa_design")"
if [[ "$batt_status" == "Full" || "$batt_status" == "Unknow" ]]; then
batt_restant="totalement chargée"
elif [ "$batt_status" == "Discharging" ]; then # alt: [ "$batt_alim" == "0" ]
batt_restant="en décharge, reste approximativement: "
tempo="$(gawk '$1+$2 != "" && $2!="0 "{print $1*0.9/$2}' <<< "$batt_capa_now $batt_conso")"
elif [ "$batt_status" == "Charging" ]; then
batt_restant="en charge, reste approximativement: "
tempo="$(gawk '$1+$2+$3 != "" && $3 != "0" {print ($1-$2)/$3}' <<< "$batt_capa_full $batt_capa_now $batt_conso")"
fi
batt_restant+="$(gawk '$1 != "" {printf "%d h %02d mn \n", $1, $1*60%60}' <<< $tempo) "
# mise en forme pour sortie, séparateur milliers
batt_capa_design="$(printf "%'d" $batt_capa_design)"
batt_capa_full="$(printf "%'d" $batt_capa_full)"
batt_conso="$(printf "%'d" $batt_conso)"
# sortie
batt_detail+="$ibat: $(cat $batRep/$ibat/manufacturer 2>/dev/null) "
batt_detail+="$(cat $batRep/$ibat/model_name 2>/dev/null) $(cat $batRep/$ibat/technology 2>/dev/null) "
batt_detail+="$batt_capa_design$batt_unit - $batt_volt_min""V / $batt_volt_now""V (mini/actuel)"
[ "$batt_batt_sn" ] && batt_detail+="n° série: $batt_sn "
[ "$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_detail+="pleine charge théorique: $batt_capa_design$batt_unit => "
if [ "$batt_conso" != "0" ]; then
batt_restant+="(consommation en cours: $(printf "%'d" $batt_conso)$(sed 's/h//' <<< $batt_unit), "
batt_restant+="charge actuelle: $(printf "%'d" $batt_capa_now)$batt_unit)"
fi
[ "$batt_sante" ] && batt_detail+="$batt_sante% (indicateur)"$' \n'
[ "$batt_restant" ] && batt_detail+="$batt_restant"$' \n'
# alertes batterie
[ "$batt_nb" -gt 1 ] && pluriel="s" || unset pluriel
[ "$alert_batt_alarm" ] && batt_detail+="**batterie en alarme** $alert_batt_alarm "
if [ "$batt_capa_design" == "$batt_capa_full" ] && [ "$batt_volt_min" == "$batt_volt_now" ]; then
batt_detail+="les pleines charges et les voltages sont incohérents, ou batterie$pluriels "
batt_detail+="mal gérée$pluriel ou batterie$pluriels HS "
fi
if [ "$(awk '{printf "%d", $1}' <<< $batt_sante)" -lt 50 ] && [[ "$batt_status" == "Full" || "$batt_status" == "Unknow" ]]; then
batt_detail+="batterie$pluriel mal chargée$pluriel: mauvais état"$' \n'
else
batt_detail+=$' \n'
fi
done
fget_batt=${batt_detail::-1} # suppression dernier $'\n'
fget_batt_nb="$batt_nb"
fi
}
figet_batt_test(){ # 13/10/2017
@ -1109,7 +1103,7 @@ figet_cpu(){ # thanks neofetch, assigne $fget_cpu $fget_core # 10/10/2017
fget_cpu="$cpu"
}
figet_de(){ # thanks neofetch, assigne $fget_de #09/10/2017
figet_de(){ # thanks neofetch, assigne $fget_de #14/10/2017
# local de="${XDG_CURRENT_DESKTOP/i3}" #supprime i3??...
local de="$XDG_CURRENT_DESKTOP"
de="${de/'X-'}"
@ -1135,13 +1129,13 @@ figet_de(){ # thanks neofetch, assigne $fget_de #09/10/2017
;;
esac
fget_de="${de,,}"
fget_de="${figet_de^}"
fget_de="${fget_de^}"
}
# assigne $disk_detail $disk_hotplug $disk_fix $part_fix $part_hotplug $part_fix_tot
# $disk_ata $disk_usb $disk_mmc $disk_nvme
figet_disk(){ # 11/10/2017
local vendor_model idisk
# $disk_ata $disk_usb $disk_mmc $disk_nvme
figet_disk(){ # 14/10/2017
local vendor_model idisk list_id
# détails disques et séquences disques fixes et amovibles, $disk_detail, $disk_fix, $disk_hotplug
unset disk_hotplug disk_fix part_fix part_hotplug
disk_detail="$(printf '%6s %8s %-24s %-s' "disque" "taille" "vendeur modèle" "n° serie révision")"$'\n'
@ -1175,14 +1169,14 @@ figet_disk(){ # 11/10/2017
part_fix_tot="espace disque des partitions fixes montées (total, utilisé, dispo): "
part_fix_tot+="$(df -h --total --output=size,used,avail $(printf '/dev/%s ' $part_fix) | tail -n-1 | xargs)"
part_fix_tot="$(sed 's/G/Go/g; s/M/Mo/g; s/K/ko/g' <<< $part_fix_tot)"
disk_ata="$(ls -l /dev/disk/by-id/ | gawk '{print $9,$11}')"
disk_ata="$(sed '/^ata/!d; /part/d; /\/sd/!d; s/^.*\(sd..*\)$/\1/' <<< $disk_ata | tr '\n' ' ')"
disk_usb="$(ls -l /dev/disk/by-id/ | gawk '{print $9,$11}')"
disk_usb="$(sed '/^usb/!d; /part/d; /\/sd/!d; s/^.*\(sd..*\)$/\1/' <<< $disk_usb | tr '\n' ' ')"
disk_mmc="$(ls -l /dev/disk/by-id/ | gawk '{print $9,$11}')"
disk_mmc="$(sed '/^mmc/!d; /part/d; /\/mmcblk/!d; s/^.*\(mmcblk..*\)$/\1/' <<< $disk_mmc | tr '\n' ' ')"
disk_nvme="$(ls -l /dev/disk/by-id/ | gawk '{print $9,$11}')"
disk_nvme="$(sed '/^nvme/!d; /part/d; /\/nvme/!d; s/^.*\(nvme...*\)$/\1/' <<< $disk_nvme | tr '\n' ' ')"
list_id="$(ls -l /dev/disk/by-id/ | gawk '{print $9,$11}')"
disk_ata="$(sed '/^ata/!d; /part/d' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
disk_usb="$(sed '/^usb/!d; /part/d' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
# disk_mmc="$(sed '/^mmc/!d; /part/d; /\/mmcblk/!d; s/^.*\(mmcblk..*\)$/\1/' <<< $list_id | tr '\n' ' ')"
disk_mmc="$(sed '/^mmc/!d; /part/d' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
# disk_nvme="$(sed '/^nvme/!d; /part/d; /\/nvme/!d; s/^.*\(nvme...*\)$/\1/' <<< $list_id | tr '\n' ' ')"
disk_nvme="$(sed '/^nvme/!d; /part/d' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
# disk_nvme="$(sed '/^nvme/!d; /part/d' <<< $list_id | awk -F '/' '{if ($0=""){print "-"} else {print $NF}}' | tr '\n' ' ')"
[ "$disk_ata" ] || disk_ata="-"
[ "$disk_usb" ] || disk_usb="-"
[ "$disk_mmc" ] || disk_mmc="-"
@ -1283,11 +1277,11 @@ figet_gpu(){ # thanks neofetch, assigne $fget_gpu # 09/10/2017
}
# acpi via kernel, hardware monitor, assigne $fget_hw_nb $fget_hw
figet_hw(){ # 13/10/2017
figet_hw(){ # 14/10/2017
local ihw ihwx text core fan autre nbf nbc input crit hyst
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"
fget_hw="gestion ACPI non accessible"
return 1
fi
unset fan core autre
@ -1297,14 +1291,19 @@ figet_hw(){ # 13/10/2017
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"$' \n'
elif grep -Eq 'temp[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
input=$(gawk '{printf "%.1f", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_input))
crit=$(gawk '{printf "%.1f", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit 2>/dev/null))
hyst=$(gawk '$0!="" {printf "%.1f", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit_hyst 2>/dev/null))
max=$(gawk '$0!="" {printf "%.1f", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_max 2>/dev/null))
fi
if grep -Eq 'temp[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
input=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_input 2>/dev/null))
crit=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit 2>/dev/null))
hyst=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit_hyst 2>/dev/null))
max=$(gawk '$0!="" {printf "%.1f ", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_max 2>/dev/null))
[ "$input" ] && input=${input::-1} # suppression espace de fin (nécessaire si multi-valeurs)
[ "$crit" ] && crit=${crit::-1}
[ "$hyst" ] && hyst=${hyst::-1}
[ "$max" ] && max=${max::-1}
if grep -q 'core' <<< $(cat /sys/class/hwmon/$ihw/name) ; then
nbc=$(( nbc+1 ))
core+="core$nbc $input""°C "
core+="core$nbc: $input""°C "
[ "$max" ] && core+="(max: $max""°C) "
[ "$crit" ] && core+="(crit: $crit""°C) "
[ "$hyst" ] && core+="(hyst: $hyst""°C) "
@ -1583,28 +1582,38 @@ figet_wm(){ # thanks neofetch, assigne $fget_wm # 09/10/2017
fget_wm="$wm"
}
# aiguillage export paste
fipaste(){
f__requis "curl" # requis pour paste
fipaste_curl_pastery "$fileOutput" "$pasteDuration" "$optDebug"
# à tester fipaste_curl_markdownshare "$fileOutput"
}
fipaste_curl_pastery(){ # $1 fichier à exporter, $2 durée de conservation en jour; $3 debug # 10/10/2017
# $1 fichier à exporter, $2 durée de conservation en jour; $3 debug
fipaste_curl_pastery(){ # 14/10/2017
[ -e "$1" ] || f__error "fichier $1 inexistant"
local curl id pluriel
# 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" || 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"
if grep '"result": "error' <<< "$curl" ;then
f__info "raw" "$RED Erreur critique export rapport:"
f__info "$curl"
f__info "merci contacter $projet $contact pour aider à parfaire le script"
else
id="$(echo $curl | cut -d '"' -f 4)"
[ "$pasteDuration" -gt 1 ] && pluriel="s" || unset pluriel
f__info "\n votre paste:$GREEN https://www.pastery.net/$id/" \
"(valide pendant $RED$pasteDuration jour$pluriel)"
fi
[ "$3" == "debugPaste" ] && f__info "$curl"
# UTF-8
# ?api_key=<api_key>
# &duration=<duration> en mn, 1 jour par défaut
# &language=autodetect possible
# &max_views=<max_views>
# 100ko max
#{"id": "kddgar", "title": "getInfo_2.5.0", "url": "https://www.pastery.net/kddgar/", "language": "markdown", "duration": 1439}
#{"result": "error", "error_msg": "Your request body was not valid UTF-8."}
}
fipaste_curl_markdownshare(){ # à tester/finir
@ -1842,7 +1851,7 @@ if [ "$retourFUser" -eq 2 ]; then
fi
[ "$(grep -o 'version 4' <<< $(bash --version) | sed 's/version //')" -ge "4" ] || f__error "bash version 4"
f__requis "gawk wget ip>iproute2 lspci>pciutils" # requis pour fonctionnement programme
f__requis "gawk wget ip>iproute2 lspci>pciutils strings>binutils" # requis pour fonctionnement programme
prg_alert_crit
options=$@
@ -1885,9 +1894,9 @@ unset k
for j in $options; do
case $j in
-t | --test )
prg_1
# prg_1
fi_disk
prg_3
# prg_3
exit ;; # test seulement
-c* | all )
[ "$j" == "-c" ] && exec $0 "menu"
@ -1907,21 +1916,28 @@ for j in $options; do
-h )
f_help
exit ;; # affichage help
--debug-all )
prg_1
figet_batt_test
figet_dmi_test
figet_hw_test
prg_3
exit ;; # test batterie, dmi, hwmon
--debug-batt )
prg_1
figet_batt_test
prg_3
exit ;; # rapport batterie avec affichage /sys/class/power_supply/BAT?/uevent
exit ;; # test batterie avec scan /sys/class/power_supply/
--debug-dmi )
prg_1
figet_dmi_test
prg_3
exit ;; # rapport batterie avec affichage /sys/class/power_supply/BAT?/uevent
exit ;; # test dmi avec affichage /sys/class/dmi/id/
--debug-hw )
prg_1
figet_hw_test
prg_3
exit ;; # rapport batterie avec affichage /sys/class/power_supply/BAT?/uevent
exit ;; # test hwmon avec affichage /sys/class/hwmon/
--dmesg )
prg_1
fi_log_xorg

View File

@ -4,10 +4,29 @@
## todo
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
* disk: comptage, pluriel, renommage variables publiques, révision, fin de lignes
* disk: renommage variables publiques, révision, fin de lignes
* figet_cpu, refaire
* réseau réviser
* bug temp cpu (neofetch)
---
debug-hw x401
paste error non UTF-8 file->tempoNonUTF-8
---
## 2.6.0 14/10/2017
* révision: figet_batt: +batt_volt_now, réécriture avec gawk majoritaire, alertes batterie
* révision: f__scandir
* révision & mieux: fipaste_curl_pastery, gestion erreur paste non utf-8
* révision: fi_disk, pluriel sur disk fix & hotplug
* fix: figet_disk, cd/dvd srx pris en compte
* fix: figet_de correction variable publique
* fix: figet_hw temp &fan éventuel et test sur présence temp crit et hyst
* fix: f__scandir bug utf-8, usage strings
* fix: figet_batt division by 0 (p200)
* fix: figet_hw plusieurs valeurs(temp) par device (p200)
## 2.5.0 13/10/2017
* réécriture: figet_dmi_test, figet_hw_test (f__scandir)