This commit is contained in:
kyodev 2017-08-03 13:37:46 +02:00
parent 29d487249f
commit fa0dbb036e
1 changed files with 45 additions and 13 deletions

View File

@ -1,12 +1,11 @@
#!/bin/bash
version=0.6.0
version=0.6.4
date="08/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues"
script="getInfo"
urlScript="https://framagit.org/kyodev/kyopages/raw/master/scripts/$script"
urlNotice=""
##### license LPRAB/WTFPL
# auteur: simpledebian
@ -120,7 +119,7 @@ f__user(){
# test wget, $1 url à tester, sortie script sur erreur
f__wget_test(){
echo " $1"
wget -Sq --tries=1 --timeout=15 --user-agent="$user_agent" -O /dev/null "$1"
wget -Sq --tries=1 --timeout=15 -O /dev/null "$1"
f__error "Erreur wget" " réessayer et si persistance, contacter $projet $contact" " en indiquant les messages précédents."
}
@ -159,7 +158,7 @@ fscript_remove(){
# version script en ligne, assigne $versionScript, $script_aJour=ok|ko
fscript_get_version(){
versionScript="$(wget -q --tries=2 --timeout=15 --user-agent="$user_agent" -O - "$urlScript" | grep '^version=' | cut -d '=' -f 2)"
versionScript="$(wget -q --tries=2 --timeout=15 -O - "$urlScript" | grep '^version=' | cut -d '=' -f 2)"
if [ "$version" != "$versionScript" ]; then
f__info "version script en ligne: $versionScript, mise à jour possible"
script_aJour="ko"
@ -172,7 +171,7 @@ fscript_dl(){
local dirTemp="/tmp/$script-$RANDOM/"
mkdir -p "$dirTemp"
opType="upgrade"
wget -q --show-progress --tries=2 --timeout=15 --user-agent="$user_agent" -O "$dirTemp$script" "$urlScript"
wget -q --show-progress --tries=2 --timeout=15 -O "$dirTemp$script" "$urlScript"
if [ "$?" != "0" ]; then f__wget_test "$urlScript"; fi
chmod a+rwx "$dirTemp$script"
chown "$user_": "$dirTemp$script"
@ -266,10 +265,10 @@ get_cpu() { # thanks neofetch, assigne $cpu
local temp_dir="/sys/class/hwmon/hwmon0/temp1_input"
# Get cpu speed
if [[ -d "$speed_dir" ]]; then
# Fallback to cpuinfo_max_freq if $speed_type fails
local speed="$(< "${speed_dir}/${speed_type}")" || local speed="$(< "${speed_dir}/bios_limit")" || \
local speed="$(< "${speed_dir}/scaling_max_freq")"
local speedMin="$(< "${speed_dir}/scaling_min_freq")"
local speed="$(< "${speed_dir}/scaling_max_freq")"
speed="$((speed / 100000))"
local speedMin="$((speedMin / 100000))"
else
local speed="$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)"
local speed="$((speed / 100))"
@ -285,7 +284,8 @@ get_cpu() { # thanks neofetch, assigne $cpu
coresT="$(grep -c "^processor" /proc/cpuinfo)" # logique
# Fix for speeds under 1ghz
if [[ -z "${speed:1}" ]]; then speed="0.${speed}"; else speed="${speed:0:1}.${speed:1}"; fi
cpu="$cpu @ ${speed}GHz $temp"
if [[ -z "${speedMin:1}" ]]; then speedMin="0.${speedMin}"; else speedMin="${speedMin:0:1}.${speedMin:1}"; fi
cpu="$cpu @ ${speedMin} - ${speed} GHz $temp"
# Remove uneeded patterns from cpu output, this is faster than sed/gsub
cpu="${cpu//(tm)}"
cpu="${cpu//(TM)}"
@ -303,6 +303,15 @@ get_cpu() { # thanks neofetch, assigne $cpu
cpu="${cpu/@/(${cores})(${coresT}) @}"
}
get_cpu2(){
local cpu_bogomips=$(sed -n 's/^bogomips.*: \(.*\)$/\1/p' /proc/cpuinfo | head -n 1)
local cpu_addr=$(sed -n 's/^address sizes.*: \(.*\)$/\1/p' /proc/cpuinfo | head -n 1)
local cpu_flags=$(sed -n 's/^flags.*: \(.*\)$/\1/p;' /proc/cpuinfo | head -n 1)
cpu2+="bogomips: $cpu_bogomips \n"
cpu2+="$cpu_addr \n"
cpu2+="flags cpu: \n$cpu_flags "
}
get_de() { # thanks neofetch, assigne $de
de="${XDG_CURRENT_DESKTOP/i3}"
de="${de/'X-'}"
@ -352,6 +361,12 @@ get_distro() { # thanks neofetch, assigne $distro
[[ -z "$distro" ]] && distro="$os (Unknown)"
}
get_dmesg(){
# ! root
dmesg -l err
dmesg -l warn
}
get_gpu() { # thanks neofetch, assigne $gpu
gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')"
case "$gpu" in
@ -560,8 +575,8 @@ fi_reseau(){
text+="$resolv \n"
text+='```\n'
text+="**network managers** \n"
[ "$NETMGRINST" ] && text+="installé(s): $NETMGRINST \n" || text+="non trouvé parmi: ${NETMGRNAMES[@]} \n"
text+="en fonctionnement: "
[ "$NETMGRINST" ] && text+="**installé(s):** $NETMGRINST \n" || text+="non trouvé parmi: ${NETMGRNAMES[@]} \n"
text+="**en fonctionnement:** "
[ "$netmgrrun" ] && text+="$netmgrrun" || text+="non trouvé\n"
echo -e "$text" >> "$fileOutput"
}
@ -580,6 +595,7 @@ fi_systeme(){
local text="\n## système\n\n"
get_distro; text+="$distro \n"
f__architecture || f__error "Architecture non supportée" "vous pouvez contacter contacter $projet $contact si vous voulez aider à parfaire le script"
text+='```\n'
text+="architecture: $architecture \n"
text+="$bootImage \n"
[ $description ] && text+="description: $description \n"
@ -590,6 +606,7 @@ fi_systeme(){
get_shell; text+="shell: $shell \n"
text+="shells possibles: $shells \n"
get_cpu; text+="CPU: $cpu \n"
get_cpu2; text+="$cpu2 \n"
get_gpu; text+="GPU: $gpu \n"
get_memory; text+="mémoire utilisée/totale: $memory \n"
get_resolution; text+="résolution: $resolution \n"
@ -597,6 +614,20 @@ fi_systeme(){
get_battery; text+="Batteries(s): $battery \n"
get_local_ip; text+="IP locale: $local_ip \n"
text+="dernier boot: $lastboot, uptime: $uptime \n"
text+='```\n'
echo -e "$text" >> "$fileOutput"
}
fi_system_analyse(){ # Analyze system boot-up performance
local bootTime=$(systemd-analyze time)
local bootBlame=$(systemd-analyze blame | head -n 20)
local text="\n## analyse boot\n\n"
text+="$(sed 's/Startup finished in /durée de boot: /; s/userspace/espace utilisateur/' <<< $bootTime) \n\n"
text+="**systemd-analyze blame | head -n 20** \n"
text+='```\n'
text+="$bootBlame \n"
text+='```\n'
echo -e "$text" >> "$fileOutput"
}
@ -621,8 +652,9 @@ fi_main2(){ # traitements principaux
echo -e "# getInfo $version sur $hote / $os \n" > "$fileOutput"
echo -e "Rapport au $dateRapport" >> "$fileOutput"
fi_systeme
fi_reseau
get_modules "net"
# fi_reseau
# get_modules "net"
fi_system_analyse
}
fi_main3(){ # fin de traitements
cat $fileOutput