getInfo 2.12.0

This commit is contained in:
kyodev 2017-10-22 06:45:56 +02:00
parent e2db1562c4
commit 05b283572c
2 changed files with 108 additions and 132 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
version=2.11.3
version=2.12.0
date="21/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
@ -359,35 +359,23 @@ EOF
echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
}
fi_batt(){ # 13/10/2017
fi_batt(){ #v2 21/10/2017
[ "$fget_batt_nb" ] || figet_batt # 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+="$fget_batt\n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
f_display "fget_batt" "sans"
}
fi_cpu(){ # 17/10/2017
#manuellement lscpu (util-linux)
local cpu_addr cpu_bogomips cpu_flags text
cpu_addr="$(sed -n 's/^address sizes.*: \(.*\)$/\1/p' /proc/cpuinfo | sed -n '1p')"
cpu_bogomips="$(sed -n 's/^bogomips.*: \(.*\)$/\1/p' /proc/cpuinfo | sed -n '1p')"
fi_cpu(){ #v2 21/10/2017
#manuellement: lscpu (util-linux)
local cpu_flags text
cpu_flags="$(sed -n 's/^flags.*: \(.*\)$/\1/p;' /proc/cpuinfo | sed -n '1p')"
[ "$fget_cpu" ] || figet_cpu
###
text="## processeur \n\n"
text+='```\n'
text+="CPU: $fget_cpu \n"
text+="adressage: $cpu_addr \n"
text+="bogomips: $cpu_bogomips \n"
text+='```\n\n'
text+="flags cpu: \n"
text+='```\n'
text+="$cpu_flags \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
f_display "fget_cpu" "sans"
f_display "fget_cpu" "sans"
f_display "cpu_flags" "var" "flags cpu:"
}
fi_disk(){ #v2 21/10/2017
@ -519,7 +507,7 @@ fi_dmesg(){ #v2 21/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_graph(){ # 17/10/2017
fi_graph(){ #v2 21/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')"
@ -535,40 +523,25 @@ fi_graph(){ # 17/10/2017
[ "$fget_resolution" ] || figet_gpu
[ "$fget_resolution" ] || figet_resolution
###
text="## graphisme \n\n"
text+="| | | \n"
text+=" --- | --- \n"
text+="GPU | **$fget_gpu** \n\n"
text+="**résolution: $fget_resolution** \n\n"
text+='`'"lspci -nnv | grep -iEA 13 'vga|display|3d'"'` \n'
text+='```\n'
text+="$graphCards \n"
text+='```\n\n'
text="## graphisme \n\n"
text+="| | | \n"
text+="| --- | --- | \n"
text+="| GPU | **$fget_gpu** | \n\n"
text+="**résolution: $fget_resolution** \n\n"
f_display "graphCards" "cmd" "lspci -nnv | grep -iEA 13 'vga|display|3d"
if [ "$openGl" ]; then
text+='`'"glxinfo | grep 'OpenGL version'"'` \n'
text+='```\n'
text+="$openGl \n"
text+='```\n\n'
f_display "openGl" "cmd" "xrandr --query | grep '^ *[0-9]' | head -n 10" "(10 premières résolutions possibles)"
fi
text+='`'"xrandr --query | grep '^ *[0-9]' | head -n 10"'` (10 premières résolutions possibles) \n'
text+='```\n'
text+="$resolutions \n"
text+='```\n\n'
text+="### modules video \n\n"
text+="liste non garantie complète \n"
text+='```\n'
text+="$modules\n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
f_display "resolutions" "cmd" "glxinfo | grep 'OpenGL version"
text+="### modules video \n\n"
text+="liste non garantie complète \n"
f_display "modules" "sans"
}
fi_hw(){ # 12/10/2017
fi_hw(){ #v2 21/10/2017
figet_hw
text="## hardware monitor ACPI \n\n"
text+='```\n'
text+="$fget_hw\n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
f_display "fget_hw" "sans"
}
fi_journal(){ #v2 21/10/2017
@ -629,7 +602,7 @@ fi_journal(){ #v2 21/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_localisation(){ # 11/10/2017
fi_locale(){ # 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)"
timezone="$(< /etc/timezone)"
@ -1003,7 +976,7 @@ fi_system_analyse(){ # 25/09/2017
echo -e "$text" >> "$fileOutput"
}
fi_systeme(){ # 14/10/2017
fi_systeme(){ # 21/10/2017
local mbr description uname bootImage xorg shells lastboot uptime pluriel charge text
[ -d /sys/firmware/efi ] && mbr="**EFI**" || mbr="**Legacy (mbr)**"
[ -x "/usr/bin/lsb_release" ] && description="$(lsb_release -ds)" #dépend de apt install lsb-release, sur debian, en standard, juste : lsb-base
@ -1033,37 +1006,37 @@ fi_systeme(){ # 14/10/2017
figet_shell
figet_wm
###
text="## système \n\n"
text+="$fget_dmi \n\n"
text+="| | | \n"
text+=" --- | --- \n"
text+="CPU | **$fget_cpu** \n"
text+="GPU | **$fget_gpu** \n"
text="## système \n\n"
text+="$fget_dmi \n\n"
text+="| | | \n"
text+="| --- | --- | \n"
text+="CPU | **$(sed -n '1p' <<< $fget_cpu)** \n"
text+="GPU | **$fget_gpu** \n"
text+="boot | $mbr \n"
text+="distribution | **$fget_distro** \n"
text+="distribution | **$fget_distro** \n"
f__architecture || f__info "Architecture non supportée" "vous pouvez contacter $projet, $contact " \
"pour aider à parfaire le script"
text+='```\n'
text+="architecture: $architecture \n"
[ "$description" ] && text+="description: $description \n"
text+="uname: $uname \n"
text+="$bootImage \n"
text+="démon d'initialisation: $initDaemon \n"
text+="résolution: $fget_resolution \n"
text+="serveur d'affichage: $xorg \n"
text+="desktop (DE): $fget_de \n"
text+="window manager: $fget_wm \n"
text+="shell actif: $fget_shell \n"
text+="shells installés: $shells \n"
text+="$fget_disk_part_fix_tot \n"
text+='``` \n'
text+="architecture: $architecture \n"
[ "$description" ] && text+="description: $description \n"
text+="uname: $uname \n"
text+="$bootImage \n"
text+="démon d'initialisation: $initDaemon \n"
text+="résolution: $fget_resolution \n"
text+="serveur d'affichage: $xorg \n"
text+="desktop (DE): $fget_de \n"
text+="window manager: $fget_wm \n"
text+="shell actif: $fget_shell \n"
text+="shells installés: $shells \n"
text+="$fget_disk_part_fix_tot \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"
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"
text+='```\n\n'
text+="dernier boot: $lastboot, uptime: $uptime \n"
text+="charge système depuis les 1, 5 et 15 dernières minutes: $charge \n"
text+='``` \n\n'
echo -e "$text" >> "$fileOutput"
}
@ -1174,54 +1147,48 @@ figet_batt(){ #v2 17/10/2017
fget_batt_nb="$batt_nb"
}
figet_cpu(){ # thanks neofetch, assigne $fget_cpu $fget_core # 17/10/2017
local cpu speed_dir temp_dir speedMin speed speedMin speed temp cores thread plurielc plurielt
cpu="$(gawk -F ': | @' '/model name|Processor/ {printf $2; exit}' /proc/cpuinfo)"
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
temp_dir="/sys/class/hwmon/hwmon0/temp1_input"
# Get cpu speed
if [[ -d "$speed_dir" ]]; then
speedMin="$(< "${speed_dir}/scaling_min_freq")"
speed="$(< "${speed_dir}/scaling_max_freq")"
speed="$((speed / 100000))"
speedMin="$((speedMin / 100000))"
else
speed="$(gawk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)"
speed="$((speed / 100))"
fi
# Get cpu temp
if [ -f "$temp_dir" ]; then
temp="$(< "$temp_dir")"
temp="$((temp * 100 / 10000))" # 33000 x 100 / 10 000 = 330
temp="[${temp/${temp: -1}}.${temp: -1}°C]" # formatage 1 point décimal
fi
# Show/hide hyperthreaded cores
cores="$(sort -u /proc/cpuinfo | grep -c '^core id')"
thread="$(grep -c "^processor" /proc/cpuinfo)"
# Fix for speeds under 1ghz
if [[ -z "${speed:1}" ]]; then speed="0.${speed}"; else speed="${speed:0:1}.${speed:1}"; fi
if [[ -z "${speedMin:1}" ]]; then speedMin="0.${speedMin}"; else speedMin="${speedMin:0:1}.${speedMin:1}"; fi
# cpu="$cpu @ ${speedMin} - ${speed} GHz $temp"
cpu="$cpu @ ${speedMin} - ${speed} GHz"
# Remove uneeded patterns from cpu output, this is faster than sed/gsub
cpu="${cpu//(tm)}"
cpu="${cpu//(TM)}"
cpu="${cpu//(r)}"
cpu="${cpu//(R)}"
cpu="${cpu//CPU}"
cpu="${cpu//Processor}"
cpu="${cpu//Dual-Core}"
cpu="${cpu//Quad-Core}"
cpu="${cpu//Six-Core}"
cpu="${cpu//Eight-Core}"
cpu="${cpu//Core}"
cpu="${cpu//with Radeon * Graphics}"
# Add cpu cores & threads to output
[ "$cores" -gt 1 ] && plurielc="s"
[ "$thread" -gt 1 ] && plurielt="s"
cpu="${cpu/@/($cores core$plurielc-$thread thread$plurielt) @}"
fget_core="$cores core$plurielc-$thread thread$plurielt"
fget_cpu="$cpu"
# assigne $fget_cpu (3 lignes description cpu)
figet_cpu(){ #v2 21/10/2017
local cpuinfo speedNom speedMax speedMin speedCpu cpu1 cpu2 cpu3
cpuinfo="$(cat /proc/cpuinfo)"
# speed
speedNom=$(gawk -F ':' '/cpu MHz/ {printf "%.2f", $2/1000;exit}' <<< "$cpuinfo")
speedMax=$(gawk '{printf "%.2f", $1/1000000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 2>/dev/null)
speedMin=$(gawk '{printf "%.2f", $1/1000000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq 2>/dev/null)
speedCpu=""
[ "$speedMin" ] && speedCpu+="$speedMin/"
[ "$speedNom" ] && speedCpu+="$speedNom"
[[ "$speedMax" && "$speedMax" != "$speedNom" ]] && speedCpu+="/$speedMax"
[ "$speedCpu" ] && speedCpu=$(printf "%sGHz" $speedCpu)
[ "$speedCpu" ] || speedCpu=$(gawk -F '@' '/model name/ {sub(/^ | $/,"",$2); print $2;exit}' <<< "$cpuinfo")
# motifs?: Processor Dual-Core Quad-Core Six-Core Eight-Core Core 'with Radeon * Graphics'
cpu1=$(
gawk -v "speedCpu=$speedCpu" -F ':|@' '
/^model name/ { gsub(/^ | *$|\(R\)|\(TM\)|\(r\)|\(tm\)|CPU/,"",$2); gsub(/ /," ",$2); cpu=$2 }
/^physical id/ { if ($2+1 != nbCpu) nbCpu=$2+1 }
/cpu cores/ { procCore=sprintf("%d",$2); if (procCore>1) pllc="s" }
/siblings/ { procThread=sprintf("%d",$2); if (procThread>1) pllt="s" }
/microcode/ { sub(/^ /,"",$2); microCode=$2 }
END { print nbCpu" x "cpu " (" nbCpu "c," procThread "t) {" speedCpu "} microcode:" microCode }
' <<< "$cpuinfo "
)
cpu2=$(
gawk -F ':' '
/^vendor_id/{gsub(/ /,"",$2);vendor=$2}; /^cpu family/{family=$2};
/^model[^ ]/{model=$2}; /^stepping/{rev=$2}
END {print vendor" famille" family", modèle"model", révision" rev}
' <<< "$cpuinfo"
)
cpu3=$(
gawk -F ':' '
/address sizes/ { gsub(/ bits/,"b",$2); sub(/physical/,"physique",$2);
sub(/virtual/,"virtuel",$2); sub(/^ | $/,"",$2); add=$2 }
/cache size/ {gsub(/ /,"",$2); gsub(/B/,"o",$2); gsub(/K/,"k",$2); cache=$2}
/bogomips/ { bogomips=sprintf("%d",$2) }
END { print add ", bogomips: " bogomips ", cache: " cache }
' <<< "$cpuinfo"
)
fget_cpu=$(echo -e "$cpu1\n$cpu2\n$cpu3")
}
figet_de(){ # thanks neofetch, assigne $fget_de #14/10/2017
@ -1959,7 +1926,7 @@ prg_2(){ # traitements principaux
fi
if [[ "$1" == all || "$1" =~ c ]]; then #configuration #debian, packages -cc
echo -e "# Configuration et packages \n" >> "$fileOutput"
for i in fi_localisation fi_nonFree fi_sources ; do
for i in fi_locale fi_nonFree fi_sources ; do
$i
printf "."
done
@ -2081,7 +2048,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_disk
fi_cpu
prg_3
exit ;; # test seulement
-c* | all )

View File

@ -4,16 +4,25 @@
## todo
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
* réseau réviser
* figet_cpu, refaire
* bug temp cpu (neofetch) temp supprimée temporairement
* réseau réviser, interface name: virbr0
* désactiver wifi si pas de carte réseau
* bug fedora: which à supprimer/émuler
* bug fedora: journaux xorg
* bug fedora: identification distrib
* bug fedora: localisation
* bug: acpi, power_supply si vieille tour
* bug ssh: setxkbmap : commande introuvable, Can't open display??
* bug à confirmer? tableau gpu
---
* f__requis f__wget_test fscript_get_version fscript_update fscript_cronAnacron
## 2.11.3 21/10/2017
## 2.12.0 21/10/2017
* nouveau: ré-écriture figet_cpu (sans température)
* suppression : figet_cpu neofetch
* révision: fi_cpu
* révision affichage avec f_display
## 2.11.1 20/10/2017